Example #1
0
        public void IsOdd_ShouldReturnValidResult_ForUInt64()
        {
            // Arrange.
            UInt64 twoHundredFiftySix = 256;
            UInt64 eleven             = 11;
            UInt64 zero  = 0;
            UInt64 one   = 1;
            UInt64 two   = 2;
            UInt64 three = 3;
            UInt64 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(UInt64 valueArgument,
                                                 [NotNull] String nameArgument)
        {
            nameArgument.RequireArgumentHasNonWhiteSpaceValue("nameArgument");

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