示例#1
0
        public void Given_NullableSignedNumericValue_ThatIsNegative_WhenCheck_ValueIsPositive_ThenItThrowsCorrectException()
        {
            //Arrange
            var actionsList = new List <Action>()
            {
                () => { SignedNullableNumericFactory.CreateIntWithNegativeValue().Check().ValueIsPositive(); },
                () => { SignedNullableNumericFactory.CreateLongWithNegativeValue().Check().ValueIsPositive(); },
                () => { SignedNullableNumericFactory.CreateDecimalWithNegativeValue().Check().ValueIsPositive(); },
                () => { SignedNullableNumericFactory.CreateFloatWithNegativeValue().Check().ValueIsPositive(); },
                () => { SignedNullableNumericFactory.CreateSbyteWithNegativeValue().Check().ValueIsPositive(); },
                () => { SignedNullableNumericFactory.CreateShortWithNegativeValue().Check().ValueIsPositive(); },
            };

            //Act

            //Assert
            foreach (var action in actionsList)
            {
                action.ShouldThrow <ArgumentOutOfRangeException>();
            }
        }
示例#2
0
        public void Given_NullableSignedNumericValue_ThatIsNotBetweenAMinAndMax_AndNegative_WhenCheck_ValueIsBetween_ThenItThrowsCorrectException()
        {
            //Arrange
            var actionsList = new List <Action>()
            {
                () =>
                {
                    var numericValue    = SignedNullableNumericFactory.CreateIntWithNegativeValue();
                    var minNumericValue = numericValue.Value + 1;
                    var maxNumericValue = numericValue.Value + 10;

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

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

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

                () =>
                {
                    var numericValue    = SignedNullableNumericFactory.CreateDecimalWithNegativeValue();
                    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.CreateSbyteWithNegativeValue();
                    var minNumericValue = (sbyte)(numericValue.Value + 5);
                    var maxNumericValue = (sbyte)(numericValue.Value + 10);

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

                () =>
                {
                    var numericValue    = SignedNullableNumericFactory.CreateShortWithNegativeValue();
                    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.ShouldThrow <ArgumentOutOfRangeException>();
            }
        }
示例#3
0
        public void Given_NullableSignedNumericValue_ThatIsGreaterThenAMin_AndNegative_WhenCheck_ValueIsGreaterThan_ThenItDoesNotThrow()
        {
            //Arrange
            var actionsList = new List <Action>()
            {
                () =>
                {
                    var numericValue    = SignedNullableNumericFactory.CreateIntWithNegativeValue();
                    var minNumericValue = numericValue.Value - 31;

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

                () =>
                {
                    var numericValue    = SignedNullableNumericFactory.CreateLongWithNegativeValue();
                    var minNumericValue = numericValue.Value - 31;

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

                () =>
                {
                    var numericValue    = SignedNullableNumericFactory.CreateDecimalWithNegativeValue();
                    var minNumericValue = numericValue.Value - 5.5m;

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

                () =>
                {
                    var numericValue    = SignedNullableNumericFactory.CreateFloatWithNegativeValue();
                    var minNumericValue = numericValue.Value - 5F;

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

                () =>
                {
                    var numericValue    = SignedNullableNumericFactory.CreateSbyteWithNegativeValue();
                    var minNumericValue = (sbyte)(numericValue.Value - 10);

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

                () =>
                {
                    var numericValue    = SignedNullableNumericFactory.CreateShortWithNegativeValue();
                    var minNumericValue = (short)(numericValue.Value - 10);

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

            //Act

            //Assert
            foreach (var action in actionsList)
            {
                action.ShouldNotThrow();
            }
        }
示例#4
0
        public void Given_NullableSignedNumericValue_ThatIsLessThenAMax_AndNegative_WhenCheck_ValueIsLessThen_ThenItThrowsCorrectException()
        {
            //Arrange
            var actionsList = new List <Action>()
            {
                () =>
                {
                    var numericValue    = SignedNullableNumericFactory.CreateIntWithNegativeValue();
                    var maxNumericValue = numericValue.Value + 31;

                    numericValue
                    .Check()
                    .ValueIsLessThan(maxNumericValue);
                },

                () =>
                {
                    var numericValue    = SignedNullableNumericFactory.CreateLongWithNegativeValue();
                    var maxNumericValue = numericValue.Value + 31;

                    numericValue
                    .Check()
                    .ValueIsLessThan(maxNumericValue);
                },

                () =>
                {
                    var numericValue    = SignedNullableNumericFactory.CreateDecimalWithNegativeValue();
                    var maxNumericValue = numericValue.Value + 5.5m;

                    numericValue
                    .Check()
                    .ValueIsLessThan(maxNumericValue);
                },

                () =>
                {
                    var numericValue    = SignedNullableNumericFactory.CreateFloatWithNegativeValue();
                    var maxNumericValue = numericValue.Value + 5F;

                    numericValue
                    .Check()
                    .ValueIsLessThan(maxNumericValue);
                },

                () =>
                {
                    var numericValue    = SignedNullableNumericFactory.CreateSbyteWithNegativeValue();
                    var maxNumericValue = (sbyte)(numericValue.Value + 10);

                    numericValue
                    .Check()
                    .ValueIsLessThan(maxNumericValue);
                },

                () =>
                {
                    var numericValue    = SignedNullableNumericFactory.CreateShortWithNegativeValue();
                    var maxNumericValue = (short)(numericValue.Value + 10);

                    numericValue
                    .Check()
                    .ValueIsLessThan(maxNumericValue);
                },
            };

            //Act

            //Assert
            foreach (var action in actionsList)
            {
                action.ShouldNotThrow();
            }
        }