我不确定为什么XCTAssertEqualObjects
说这些对象不相等:
[PlayerService_Test testMapping] : ((player) equal to (mappingTest.destinationObject)) failed: ("<PlayerVO: 0x8ec13e0> (entity: PlayerVO; id: 0x8ec1440 <x-coredata:///PlayerVO/t4741C1FA-8A84-4A41-9F2E-9476B1900CFD2> ; data: {
activities = (
);
dob = "1986-08-15 23:00:00 +0000";
firstName = Ahmed;
fullName = nil;
lastName = Ahmed;
middleName = Ahmed;
sex = m;
})") is not equal to ("<PlayerVO: 0x8f09660> (entity: PlayerVO; id: 0x8f57490 <x-coredata:///PlayerVO/t4741C1FA-8A84-4A41-9F2E-9476B1900CFD3> ; data: {
activities = (
);
dob = "1986-08-15 23:00:00 +0000";
firstName = Ahmed;
fullName = nil;
lastName = Ahmed;
middleName = Ahmed;
sex = m;
})")
可能是因为activities
字段吗?是否有另一种方法可以松散地比较两个对象而无需迭代和比较它的属性?
答案 0 :(得分:1)
所以这有效,但它非常讨厌:
XCTAssertEqualObjects([player valueForKey:@"firstName"], [mappingTest.destinationObject valueForKey:@"firstName"]);
XCTAssertEqualObjects([player valueForKey:@"middleName"], [mappingTest.destinationObject valueForKey:@"middleName"]);
XCTAssertEqualObjects([player valueForKey:@"lastName"], [mappingTest.destinationObject valueForKey:@"lastName"]);
XCTAssertEqualObjects([player valueForKey:@"dob"], [mappingTest.destinationObject valueForKey:@"dob"]);
XCTAssertEqualObjects([player valueForKey:@"sex"], [mappingTest.destinationObject valueForKey:@"sex"]);