Skip to content
Permalink
Browse files

Adding test for Sigmapoint-null-relationship

  • Loading branch information...
Coeur committed Jun 22, 2019
1 parent ad79e25 commit 983c0d4c7a1ab33176917fca8096122c60bc45da
@@ -40,4 +40,23 @@ - (void)testImportData
}];
}

- (void)testImportNilData
{
SingleEntityRelatedToManyMappedEntitiesUsingMappedPrimaryKey *entity = [[self testEntityClass] MR_importFromObject:self.testEntityData inContext:[NSManagedObjectContext MR_defaultContext]];

XCTAssertNotNil(entity, @"Entity should not be nil");

[entity.managedObjectContext performBlockAndWait:^{
// testing that importing nothing will not change the relationship
[entity MR_importValuesForKeysWithObject:@{}];
NSUInteger mappedEntitiesCount = entity.mappedEntities.count;
XCTAssertEqual(mappedEntitiesCount, (NSUInteger)4, @"Expected 4 mapped entities, received %zd", mappedEntitiesCount);

// testing that importing `null` will nullify the relationship
[entity MR_importValuesForKeysWithObject:@{@"mappedEntities":[NSNull null]}];
mappedEntitiesCount = entity.mappedEntities.count;
XCTAssertEqual(mappedEntitiesCount, (NSUInteger)0, @"Expected 0 mapped entities, received %zd", mappedEntitiesCount);
}];
}

@end

0 comments on commit 983c0d4

Please sign in to comment.
You can’t perform that action at this time.