Beispiel #1
0
 public void DeconstructIntoPowersOfTwo_Two_ReturnsTwo()
 {
     TestHelper.AssertSequence(
         Integer.DeconstructIntoPowersOfTwo(2),
         2);
 }
Beispiel #2
0
 public void Break_ThrowsException_IfNumberIsNegative()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => Integer.Break(-1, 1));
 }
Beispiel #3
0
 public void DeconstructIntoPowersOfTwo_Four_ReturnsMinusFour()
 {
     TestHelper.AssertSequence(
         Integer.DeconstructIntoPowersOfTwo(-4),
         -4);
 }
Beispiel #4
0
 public void DeconstructIntoPowersOfTwo_One_ReturnsOne()
 {
     TestHelper.AssertSequence(
         Integer.DeconstructIntoPowersOfTwo(1),
         1);
 }
Beispiel #5
0
        public void Zip_ReturnsCorrectResult_IntBase16(int x, int y, int expected)
        {
            var result = Integer.Zip(x, y, 16);

            Assert.AreEqual(expected, result);
        }
Beispiel #6
0
 public void Zip_ThrowsException_ForNegativeY()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() =>
                                                 Integer.Zip(1, -1, 2));
 }
Beispiel #7
0
        public void Break_ReturnsProperResult_ForSimpleCase_5()
        {
            var result = Integer.Break(10, 4, 1);

            TestHelper.AssertSequence(result, (4, 2), (1, 2));
        }
 public void DeconstructIntoPrimeFactors_Twenty_ReturnsTwoTwoFive()
 {
     TestHelper.AssertSequence(
         Integer.DeconstructIntoPrimeFactors(20),
         2, 2, 5);
 }
Beispiel #9
0
        public void Break_ReturnsNothingIfNumberIsZero()
        {
            var result = Integer.Break(0, 1);

            TestHelper.AssertSequence(result);
        }
Beispiel #10
0
        public void Break_ReturnsProperResult_ForSimpleCase_4()
        {
            var result = Integer.Break(2, 2, 1);

            TestHelper.AssertSequence(result, (2, 1));
        }
Beispiel #11
0
        public void Break_ReturnsNothingIfComponentsIsEmpty()
        {
            var result = Integer.Break(1);

            TestHelper.AssertSequence(result);
        }
Beispiel #12
0
        public void Break_ReturnsNothingIfComponentCannotBeBroken()
        {
            var result = Integer.Break(9, 5);

            TestHelper.AssertSequence(result);
        }
Beispiel #13
0
 public void Break_ThrowsException_IfOneOfComponentsIsLessThanOne()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => Integer.Break(10, 0));
 }
 public void DeconstructIntoPrimeFactors_One_ReturnsOne()
 {
     TestHelper.AssertSequence(
         Integer.DeconstructIntoPrimeFactors(1),
         1);
 }
Beispiel #15
0
        public void Break_ReturnsProperResult_ForSimpleCase_6()
        {
            var result = Integer.Break(20, 7, 8, 6);

            TestHelper.AssertSequence(result, (7, 2), (6, 1));
        }
 public void DeconstructIntoPrimeFactors_Three_ReturnsThree()
 {
     TestHelper.AssertSequence(
         Integer.DeconstructIntoPrimeFactors(3),
         3);
 }
Beispiel #17
0
        public void Break_ReturnsProperResult_ForSimpleCase_7()
        {
            var result = Integer.Break(1000, 7, 5, 3, 2, 1);

            TestHelper.AssertSequence(result, (7, 142), (5, 1), (1, 1));
        }
Beispiel #18
0
        public void IsPrime_ReturnsFalse(int number)
        {
            var result = Integer.IsPrime(number);

            Assert.IsFalse(result);
        }
 public void DeconstructIntoPrimeFactors_Zero_ReturnsZero()
 {
     TestHelper.AssertSequence(
         Integer.DeconstructIntoPrimeFactors(0),
         0);
 }
Beispiel #20
0
 public void Zip_ThrowsException_ForBaseOne()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() =>
                                                 Integer.Zip(1, 1, 1));
 }
        public void DeconstructIntoPrimeFactors__MultipliesToOriginal(int number)
        {
            var mul = Integer.DeconstructIntoPrimeFactors(number).Aggregate((x, y) => x * y);

            Assert.AreEqual(number, mul);
        }
Beispiel #22
0
        public void DeconstructIntoPowersOfTwo__SumsToOriginal(int number)
        {
            var backSum = Integer.DeconstructIntoPowersOfTwo(number).Sum();

            Assert.AreEqual(number, backSum);
        }
 public void DeconstructIntoPrimeFactors_Four_ReturnsTwoTwo()
 {
     TestHelper.AssertSequence(
         Integer.DeconstructIntoPrimeFactors(4),
         2, 2);
 }
Beispiel #24
0
 public void DeconstructIntoPowersOfTwo_MinusThree_ReturnsMinusOneThenMinusTwo()
 {
     TestHelper.AssertSequence(
         Integer.DeconstructIntoPowersOfTwo(-3),
         -1, -2);
 }
 public void DeconstructIntoPrimeFactors_MinusFour_ReturnsMinusOneMinusTwoMinusTwo()
 {
     TestHelper.AssertSequence(
         Integer.DeconstructIntoPrimeFactors(-4),
         -2, -2, -1);
 }
Beispiel #26
0
 public void DeconstructIntoPowersOfTwo_Three_ReturnsOneThenTwo()
 {
     TestHelper.AssertSequence(
         Integer.DeconstructIntoPowersOfTwo(3),
         1, 2);
 }
 public void DeconstructIntoPrimeFactors_MinusTwo_ReturnsMinusTwo()
 {
     TestHelper.AssertSequence(
         Integer.DeconstructIntoPrimeFactors(-2),
         -2);
 }
Beispiel #28
0
 public void DeconstructIntoPowersOfTwo_Zero_ReturnsNothing()
 {
     TestHelper.AssertSequence(
         Integer.DeconstructIntoPowersOfTwo(0));
 }
Beispiel #29
0
 public void Break_ThrowsException_IfComponentArrayIsNull()
 {
     Assert.Throws <ArgumentNullException>(() => Integer.Break(1, null));
 }