Exemplo n.º 1
0
        public void IsOdd_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.IsOdd();
            var resultTwo   = eleven.IsOdd();
            var resultThree = zero.IsOdd();
            var resultFour  = one.IsOdd();
            var resultFive  = two.IsOdd();
            var resultSix   = three.IsOdd();
            var resultSeven = four.IsOdd();

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

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