public void Should_return_true_if_searching_for_a_() { IIdentityMap <IDomainObject> map = CreateSUT( ); int id = 1; map.Add(new DomainObject(id)); Assert.IsTrue(map.ContainsObjectWithIdOf(id)); Assert.IsFalse(map.ContainsObjectWithIdOf(2)); }
public void Should_be_able_to_add_a_new_domain_object_to_the_identitiy_map() { IDomainObject objectThatHasBeenAddedToMap = new DomainObject(1); IDomainObject objectThatHasNotBeenAddedToMap = new DomainObject(2); IIdentityMap <IDomainObject> map = CreateSUT( ); map.Add(objectThatHasBeenAddedToMap); Assert.IsTrue(map.ContainsObjectWithIdOf(objectThatHasBeenAddedToMap.ID( ))); Assert.IsFalse(map.ContainsObjectWithIdOf(objectThatHasNotBeenAddedToMap.ID( ))); }
public void Should_check_identity_map_to_see_if_customer_is_loaded() { ICustomer customer = _mockery.DynamicMock <ICustomer>( ); long customerId = 23455; using (_mockery.Record( )) { Expect.Call(_mockIdentityMap.ContainsObjectWithIdOf(customerId)).Return(true); Expect.Call(_mockIdentityMap.FindObjectWithIdOf(customerId)).Return(customer); } using (_mockery.Playback( )) { Assert.AreEqual(customer, CreateSUT( ).FindBy(customerId)); } }
public void Should_leverage_mapper_to_update_customer() { ICustomer customer = _mockery.DynamicMock <ICustomer>( ); IIdentityMap <ICustomer> identityMap = _mockery.CreateMock <IIdentityMap <ICustomer> >( ); ICustomerDataMapper dataMapper = _mockery.CreateMock <ICustomerDataMapper>( ); long customerId = 46; using (_mockery.Record( )) { SetupResult.For(customer.ID( )).Return(customerId); SetupResult.For(identityMap.ContainsObjectWithIdOf(customerId)).Return(true); dataMapper.Update(customer); } using (_mockery.Playback( )) { CreateSUT(identityMap, dataMapper).Save(customer); } }