public void Contains_entity2_empty_collection() { MockEntity entity = new MockEntity() { id = int.MinValue }; DualDbEntityAssociativeCollectionManager <MockEntityOne, MockEntityTwo, MockEntity> manager = new DualDbEntityAssociativeCollectionManager <MockEntityOne, MockEntityTwo, MockEntity>(1, entity, () => entity.RelationalEntities, null, null, null, (o, ae) => true, (e1, ae) => true, (e2, ae) => true); Assert.IsFalse(manager.Contains(new MockEntityTwo())); }
public void Contains_entity2_false() { MockEntity entity = new MockEntity() { id = int.MinValue }; Func <IDbEntity, MockEntity, bool> matchesAssociativeEntityOwner = (o, ae) => false; Func <MockEntityOne, MockEntity, bool> matchesEntity1 = (e1, ae) => false; Func <MockEntityTwo, MockEntity, bool> matchesEntity2 = (e2, ae) => false; DualDbEntityAssociativeCollectionManager <MockEntityOne, MockEntityTwo, MockEntity> manager = new DualDbEntityAssociativeCollectionManager <MockEntityOne, MockEntityTwo, MockEntity>(1, entity, () => entity.RelationalEntities, null, null, null, matchesAssociativeEntityOwner, matchesEntity1, matchesEntity2); entity.RelationalEntities.Add(new MockEntity()); Assert.IsFalse(manager.Contains(new MockEntityTwo())); }
public void Contains_deleted_entity() { MockEntity entity = new MockEntity() { id = int.MinValue }; DualDbEntityAssociativeCollectionManager <MockEntity, MockEntity, MockEntity> manager = new DualDbEntityAssociativeCollectionManager <MockEntity, MockEntity, MockEntity>(1, entity, () => entity.RelationalEntities, null, null, null, (o, ae) => true, (e1, ae) => true, (e2, ae) => true); entity.RelationalEntities.Add(new MockEntity() { IsDeleted = true }); Assert.IsFalse(manager.Contains(new MockEntity(), new MockEntity())); }
public void Contains_true() { MockEntity entity = new MockEntity() { id = int.MinValue }; bool isAssociativeEntityOwnerMatched = false; bool isEntity1Matched = false; bool isEntity2Matched = false; Func <IDbEntity, MockEntity, bool> matchesAssociativeEntityOwner = (o, ae) => { return(isAssociativeEntityOwnerMatched = true); }; Func <MockEntity, MockEntity, bool> matchesEntity1 = (e1, ae) => { return(isEntity1Matched = true); }; Func <MockEntity, MockEntity, bool> matchesEntity2 = (e2, ae) => { return(isEntity2Matched = true); }; DualDbEntityAssociativeCollectionManager <MockEntity, MockEntity, MockEntity> manager = new DualDbEntityAssociativeCollectionManager <MockEntity, MockEntity, MockEntity>(1, entity, () => entity.RelationalEntities, null, null, null, matchesAssociativeEntityOwner, matchesEntity1, matchesEntity2); entity.RelationalEntities.Add(new MockEntity()); Assert.IsTrue(manager.Contains(new MockEntity(), new MockEntity())); Assert.IsTrue(isAssociativeEntityOwnerMatched); Assert.IsTrue(isEntity1Matched); Assert.IsTrue(isEntity2Matched); }