public void Constructor_Must_ThrowExceptions() { // Arrange var fixture = new FindHandlerFixtures(FindHandlerFixtures.TestTypeEnum.Ok); Action sut1 = () => new FindHandlerFixtures.FindHandlerMock( null, fixture.Mapper.Object); Action sut2 = () => new FindHandlerFixtures.FindHandlerMock( fixture.ReadOnlyRepository.Object, null); // Act // Assert Assert.Throws <ArgumentNullException>(sut1); Assert.Throws <ArgumentNullException>(sut2); }
public async void Handler_Must_ThrowException(FindHandlerFixtures.TestTypeEnum testType, Type typeException) { // Arrange var fixture = new FindHandlerFixtures(testType); var query = fixture.Query; var sut = new FindHandlerFixtures.FindHandlerMock( fixture.ReadOnlyRepository.Object, fixture.Mapper.Object); // Act Exception ex = await Assert.ThrowsAnyAsync <Exception>(async() => await sut.Handle(query, default)); // Assert Assert.Equal(typeException, ex.GetType()); fixture.ReadOnlyRepository.VerifyAll(); fixture.ReadOnlyRepository.VerifyNoOtherCalls(); }
public async void Handler_MustReturn_Result() { // Arrange var fixture = new FindHandlerFixtures(FindHandlerFixtures.TestTypeEnum.Ok); var query = fixture.Query; var sut = new FindHandlerFixtures.FindHandlerMock( fixture.ReadOnlyRepository.Object, fixture.Mapper.Object); // Act var computed = await sut.Handle(query, default); // Assert Assert.NotNull(computed); Assert.Equal(fixture.QueryResult, computed); fixture.ReadOnlyRepository.VerifyAll(); fixture.ReadOnlyRepository.VerifyNoOtherCalls(); }