mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-01-17 09:51:20 +00:00
test if new session gets created correctly
This commit is contained in:
@@ -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];
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ static id mockCenter;
|
||||
}
|
||||
|
||||
- (void)tearDown {
|
||||
[super tearDown];
|
||||
mockUserDefaults = nil;
|
||||
[super tearDown];
|
||||
}
|
||||
|
||||
# pragma mark - Helper
|
||||
|
||||
Reference in New Issue
Block a user