public void MapSetsIsNewToTrueWhenGivenDomainObjectIdIs0() { const int id = 0; var domainObject = new FakeDomainObject(id); FakeEntity entity = _mapper.Map(domainObject); Assert.IsTrue(entity.IsNew, "IsNew set to false when given ID was 0."); }
public void MapSetsIsNewToFalseWhenGivenDomainObjectIdIsNot0() { const int id = 3; var domainObject = new FakeDomainObject(id); FakeEntity entity = _mapper.Map(domainObject); Assert.IsFalse(entity.IsNew, "IsNew set to true when given ID was not 0."); }
public void DeletionTest(bool wasDeletionSuccessful) { var entityToDelete = new FakeEntity(); var domainObjectToDelete = new FakeDomainObject(); ExpectGetDataAccessAdapterAndDispose(); Expect.Call(_mapper.Map(domainObjectToDelete)).Return(entityToDelete); ExpectDeleteEntity(wasDeletionSuccessful); _mocks.ReplayAll(); _repository.Delete(domainObjectToDelete); _mocks.VerifyAll(); }
public void MapMultipleReturnsSameEntityObjectAsMapDoes() { var domainObjectToMap = new FakeDomainObject { Id = 5 }; long expectedId = _mapper.Map(domainObjectToMap).Id; IEnumerable <FakeDomainObject> domainObjects = new List <FakeDomainObject> { domainObjectToMap }; IEnumerable <FakeEntity> entities = _mapper.MapMultiple(domainObjects); Assert.AreEqual(expectedId, entities.Single().Id, "The entity returned did not have its fields mapped correctly."); }
public void SaveThrowsExceptionWhenObjectFailsToGetPersisted() { const bool entitySavedSuccessfully = false; const bool refetchAfterSaveParameter = true; var fakeDomainObject = new FakeDomainObject(); ExpectGetDataAccessAdapterAndDispose(); ExpectSaveEntity(entitySavedSuccessfully, refetchAfterSaveParameter); Expect.Call(() => _fakePrePersistenceStrategy.ApplyStrategy(fakeDomainObject)); Expect.Call(_mockedMapper.Map(fakeDomainObject)).Return(new FakeEntity()); _mocks.ReplayAll(); _uniqueItemRepository.Save(fakeDomainObject); _mocks.VerifyAll(); }