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_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 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_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)); }