Beispiel #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();
            }
        }
Beispiel #2
0
        public void Given_NullableSignedNumericValue_ThatIsGreaterThenAMin_AndPositive_WhenCheck_ValueIsGreaterThan_ThenItDoesNotThrow()
        {
            //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.ShouldNotThrow();
            }
        }
Beispiel #3
0
        public void Given_NullableSignedNumericValue_ThatIsNotLessThenAMax_AndPositive_WhenCheck_ValueIsLessThen_ThenItThrowsCorrectException()
        {
            //Arrange
            var actionsList = new List <Action>()
            {
                () =>
                {
                    var numericValue    = SignedNullableNumericFactory.CreateIntWithPositiveValue();
                    var maxNumericValue = numericValue.Value - 31;

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

                () =>
                {
                    var numericValue    = SignedNullableNumericFactory.CreateLongWithPositiveValue();
                    var maxNumericValue = numericValue.Value - 31;

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

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

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

                () =>
                {
                    var numericValue    = SignedNullableNumericFactory.CreateFloatWithPositiveValue();
                    var maxNumericValue = numericValue.Value - 5F;

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

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

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

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

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

            //Act

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