public void ArgumentValidator_Begin_Returns_Null() { // act var validator = ArgumentValidator.Begin(); // assert validator.Should().NotBeNull(); }
public void ArgumentValidator_AddException_Returns_NonNull_ArgumentValidator() { // act var validator = ArgumentValidator.Begin(); validator = ArgumentValidator.AddException(validator, new Exception("Just testing.")); // assert validator.Should().NotBeNull(); }
public void ArgumentValidator_IsNotNullOrWhitespace_Throws_Error_With_String(string argument) { // arr Action action = () => ArgumentValidator.Begin() .IsNotNullOrWhitespace(argument, nameof(argument)) .Validate(); // act | assert action.Should().Throw <AggregateException>() .WithInnerException <ArgumentException>(); }
public void ArgumentValidator_Validate_Throws_Error() { // arr Action action = () => ArgumentValidator.Begin() .IsNotNull(default(string), @"argument") .Validate(); // act | assert action.Should().Throw <AggregateException>() .WithInnerException <ArgumentNullException>(); }
public void ArgumentValidator_GetExceptions_Returns_Exceptions() { // act var validator = ArgumentValidator.Begin(); validator = ArgumentValidator.AddException(validator, new Exception("Just testing.")); var exceptions = ArgumentValidator.GetArgumentExceptions(validator).ToList(); //doing a .ToList() to avoid multiple enumerations. // assert exceptions.Should().NotBeEmpty(); exceptions.Should().HaveCountGreaterThan(0); exceptions.Single().Should().BeOfType <Exception>(); }
public void ArgumentValidator_MustHaveItems_Throws_Error_With_Empty_Collection() { // arr var collection = Enumerable.Empty <int>(); // act Action action = () => ArgumentValidator.Begin() .MustHaveItems(collection, nameof(collection)) .Validate(); // assert action.Should().Throw <AggregateException>() .WithInnerException <ArgumentException>(); }
public void ArgumentValidator_MustHaveItems_Returns_Null() { // arr var collection = new List <int> { 1, 2, 3 }; // act var validator = ArgumentValidator.Begin() .MustHaveItems(collection, nameof(collection)) .Validate(); // assert var exceptions = ArgumentValidator.GetArgumentExceptions(validator); exceptions.Should().BeEmpty(); }