@@ -40,14 +40,6 @@ @interface AWSPinpointNSSecureCodingTests : XCTestCase
40
40
41
41
@property (nonatomic , strong ) NSURL *archiveURL;
42
42
43
- // Specifically declare these methods in the interface so we can set availability
44
- // to iOS 11. Tests that don't use newer APIs don't need to be declared here.
45
- - (void )testProfileArchivesAndUnarchivesUsingSecureCoding API_AVAILABLE(ios(11 ));
46
- - (void )testProfileArchivesAndUnarchivesWithLegacyAPI API_AVAILABLE(ios(11 ));
47
-
48
- - (void )testSessionArchivesAndUnarchivesSecurely API_AVAILABLE(ios(11 ));
49
- - (void )testSessionArchivesAndUnarchivesWithLegacyAPI API_AVAILABLE(ios(11 ));
50
-
51
43
@end
52
44
53
45
@implementation AWSPinpointNSSecureCodingTests
@@ -60,6 +52,16 @@ - (void)testProfileArchivesAndUnarchivesUsingSecureCoding {
60
52
debug: YES
61
53
userDefaults: [NSUserDefaults standardUserDefaults ] keychain: [AWSUICKeyChainStore keyChainStoreWithService: @" com.amazonaws.AWSPinpointContext" ]];
62
54
55
+ [profile addAttribute: @[@" Attribute1" , @" Attribute2" ]
56
+ forKey: @" profileAttributeKey" ];
57
+ [profile addMetric: [NSNumber numberWithInt: 10 ] forKey: @" profileMetricKey" ];
58
+
59
+ AWSPinpointEndpointProfileUser *user = [AWSPinpointEndpointProfileUser new ];
60
+ user.userId = @" UserId" ;
61
+ [user addUserAttribute: @[@" Attribute1" , @" Attribute2" ]
62
+ forKey: @" userAttributeKey" ];
63
+ profile.user = user;
64
+
63
65
NSError *error;
64
66
NSData *data = [NSKeyedArchiver archivedDataWithRootObject: profile
65
67
requiringSecureCoding: YES
@@ -80,21 +82,6 @@ - (void)testProfileSupportsSecureCoding {
80
82
XCTAssert ([AWSPinpointEndpointProfile supportsSecureCoding ]);
81
83
}
82
84
83
- - (void )testProfileArchivesAndUnarchivesWithLegacyAPI {
84
- AWSPinpointEndpointProfile *profile = [[AWSPinpointEndpointProfile alloc ] initWithApplicationId: @" app-id-123"
85
- endpointId: @" endpoint-id-123"
86
- applicationLevelOptOut: YES
87
- isRegisteredForRemoteNotifications: YES
88
- debug: YES
89
- userDefaults: [NSUserDefaults standardUserDefaults ] keychain: [AWSUICKeyChainStore keyChainStoreWithService: @" com.amazonaws.AWSPinpointContext" ]];
90
- NSData *data = [NSKeyedArchiver archivedDataWithRootObject: profile];
91
-
92
- AWSPinpointEndpointProfile *unarchivedProfile = (AWSPinpointEndpointProfile *)[NSKeyedUnarchiver unarchiveObjectWithData: data];
93
-
94
- // The class doesn't support `isEqual` so we'll compare string descriptions
95
- XCTAssertEqualObjects ([unarchivedProfile description ], [profile description ]);
96
- }
97
-
98
85
- (void )testSessionArchivesAndUnarchivesSecurely {
99
86
AWSPinpointSession *session = [[AWSPinpointSession alloc ] initWithSessionId: @" session-123"
100
87
withStartTime: [NSDate new ]
@@ -121,18 +108,4 @@ - (void)testSessionSupportsSecureCoding {
121
108
XCTAssert ([AWSPinpointSession supportsSecureCoding ]);
122
109
}
123
110
124
- - (void )testSessionArchivesAndUnarchivesWithLegacyAPI {
125
- AWSPinpointSession *session = [[AWSPinpointSession alloc ] initWithSessionId: @" session-123"
126
- withStartTime: [NSDate new ]
127
- withStopTime: nil ];
128
- NSData *data = [NSKeyedArchiver archivedDataWithRootObject: session];
129
-
130
- AWSPinpointSession *unarchivedSession = (AWSPinpointSession *)[NSKeyedUnarchiver unarchiveObjectWithData: data];
131
-
132
- // The class doesn't support `isEqual` or `description` so we'll compare property-by-property
133
- XCTAssertEqualObjects (unarchivedSession.sessionId , session.sessionId );
134
- XCTAssertEqualObjects (unarchivedSession.startTime , session.startTime );
135
- XCTAssertEqualObjects (unarchivedSession.stopTime , session.stopTime );
136
- }
137
-
138
111
@end
0 commit comments