test if new session gets created correctly

This commit is contained in:
Christoph Wendt
2015-08-26 16:51:49 -07:00
parent a7da07947a
commit e6e28fa2c8
2 changed files with 27 additions and 3 deletions

View File

@@ -2,7 +2,9 @@
#import <OCMock/OCMock.h>
#import "BITTestsDependencyInjection.h"
#import "BITTelemetryManager.h"
#import "BITTelemetryManagerPrivate.h"
#import "BITHockeyBaseManagerPrivate.h"
#import "BITSession.h"
#define HC_SHORTHAND
#import <OCHamcrestIOS/OCHamcrestIOS.h>
@@ -24,13 +26,35 @@
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
- (void)testTelemetryManagerGetsInstantiated {
self.sut = [BITTelemetryManager new];
XCTAssertNotNil(self.sut, @"Should not be nil.");
}
- (void)testNewSessionIsCreatedCorrectly {
self.sut = [BITTelemetryManager new];
[self.mockUserDefaults setBool:NO forKey:@"BITApplicationWasLaunched"];
NSString *testSessionId1 = @"12345";
NSString *testSessionId2 = @"67890";
// First session
BITSession *actualSession1 = [self.sut createNewSessionWithId:testSessionId1];
XCTAssertEqualObjects(actualSession1.sessionId, testSessionId1);
XCTAssertEqualObjects(actualSession1.isNew, @"true");
XCTAssertEqualObjects(actualSession1.isFirst, @"true");
// Next sessions
BITSession *actualSession2 = [self.sut createNewSessionWithId:testSessionId2];
XCTAssertEqualObjects(actualSession2.sessionId, testSessionId2);
XCTAssertEqualObjects(actualSession2.isNew, @"true");
XCTAssertEqualObjects(actualSession2.isFirst, @"false");
}
- (void)testRegisterObserversOnStart {
self.mockNotificationCenter = mock(NSNotificationCenter.class);
self.sut = [BITTelemetryManager new];
[self.sut startManager];

View File

@@ -23,8 +23,8 @@ static id mockCenter;
}
- (void)tearDown {
[super tearDown];
mockUserDefaults = nil;
[super tearDown];
}
# pragma mark - Helper