Exemple #1
0
        public void Given_NullableSignedNumericValue_ThatIsNotLessThenAMax_AndPositive_WhenCheck_ValueIsLessThen_ThenItThrowsCorrectException()
        {
            //Arrange
            var actionsList = new List <Action>()
            {
                () =>
                {
                    var numericValue    = UnsignedNullableNumericFactory.CreateUIntWithValue();
                    var maxNumericValue = numericValue.Value - 31;

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

                () =>
                {
                    var numericValue    = UnsignedNullableNumericFactory.CreateULongWithValue();
                    var maxNumericValue = numericValue.Value - 31;

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

                () =>
                {
                    var numericValue    = UnsignedNullableNumericFactory.CreateByteWithValue();
                    var maxNumericValue = (byte)(numericValue.Value - 10);

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

                () =>
                {
                    var numericValue    = UnsignedNullableNumericFactory.CreateUShortWithValue();
                    var maxNumericValue = (ushort)(numericValue.Value - 233);

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

            //Act

            //Assert
            foreach (var action in actionsList)
            {
                action.ShouldThrow <ArgumentOutOfRangeException>();
            }
        }
Exemple #2
0
        public void Given_NullableSignedNumericValue_ThatHasValue_WhenCheck_HasValue_ThenItDoesNotThrow()
        {
            //Arrange
            var actionsList = new List <Action>()
            {
                () => { UnsignedNullableNumericFactory.CreateUIntWithValue().Check().HasValue(); },
                () => { UnsignedNullableNumericFactory.CreateULongWithValue().Check().HasValue(); },
                () => { UnsignedNullableNumericFactory.CreateByteWithValue().Check().HasValue(); },
                () => { UnsignedNullableNumericFactory.CreateUShortWithValue().Check().HasValue(); },
            };

            //Act

            //Assert
            foreach (var action in actionsList)
            {
                action.ShouldNotThrow();
            }
        }
Exemple #3
0
        public void Given_NullableSignedNumericValue_ThatIsNull_WhenCheck_HasValue_ThenItThrowsCorrectException()
        {
            //Arrange
            var actionsList = new List <Action>()
            {
                () => { UnsignedNullableNumericFactory.CreateUIntWithNull().Check().HasValue(); },
                () => { UnsignedNullableNumericFactory.CreateULongWithNull().Check().HasValue(); },
                () => { UnsignedNullableNumericFactory.CreateByteWithNull().Check().HasValue(); },
                () => { UnsignedNullableNumericFactory.CreateUShortWithNull().Check().HasValue(); },
            };

            //Act

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