Beispiel #1
0
        public void Should_Have_Small_Execution_Time()
        {
            // Arrange.
            int[] bigArray = this.GenerateBigRandomArray();
            PairSumInArrayProblem suject = new PairSumInArrayProblem();

            // Assert.
            suject.ExecutionTimeOf(s => s.HasPairSumInArray(bigArray, 999))
            .Should().BeLessOrEqualTo(TimeSpan.FromSeconds(1000));
        }
Beispiel #2
0
        public void Should_Return_False_If_Array_Is_Null_Or_Empty()
        {
            PairSumInArrayProblem suject = new PairSumInArrayProblem();

            suject.HasPairSumInArray(null, 0).Should().BeFalse();
            suject.HasPairSumInArray(null, 10).Should().BeFalse();

            suject.HasPairSumInArray(new int[] { }, 0).Should().BeFalse();
            suject.HasPairSumInArray(new int[] { }, 10).Should().BeFalse();
        }
Beispiel #3
0
        public void Should_Return_False_If_Pair_Sum_Is_Not_Present()
        {
            // Arrange.
            int[] bigArray = this.GenerateBigRandomArray();
            PairSumInArrayProblem suject = new PairSumInArrayProblem();

            // Assert.
            suject.HasPairSumInArray(new int[] { 0 }, 0).Should().BeFalse();
            suject.HasPairSumInArray(new int[] { 7, 1, 7, 10, 2, 55, 31, 77 }, 15).Should().BeFalse();
            suject.HasPairSumInArray(new int[] { 1, 1, 1, 1, 1, 1, 1, 1 }, 3).Should().BeFalse();
            suject.HasPairSumInArray(bigArray, 999).Should().BeFalse();
        }