Skip to content

Commit e52e136

Browse files
author
Josh Holtz
committed
Changed tests to us XCTAssert from NSAssert
1 parent 5d26a4e commit e52e136

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

Project/JSONAPITests/JSONAPITests.m

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ - (void)testMeta
5050
NSDictionary *json = @{ @"meta" : meta, @"linked" : linked, @"posts" : @[ @{ @"id" : @1, @"name" : @"Josh is awesome", @"links" : @{ @"author" : @9 } } ] };
5151

5252
JSONAPI *jsonAPI = [[JSONAPI alloc] initWithDictionary:json];
53-
NSAssert([meta isEqualToDictionary:jsonAPI.meta], @"Meta does not equal %@", meta);
54-
// @"No implementation for \"%s\"", __PRETTY_FUNCTION__
53+
XCTAssert([meta isEqualToDictionary:jsonAPI.meta], @"Meta does not equal %@", meta);
5554

5655
}
5756

@@ -62,7 +61,7 @@ - (void)testBadMeta
6261
NSDictionary *json = @{ @"meta" : meta, @"linked" : linked, @"posts" : @[ @{ @"id" : @1, @"name" : @"Josh is awesome", @"links" : @{ @"author" : @9 } } ] };
6362

6463
JSONAPI *jsonAPI = [[JSONAPI alloc] initWithDictionary:json];
65-
NSAssert(jsonAPI.meta == nil, @"Meta is not nil");
64+
XCTAssertNil(jsonAPI.meta, @"Meta is not nil");
6665

6766
}
6867

@@ -73,7 +72,7 @@ - (void)testLinkedCount
7372
NSDictionary *json = @{ @"meta" : meta, @"linked" : linked, @"posts" : @[ @{ @"id" : @1, @"name" : @"Josh is awesome", @"links" : @{ @"author" : @9 } } ] };
7473

7574
JSONAPI *jsonAPI = [[JSONAPI alloc] initWithDictionary:json];
76-
NSAssert(linked.count == jsonAPI.linked.count, @"Linked count does not equal %d", linked.count);
75+
XCTAssert(linked.count == jsonAPI.linked.count, @"Linked count does not equal %d", linked.count);
7776

7877
}
7978

@@ -85,8 +84,8 @@ - (void)testLinkedResource {
8584

8685
JSONAPI *jsonAPI = [[JSONAPI alloc] initWithDictionary:json];
8786
JSONAPIResource *linkedAuthorResource = [[jsonAPI.linked objectForKey:@"authors"] objectForKey:@9];
88-
NSAssert([[linkedAuthor9 objectForKey:@"id"] isEqualToNumber:linkedAuthorResource.ID] , @"Author resource ID does not equal %@", [linkedAuthor9 objectForKey:@"id"]);
89-
NSAssert([[linkedAuthor9 objectForKey:@"name"] isEqualToString:[linkedAuthorResource objectForKey:@"name"]] , @"Author resource name does not equal %@", [linkedAuthor9 objectForKey:@"name"]);
87+
XCTAssertEqualObjects([linkedAuthor9 objectForKey:@"id"], linkedAuthorResource.ID , @"Author resource ID does not equal %@", [linkedAuthor9 objectForKey:@"id"]);
88+
XCTAssertEqualObjects([linkedAuthor9 objectForKey:@"name"], [linkedAuthorResource objectForKey:@"name"] , @"Author resource name does not equal %@", [linkedAuthor9 objectForKey:@"name"]);
9089
}
9190

9291
- (void)testBadLinked
@@ -96,7 +95,8 @@ - (void)testBadLinked
9695
NSDictionary *json = @{ @"meta" : meta, @"linked" : linked, @"posts" : @[ @{ @"id" : @1, @"name" : @"Josh is awesome", @"links" : @{ @"author" : @9 } } ] };
9796

9897
JSONAPI *jsonAPI = [[JSONAPI alloc] initWithDictionary:json];
99-
NSAssert(jsonAPI.linked.count == 0, @"Linked is not 0");
98+
NSLog(@"%d HRM %d", jsonAPI.linked.count, 0);
99+
XCTAssert(jsonAPI.linked.count == 0, @"Linked is not 0");
100100

101101
}
102102

@@ -109,7 +109,7 @@ - (void)testResourcesCount {
109109
NSDictionary *json = @{ @"meta" : meta, @"linked" : linked, @"posts" : posts };
110110

111111
JSONAPI *jsonAPI = [[JSONAPI alloc] initWithDictionary:json];
112-
NSAssert(posts.count == [jsonAPI resourcesForKey:@"posts"].count, @"Posts count does not equal %d", posts.count);
112+
XCTAssert(posts.count == [jsonAPI resourcesForKey:@"posts"].count, @"Posts count does not equal %d", posts.count);
113113
}
114114

115115
- (void)testResourcesObject {
@@ -123,8 +123,8 @@ - (void)testResourcesObject {
123123
JSONAPI *jsonAPI = [[JSONAPI alloc] initWithDictionary:json];
124124
JSONAPIResource *resource = [jsonAPI resourceForKey:@"posts"];
125125

126-
NSAssert([[post objectForKey:@"id"] isEqualToNumber:resource.ID] , @"Posts ID does not equal %@", [post objectForKey:@"id"]);
127-
NSAssert([[post objectForKey:@"name"] isEqualToString:[resource objectForKey:@"name"]] , @"Posts name does not equal %@", [post objectForKey:@"name"]);
126+
XCTAssertEqualObjects([post objectForKey:@"id"], resource.ID, @"Posts ID does not equal %@", [post objectForKey:@"id"]);
127+
XCTAssertEqualObjects([post objectForKey:@"name"], [resource objectForKey:@"name"], @"Posts name does not equal %@", [post objectForKey:@"name"]);
128128
}
129129

130130
- (void)testResourceLinkSameTypeName {
@@ -141,9 +141,9 @@ - (void)testResourceLinkSameTypeName {
141141

142142
JSONAPIResource *linkedAuthor = [resource linkedResourceForKey:@"author"];
143143

144-
NSAssert(linkedAuthor != nil, @"Linked author is nil");
145-
NSAssert([[linkedAuthor objectForKey:@"name"] isEqualToString:[linkedAuthor9 objectForKey:@"name"]], @"Linked author's name is not equal to %@", [linkedAuthor9 objectForKey:@"name"]);
146-
NSAssert([[linkedAuthor objectForKey:@"name"] isEqualToString:[linkedAuthor9 objectForKey:@"name"]], @"Linked author's name is not equal to %@", [linkedAuthor9 objectForKey:@"name"]);
144+
XCTAssertNotNil(linkedAuthor, @"Linked author is nil");
145+
XCTAssertEqualObjects([linkedAuthor objectForKey:@"name"], [linkedAuthor9 objectForKey:@"name"], @"Linked author's name is not equal to %@", [linkedAuthor9 objectForKey:@"name"]);
146+
XCTAssertEqualObjects([linkedAuthor objectForKey:@"name"], [linkedAuthor9 objectForKey:@"name"], @"Linked author's name is not equal to %@", [linkedAuthor9 objectForKey:@"name"]);
147147

148148
}
149149

@@ -171,13 +171,13 @@ - (void)testResourceLinksSameTypeName {
171171
}
172172
}
173173

174-
NSAssert(linkedAuthorsResources.count == linkedAuthors.count, @"Linked author resource count is not %d", linkedAuthors.count);
174+
XCTAssert(linkedAuthorsResources.count == linkedAuthors.count, @"Linked author resource count is not %d", linkedAuthors.count);
175175

176-
NSAssert([[linkedAuthorResource9 objectForKey:@"name"] isEqualToString:[linkedAuthor9 objectForKey:@"name"]], @"Linked author's 9 name is not equal to %@", [linkedAuthor9 objectForKey:@"name"]);
177-
NSAssert([[linkedAuthorResource9 objectForKey:@"name"] isEqualToString:[linkedAuthor9 objectForKey:@"name"]], @"Linked author's 9 name is not equal to %@", [linkedAuthor9 objectForKey:@"name"]);
176+
XCTAssertEqualObjects([linkedAuthorResource9 objectForKey:@"name"], [linkedAuthor9 objectForKey:@"name"], @"Linked author's 9 name is not equal to %@", [linkedAuthor9 objectForKey:@"name"]);
177+
XCTAssertEqualObjects([linkedAuthorResource9 objectForKey:@"name"], [linkedAuthor9 objectForKey:@"name"], @"Linked author's 9 name is not equal to %@", [linkedAuthor9 objectForKey:@"name"]);
178178

179-
NSAssert([[linkedAuthorResource11 objectForKey:@"name"] isEqualToString:[linkedAuthor11 objectForKey:@"name"]], @"Linked author's 11 name is not equal to %@", [linkedAuthor9 objectForKey:@"name"]);
180-
NSAssert([[linkedAuthorResource11 objectForKey:@"name"] isEqualToString:[linkedAuthor11 objectForKey:@"name"]], @"Linked author's 11 name is not equal to %@", [linkedAuthor9 objectForKey:@"name"]);
179+
XCTAssertEqualObjects([linkedAuthorResource11 objectForKey:@"name"], [linkedAuthor11 objectForKey:@"name"], @"Linked author's 11 name is not equal to %@", [linkedAuthor9 objectForKey:@"name"]);
180+
XCTAssertEqualObjects([linkedAuthorResource11 objectForKey:@"name"], [linkedAuthor11 objectForKey:@"name"], @"Linked author's 11 name is not equal to %@", [linkedAuthor9 objectForKey:@"name"]);
181181

182182
}
183183

@@ -197,9 +197,9 @@ - (void)testResourceLinksRealDifferentTypeName {
197197

198198
JSONAPIResource *linkedPersonResource = [resource linkedResourceForKey:@"person"];
199199

200-
NSAssert(linkedPersonResource != nil, @"Linked person is nil");
201-
NSAssert([[linkedPersonResource objectForKey:@"name"] isEqualToString:[linkedPeople9 objectForKey:@"name"]], @"Linked person's 9 name is not equal to %@", [linkedPeople11 objectForKey:@"name"]);
202-
NSAssert([[linkedPersonResource objectForKey:@"name"] isEqualToString:[linkedPeople9 objectForKey:@"name"]], @"Linked person's 9 name is not equal to %@", [linkedPeople11 objectForKey:@"name"]);
200+
XCTAssertNotNil(linkedPersonResource, @"Linked person is nil");
201+
XCTAssertEqualObjects([linkedPersonResource objectForKey:@"name"], [linkedPeople9 objectForKey:@"name"], @"Linked person's 9 name is not equal to %@", [linkedPeople11 objectForKey:@"name"]);
202+
XCTAssertEqualObjects([linkedPersonResource objectForKey:@"name"], [linkedPeople9 objectForKey:@"name"], @"Linked person's 9 name is not equal to %@", [linkedPeople11 objectForKey:@"name"]);
203203

204204

205205
}
@@ -217,10 +217,10 @@ - (void)testResourceModels {
217217
JSONAPI *jsonAPI = [[JSONAPI alloc] initWithDictionary:json];
218218
PostResource *postResource = [jsonAPI resourceForKey:@"posts"];
219219

220-
NSAssert([postResource class] == [PostResource class], @"Post resource is not of type PostResource, but %@", [postResource class]);
221-
NSAssert([postResource.author class] == [PeopleResource class], @"Post resource's author is not of type PeopleResource, but %@", [postResource.author class]);
222-
NSAssert([postResource.name isEqualToString:[post objectForKey:@"name"]], @"Post name is not equal to %@", [post objectForKey:@"name"]);
223-
NSAssert([postResource.author.name isEqualToString:[linkedAuthor9 objectForKey:@"name"]], @"Author name is not equal to %@", [post objectForKey:@"name"]);
220+
XCTAssertEqual([postResource class], [PostResource class], @"Post resource is not of type PostResource, but %@", [postResource class]);
221+
XCTAssertEqual([postResource.author class], [PeopleResource class], @"Post resource's author is not of type PeopleResource, but %@", [postResource.author class]);
222+
XCTAssertEqualObjects(postResource.name, [post objectForKey:@"name"], @"Post name is not equal to %@", [post objectForKey:@"name"]);
223+
XCTAssertEqualObjects(postResource.author.name, [linkedAuthor9 objectForKey:@"name"], @"Author name is not equal to %@", [post objectForKey:@"name"]);
224224
}
225225

226226
@end

0 commit comments

Comments
 (0)