public void It_should_not_call_validator() { // Act _sut.GetValidationResult(null, _validationContext); // Assert IbanValidatorMock.Verify(m => m.Validate(TestValues.ValidIban), Times.Never); }
public void It_should_call_validator() { // Act _sut.GetValidationResult(TestValues.InvalidIban, _validationContext); // Assert IbanValidatorMock.Verify(m => m.Validate(TestValues.InvalidIban), Times.Once); }
public void It_should_call_validator() { // Act _sut.Validate(_propertyValidatorContext); // Assert IbanValidatorMock.Verify(m => m.Validate(AttemptedIbanValue), Times.Once); }
public void It_should_not_call_validator() { // Act _sut.Validate(_propertyValidatorContext); // Assert IbanValidatorMock.Verify(m => m.Validate(It.IsAny <string>()), Times.Never); }
public void It_should_throw() { // Act Action act = () => _sut.Validate(_propertyValidatorContext); // Assert act.Should().Throw <InvalidCastException>(); IbanValidatorMock.Verify(m => m.Validate(It.IsAny <string>()), Times.Never); }
public void With_invalid_value_should_return_false() { // Act bool actual = Iban.TryParse(TestValues.InvalidIban, out Iban iban); // Assert actual.Should().BeFalse("the provided value was invalid"); iban.Should().BeNull("parsing did not succeed"); IbanValidatorMock.Verify(m => m.Validate(It.IsAny <string>()), Times.Once); }
public void It_should_throw() { // Act Action act = () => _sut.GetValidationResult(InvalidTypeValue, _validationContext); // Assert act.Should().Throw <NotImplementedException>(); _serviceProviderMock.Verify(m => m.GetService(It.IsAny <Type>()), Times.Never); IbanValidatorMock.Verify(m => m.Validate(TestValues.InvalidIban), Times.Never); }
public void It_should_throw() { // Arrange _validationContext = new ValidationContext(new object(), null, null); // Act Action act = () => _sut.GetValidationResult(TestValues.ValidIban, _validationContext); // Assert act.Should() .Throw <InvalidOperationException>() .WithMessage("Failed to get an instance of *"); IbanValidatorMock.Verify(m => m.Validate(TestValues.ValidIban), Times.Never); }
public void With_valid_value_should_pass() { // Act var actual = Iban.TryParse(TestValues.ValidIban, out var iban); // Assert actual.Should().BeTrue("the provided value was valid"); iban.Should().NotBeNull(). And.BeOfType <Iban>() .Which.ToString() .Should().Be(TestValues.ValidIban); IbanValidatorMock.Verify(m => m.Validate(It.IsAny <string>()), Times.Once); }
public void It_should_use_default_validator() { // Arrange _serviceProviderMock .Setup(m => m.GetService(typeof(IIbanValidator))) .Returns(null) .Verifiable(); // Act _sut.GetValidationResult(TestValues.ValidIban, _validationContext); // Assert _serviceProviderMock.Verify(); IbanValidatorMock.Verify(m => m.Validate(TestValues.ValidIban), Times.Once); }
public void It_should_throw() { // Arrange _serviceProviderMock.Reset(); Iban.Validator = null; // Act Action act = () => _sut.GetValidationResult(TestValues.ValidIban, _validationContext); // Assert act.Should().Throw <InvalidOperationException>(); _serviceProviderMock.Verify(m => m.GetService(It.IsAny <Type>()), Times.Once); IbanValidatorMock.Verify(m => m.Validate(TestValues.InvalidIban), Times.Never); }
public void It_should_throw() { // Arrange _serviceProviderMock .Setup(m => m.GetService(typeof(IIbanValidator))) .Returns(null) .Verifiable(); // Act Action act = () => _sut.GetValidationResult(TestValues.ValidIban, _validationContext); // Assert act.Should() .Throw <InvalidOperationException>() .WithMessage("Failed to get an instance of *"); _serviceProviderMock.Verify(); IbanValidatorMock.Verify(m => m.Validate(TestValues.ValidIban), Times.Never); }