예제 #1
0
        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>());
        }
예제 #2
0
        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"));
        }
예제 #3
0
        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"));
        }
예제 #4
0
        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));
        }