79 lines
2.0 KiB
Objective-C
79 lines
2.0 KiB
Objective-C
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// Licensed under the MIT License.
|
|
|
|
#import "MSACStartSessionLog.h"
|
|
#import "MSACTestFrameworks.h"
|
|
#import "MSACUtility.h"
|
|
|
|
@interface MSACStartSessionLogTests : XCTestCase
|
|
|
|
@property(nonatomic) MSACStartSessionLog *sut;
|
|
|
|
@end
|
|
|
|
@implementation MSACStartSessionLogTests
|
|
|
|
#pragma mark - Houskeeping
|
|
|
|
- (void)setUp {
|
|
[super setUp];
|
|
self.sut = [MSACStartSessionLog new];
|
|
}
|
|
|
|
- (void)tearDown {
|
|
[super tearDown];
|
|
}
|
|
|
|
#pragma mark - Tests
|
|
|
|
- (void)testSerializingSessionToDictionaryWorks {
|
|
|
|
// If
|
|
MSACDevice *device = [MSACDevice new];
|
|
NSString *typeName = @"startSession";
|
|
NSString *sessionId = @"1234567890";
|
|
NSDate *timestamp = [NSDate dateWithTimeIntervalSince1970:42];
|
|
|
|
self.sut.device = device;
|
|
self.sut.timestamp = timestamp;
|
|
self.sut.sid = sessionId;
|
|
|
|
// When
|
|
NSMutableDictionary *actual = [self.sut serializeToDictionary];
|
|
|
|
// Then
|
|
assertThat(actual, notNilValue());
|
|
assertThat(actual[@"type"], equalTo(typeName));
|
|
assertThat(actual[@"device"], notNilValue());
|
|
assertThat(actual[@"timestamp"], equalTo(@"1970-01-01T00:00:42.000Z"));
|
|
}
|
|
|
|
- (void)testNSCodingSerializationAndDeserializationWorks {
|
|
|
|
// If
|
|
MSACDevice *device = [MSACDevice new];
|
|
NSString *typeName = @"startSession";
|
|
NSString *sessionId = @"1234567890";
|
|
NSDate *timestamp = [NSDate dateWithTimeIntervalSince1970:42];
|
|
|
|
self.sut.device = device;
|
|
self.sut.timestamp = timestamp;
|
|
self.sut.sid = sessionId;
|
|
|
|
// When
|
|
NSData *serializedEvent = [MSACUtility archiveKeyedData:self.sut];
|
|
id actual = [MSACUtility unarchiveKeyedData:serializedEvent];
|
|
|
|
// Then
|
|
assertThat(actual, notNilValue());
|
|
assertThat(actual, instanceOf([MSACStartSessionLog class]));
|
|
|
|
MSACStartSessionLog *actualSession = actual;
|
|
assertThat(actualSession.device, notNilValue());
|
|
assertThat(actualSession.timestamp, equalTo(timestamp));
|
|
assertThat(actualSession.type, equalTo(typeName));
|
|
assertThat(actualSession.sid, equalTo(sessionId));
|
|
}
|
|
|
|
@end
|