Beispiel #1
0
        public void GetSubsetWithNearValue_ReturnsNothing_ForEmptyArray()
        {
            var array = new int[] { };

            TestHelper.AssertSequence(
                Set.GetSubsetWithNearValue(array, 1));
        }
Beispiel #2
0
        public void GetSubsetWithNearValue_ReturnsNothing_WhenSumCannotBeCompleted()
        {
            var array = new[] { 2, 3, 4 };

            TestHelper.AssertSequence(
                Set.GetSubsetWithNearValue(array, 1));
        }
Beispiel #3
0
        public void GetSubsetWithNearValue_ReturnsTen_ForASumOfEleven_ExcludingFive()
        {
            var array = new[] { 5, 10 };

            TestHelper.AssertSequence(
                Set.GetSubsetWithNearValue(array, 11),
                10);
        }
Beispiel #4
0
        public void GetSubsetWithNearValue_ReturnsOneTwoThree_ForASumOfTen()
        {
            var array = new[] { 1, 2, 3 };

            TestHelper.AssertSequence(
                Set.GetSubsetWithNearValue(array, 10),
                3, 2, 1);
        }
Beispiel #5
0
        public void GetSubsetWithNearValue_ReturnsOneAndTwo_ForASumOfThree()
        {
            var array = new[] { 1, 2, 3, 4, 5 };

            TestHelper.AssertSequence(
                Set.GetSubsetWithNearValue(array, 3),
                2, 1);
        }
Beispiel #6
0
        public void GetSubsetWithNearValue_ReturnsOne_WhenSkippingZeroes()
        {
            var array = new[] { 0, 0, 1 };

            TestHelper.AssertSequence(
                Set.GetSubsetWithNearValue(array, 1),
                1);
        }
Beispiel #7
0
        public void GetSubsetWithNearValue_ReturnsOne_ForPerfectMatchingSumOfOne()
        {
            var array = new[] { 1 };

            TestHelper.AssertSequence(
                Set.GetSubsetWithNearValue(array, 1),
                1);
        }
Beispiel #8
0
        public void GetSubsetWithNearValue_ReturnsTwo_ForPerfectFullyCompletedSumOfTwo()
        {
            var array = new[] { 1, 2 };

            TestHelper.AssertSequence(
                Set.GetSubsetWithNearValue(array, 2),
                2);
        }
Beispiel #9
0
        public void GetSubsetWithNearValue_ReturnsTenOne_ForASumOfEleven_ExcludingOneTwoThree()
        {
            var array = new[] { 1, 2, 3, 10 };

            TestHelper.AssertSequence(
                Set.GetSubsetWithNearValue(array, 11),
                10, 1);
        }
Beispiel #10
0
 public void GetSubsetWithNearValue_ThrowsException_ForZeroTargetSum()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() =>
                                                 Set.GetSubsetWithNearValue(new int[] { }, 0));
 }
Beispiel #11
0
 public void GetSubsetWithNearValue_ThrowsException_ForNullSequence()
 {
     Assert.Throws <ArgumentNullException>(() =>
                                           Set.GetSubsetWithNearValue(null, 1));
 }
Beispiel #12
0
 public void GetSubsetWithNearValue_ThrowsException_ForNegativeNumberInSequence()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() =>
                                                 Set.GetSubsetWithNearValue(new[] { -1 }, 1));
 }