Exemple #1
0
        public void IsEven_ShouldReturnValidResult_ForUInt16()
        {
            // Arrange.
            UInt16 twoHundredFiftySix = 256;
            UInt16 eleven             = 11;
            UInt16 zero  = 0;
            UInt16 one   = 1;
            UInt16 two   = 2;
            UInt16 three = 3;
            UInt16 four  = 4;

            // Act.
            var resultOne   = twoHundredFiftySix.IsEven();
            var resultTwo   = eleven.IsEven();
            var resultThree = zero.IsEven();
            var resultFour  = one.IsEven();
            var resultFive  = two.IsEven();
            var resultSix   = three.IsEven();
            var resultSeven = four.IsEven();

            // Assert.
            resultOne.Should().BeTrue();
            resultTwo.Should().BeFalse();
            resultThree.Should().BeTrue();
            resultFour.Should().BeFalse();
            resultFive.Should().BeTrue();
            resultSix.Should().BeFalse();
            resultSeven.Should().BeTrue();
        }
        public static void RequireArgumentIsOdd(UInt16 valueArgument,
                                                [NotNull] String nameArgument)
        {
            nameArgument.RequireArgumentHasNonWhiteSpaceValue("nameArgument");

            if (valueArgument.IsEven())
            {
                throw new ArgumentOutOfRangeException(nameArgument, valueArgument, String.Format(CultureInfo.InvariantCulture, "{0}.", Resources.ValueMustBeOdd));
            }
        }