public void ShouldBeGreaterThanZero_WhenValueIsGreaterThanZero_ReturnsDecimalValidator() { IDecimalValidator sut = CreateSut(); IValidator result = sut.ShouldBeGreaterThanZero(_random.Next(1, 5), GetType(), _fixture.Create <string>()); Assert.That(result, Is.TypeOf <BusinessLogic.Validation.DecimalValidator>()); }
public void ShouldBeGreaterThanZero_WhenValidatingFieldIsWhiteSpace_ThrowsArgumentNullException() { IDecimalValidator sut = CreateSut(); ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.ShouldBeGreaterThanZero(_fixture.Create <decimal>(), GetType(), " ")); Assert.That(result.ParamName, Is.EqualTo("validatingField")); }
public void ShouldBeGreaterThanZero_WhenValidatingTypeIsNull_ThrowsArgumentNullException() { IDecimalValidator sut = CreateSut(); ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.ShouldBeGreaterThanZero(_fixture.Create <decimal>(), null, _fixture.Create <string>())); Assert.That(result.ParamName, Is.EqualTo("validatingType")); }
public void Decimal_WhenCalled_AssertDecimalValidatorFromConstructor() { IValidator sut = CreateSut(); IDecimalValidator decimalValidator = sut.Decimal; Assert.That(decimalValidator, Is.EqualTo(_decimalValidatorMock.Object)); }
public void ShouldBeBetween_WhenValueIsBetweenMinAndMaxValue_ReturnsDecimalValidator() { IDecimalValidator sut = CreateSut(); decimal minValue = _random.Next(1, 100); decimal maxValue = minValue + _random.Next(1, 100); decimal value = _random.Next((int)minValue, (int)maxValue); IValidator result = sut.ShouldBeBetween(value, minValue, maxValue, GetType(), _fixture.Create <string>()); Assert.That(result, Is.TypeOf <BusinessLogic.Validation.DecimalValidator>()); }
public void ShouldBeBetween_WhenValidatingFieldIsWhiteSpace_ThrowsArgumentNullException() { IDecimalValidator sut = CreateSut(); decimal minValue = _random.Next(1, 100); decimal maxValue = minValue + _random.Next(1, 100); decimal value = _random.Next((int)minValue, (int)maxValue); ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.ShouldBeBetween(value, minValue, maxValue, GetType(), " ")); Assert.That(result.ParamName, Is.EqualTo("validatingField")); }
public void ShouldBeBetween_WhenValidatingTypeIsNull_ThrowsArgumentNullException() { IDecimalValidator sut = CreateSut(); decimal minValue = _random.Next(1, 100); decimal maxValue = minValue + _random.Next(1, 100); decimal value = _random.Next((int)minValue, (int)maxValue); ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.ShouldBeBetween(value, minValue, maxValue, null, _fixture.Create <string>())); Assert.That(result.ParamName, Is.EqualTo("validatingType")); }
public void ShouldBeGreaterThanZero_WhenValueIsLowerThanZero_ThrowsIntranetValidationException() { IDecimalValidator sut = CreateSut(); Type validatingType = GetType(); string validatingField = _fixture.Create <string>(); IntranetValidationException result = Assert.Throws <IntranetValidationException>(() => sut.ShouldBeGreaterThanZero(_random.Next(1, 5) * -1, validatingType, validatingField)); Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.ValueNotGreaterThanZero)); Assert.That(result.ValidatingType, Is.EqualTo(validatingType)); Assert.That(result.ValidatingField, Is.EqualTo(validatingField)); }
public void ShouldBeBetween_WhenValueIsGreaterThanMaxValue_ThrowsIntranetValidationException() { IDecimalValidator sut = CreateSut(); decimal minValue = _random.Next(1, 100); decimal maxValue = minValue + _random.Next(1, 100); decimal value = maxValue + _random.Next(1, 10); Type validatingType = GetType(); string validatingField = _fixture.Create <string>(); IntranetValidationException result = Assert.Throws <IntranetValidationException>(() => sut.ShouldBeBetween(value, minValue, maxValue, validatingType, validatingField)); Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.ValueNotBetween)); Assert.That(result.ValidatingType, Is.EqualTo(validatingType)); Assert.That(result.ValidatingField, Is.EqualTo(validatingField)); }
public Validator(IIntegerValidator integerValidator, IDecimalValidator decimalValidator, IStringValidator stringValidator, IDateTimeValidator dateTimeValidator, IObjectValidator objectValidator, IEnumerableValidator enumerableValidator) { NullGuard.NotNull(integerValidator, nameof(integerValidator)) .NotNull(decimalValidator, nameof(decimalValidator)) .NotNull(stringValidator, nameof(stringValidator)) .NotNull(dateTimeValidator, nameof(dateTimeValidator)) .NotNull(objectValidator, nameof(objectValidator)) .NotNull(enumerableValidator, nameof(enumerableValidator)); lock (SyncRoot) { _integerValidator = integerValidator; _decimalValidator = decimalValidator; _stringValidator = stringValidator; _dateTimeValidator = dateTimeValidator; _objectValidator = objectValidator; _enumerableValidator = enumerableValidator; } }