public void Book_title_cannot_be_null() { var bookWithoutTitle = DefaultBuilder.Create <Book>() .Valid() .With(x => x.Title = null) .Build(); _sut.When() .Validate(bookWithoutTitle) .ThenExpectException <ArgumentException>() .WithParameter(nameof(Book.Title)); }
public void Asserting_incorrect_result_raises_Exception() { var test = DefaultBuilder.Create <TestingClass>() .When() .Invoke(x => 4999); void When() { test.ThenIs(5000); } Assert.ThrowsException <TestFailedException>((Action)When); }
public void Doesnt_stop_exception_from_validate() { BookSerialValidator.When(x => x.Validate(Arg.Any <string>())).Throw <TestingException>(); var book = DefaultBuilder.Create <Book>() .Valid() .Build(); _sut.When() .Validate(book) .ThenExpectException <TestingException>(); }
public void Then_success_fails_if_exception_is_thrown() { var test = DefaultBuilder.Create <TestingClass>() .When() .Invoke(x => throw new Exception()); void When() { test.ThenSuccess(); } Assert.ThrowsException <TestFailedException>((Action)When); }
public void Checking_result_from_action_raises_error() { var test = DefaultBuilder.Create <TestingClass>() .When() .Invoke(x => { }); void When() { test.ThenIs(true); } Assert.ThrowsException <NoResultFromActionException>((Action)When); }
public BookValidatorFacts() { _sut = DefaultBuilder.Create <BookValidator>() .SetArguments(BookSerialValidator); }
public SerialValidationFacts() { _sut = DefaultBuilder.Create <SerialValidator>(); }
public ResultTesterFacts() { _sut = DefaultBuilder.Create <ResultTester>(); }