public void TestThatGetDataQueryerReturnsDataQueryerForDataRepository() { var fixture = new Fixture(); var dataQueryerMock = MockRepository.GenerateMock <IDataQueryer>(); fixture.Customize <IDataQueryer>(e => e.FromFactory(() => dataQueryerMock)); var dataRepositoryMock = MockRepository.GenerateMock <IDataRepository>(); dataRepositoryMock.Expect(m => m.GetDataQueryer()) .Return(dataQueryerMock) .Repeat.Any(); fixture.Customize <IDataRepository>(e => e.FromFactory(() => dataRepositoryMock)); var dataValidator = new MyDataValidator(); Assert.That(dataValidator, Is.Not.Null); using (var dataQueryer = dataValidator.GetDataQueryer(fixture.CreateAnonymous <IDataRepository>())) { Assert.That(dataQueryer, Is.Not.Null); Assert.That(dataQueryer, Is.EqualTo(dataQueryerMock)); dataQueryer.Dispose(); } dataRepositoryMock.AssertWasCalled(m => m.GetDataQueryer()); dataQueryerMock.AssertWasCalled(m => m.Dispose()); }
public void TestThatGetDataQueryerThrowsArgumentNullExceptionIfDataRepositoryIsNull() { var dataValidator = new MyDataValidator(); Assert.That(dataValidator, Is.Not.Null); Assert.Throws <ArgumentNullException>(() => dataValidator.GetDataQueryer(null)); }
public void TestThatGetDataQueryerThrowsDeliveryEngineSystemExceptionIfGetDataQueryerInDataRepositoryThrowsException() { var fixture = new Fixture(); var dataRepositoryMock = MockRepository.GenerateMock <IDataRepository>(); dataRepositoryMock.Expect(m => m.GetDataQueryer()) .Throw(fixture.CreateAnonymous <Exception>()) .Repeat.Any(); fixture.Customize <IDataRepository>(e => e.FromFactory(() => dataRepositoryMock)); var dataValidator = new MyDataValidator(); Assert.That(dataValidator, Is.Not.Null); Assert.Throws <DeliveryEngineSystemException>(() => dataValidator.GetDataQueryer(fixture.CreateAnonymous <IDataRepository>())); dataRepositoryMock.AssertWasCalled(m => m.GetDataQueryer()); }