Exemplo n.º 1
0
        public void Given_NullableSignedNumericValue_ThatIsPositive_WhenCheck_ValueIsPositive_ThenItDoesNotThrow()
        {
            //Arrange
            var actionsList = new List <Action>()
            {
                () => { SignedNullableNumericFactory.CreateIntWithPositiveValue().Check().ValueIsPositive(); },
                () => { SignedNullableNumericFactory.CreateLongWithPositiveValue().Check().ValueIsPositive(); },
                () => { SignedNullableNumericFactory.CreateDecimalWithPositiveValue().Check().ValueIsPositive(); },
                () => { SignedNullableNumericFactory.CreateFloatWithPositiveValue().Check().ValueIsPositive(); },
                () => { SignedNullableNumericFactory.CreateSbyteWithPositiveValue().Check().ValueIsPositive(); },
                () => { SignedNullableNumericFactory.CreateShortWithPositiveValue().Check().ValueIsPositive(); },
            };

            //Act

            //Assert
            foreach (var action in actionsList)
            {
                action.ShouldNotThrow();
            }
        }
Exemplo n.º 2
0
        public void Given_NullableSignedNumericValue_ThatIsBetweenAMinAndMax_AndPositive_WhenCheck_ValueIsBetween_ThenItDoesNotThrow()
        {
            //Arrange
            var actionsList = new List <Action>()
            {
                () =>
                {
                    var numericValue    = SignedNullableNumericFactory.CreateIntWithPositiveValue();
                    var minNumericValue = numericValue.Value - 1;
                    var maxNumericValue = numericValue.Value + 10;

                    numericValue
                    .Check()
                    .ValueIsBetween(minNumericValue, maxNumericValue);
                },

                () =>
                {
                    var numericValue    = SignedNullableNumericFactory.CreateLongWithPositiveValue();
                    var minNumericValue = numericValue.Value - 1;
                    var maxNumericValue = numericValue.Value + 10;

                    numericValue
                    .Check()
                    .ValueIsBetween(minNumericValue, maxNumericValue);
                },

                () =>
                {
                    var numericValue    = SignedNullableNumericFactory.CreateDecimalWithPositiveValue();
                    var minNumericValue = numericValue.Value - 5.5m;
                    var maxNumericValue = numericValue.Value + 10m;

                    numericValue
                    .Check()
                    .ValueIsBetween(minNumericValue, maxNumericValue);
                },

                () =>
                {
                    var numericValue    = SignedNullableNumericFactory.CreateFloatWithNegativeValue();
                    var minNumericValue = numericValue.Value - 3F;
                    var maxNumericValue = numericValue.Value + 10F;

                    numericValue
                    .Check()
                    .ValueIsBetween(minNumericValue, maxNumericValue);
                },

                () =>
                {
                    var numericValue    = SignedNullableNumericFactory.CreateSbyteWithPositiveValue();
                    var minNumericValue = (sbyte)(numericValue.Value - 5);
                    var maxNumericValue = (sbyte)(numericValue.Value + 10);

                    numericValue
                    .Check()
                    .ValueIsBetween(minNumericValue, maxNumericValue);
                },

                () =>
                {
                    var numericValue    = SignedNullableNumericFactory.CreateShortWithPositiveValue();
                    var minNumericValue = (short)(numericValue.Value - 5);
                    var maxNumericValue = (short)(numericValue.Value + 10);

                    numericValue
                    .Check()
                    .ValueIsBetween(minNumericValue, maxNumericValue);
                },
            };

            //Act

            //Assert
            foreach (var action in actionsList)
            {
                action.ShouldNotThrow();
            }
        }
Exemplo n.º 3
0
        public void Given_NullableSignedNumericValue_ThatIsNotGreaterThenAMin_AndPositive_WhenCheck_ValueIsGreaterThan_ThenItThrowsCorrectException()
        {
            //Arrange
            var actionsList = new List <Action>()
            {
                () =>
                {
                    var numericValue    = SignedNullableNumericFactory.CreateIntWithPositiveValue();
                    var minNumericValue = numericValue.Value + 31;

                    numericValue
                    .Check()
                    .ValueIsGreaterThan(minNumericValue);
                },

                () =>
                {
                    var numericValue    = SignedNullableNumericFactory.CreateLongWithPositiveValue();
                    var minNumericValue = numericValue.Value + 31;

                    numericValue
                    .Check()
                    .ValueIsGreaterThan(minNumericValue);
                },

                () =>
                {
                    var numericValue    = SignedNullableNumericFactory.CreateDecimalWithPositiveValue();
                    var minNumericValue = numericValue.Value + 5.5m;

                    numericValue
                    .Check()
                    .ValueIsGreaterThan(minNumericValue);
                },

                () =>
                {
                    var numericValue    = SignedNullableNumericFactory.CreateFloatWithPositiveValue();
                    var minNumericValue = numericValue.Value + 5F;

                    numericValue
                    .Check()
                    .ValueIsGreaterThan(minNumericValue);
                },

                () =>
                {
                    var numericValue    = SignedNullableNumericFactory.CreateSbyteWithPositiveValue();
                    var minNumericValue = (sbyte)(numericValue.Value + 10);

                    numericValue
                    .Check()
                    .ValueIsGreaterThan(minNumericValue);
                },

                () =>
                {
                    var numericValue    = SignedNullableNumericFactory.CreateShortWithPositiveValue();
                    var minNumericValue = (short)(numericValue.Value + 10);

                    numericValue
                    .Check()
                    .ValueIsGreaterThan(minNumericValue);
                },
            };

            //Act

            //Assert
            foreach (var action in actionsList)
            {
                action.ShouldThrow <ArgumentOutOfRangeException>();
            }
        }