示例#1
0
        public void OnlyTwoLinesReturnsArea()
        {
            var container = new ContainerWithMostWater();
            var lines     = new[] { 1, 3 };

            Assert.Equal(1, container.MaxArea(lines));
        }
示例#2
0
        public void NotEnoughLinesReturnsNegativeOne()
        {
            var container = new ContainerWithMostWater();
            var lines     = new[] { 1 };

            Assert.Equal(-1, container.MaxArea(lines));
        }
        public void MaxArea(int[] height, int expected)
        {
            var sut    = new ContainerWithMostWater();
            var actual = sut.MaxArea(height);

            Assert.AreEqual(expected, actual);
        }
示例#4
0
        public void MaxArea_GivenAnIntArray_ReturnMaxArea(int[] array, int expectedResult)
        {
            var cwmw   = new ContainerWithMostWater();
            var result = cwmw.MaxArea(array);

            result.Should().Be(expectedResult);
        }
示例#5
0
        public void Test_ContainerWithMostWater()

        {
            int[] input  = { 1, 2, 4, 3 };
            int   result = ContainerWithMostWater.MaxArea(input);

            Assert.AreEqual(result, 4);
        }
示例#6
0
        public void SampleInputShouldReturn49()
        {
            var sw = new Stopwatch();

            var container = new ContainerWithMostWater();

            var lines = new[] { 1, 8, 6, 2, 5, 4, 8, 3, 7 };

            Assert.Equal(49, container.MaxArea(lines));
        }
        public void Given_213_Then_4()
        {
            // Arrange
            var algo = new ContainerWithMostWater();

            // Action
            var actual = algo.MaxArea(new int[] { 2, 1, 3 });

            // Assert
            Assert.AreEqual(4, actual);
        }
        public void Given_186254837_Then_49()
        {
            // Arrange
            var algo = new ContainerWithMostWater();

            // Action
            var actual = algo.MaxArea(new int[] { 1, 8, 6, 2, 5, 4, 8, 3, 7 });

            // Assert
            Assert.AreEqual(49, actual);
        }
示例#9
0
        public void Test_MaxArea()
        {
            var testCases = new int[][]
            {
                new int[] { 1, 8, 6, 2, 5, 4, 8, 3, 7 },
            };

            var expected = new int[] { 49 };
            var actual   = _objUnderTest.MaxArea(testCases[0]);

            Assert.Equal(expected[0], actual);
        }
示例#10
0
        public void MaxArea_ShouldReturn_MaximumAreaBetweenTwoLines(
            int[] heights,
            int expectedMaximumArea)
        {
            // Arrange
            var container = new ContainerWithMostWater();

            // Act
            var maximumArea = container.MaxArea(heights);

            // Assert
            maximumArea.Should().Be(expectedMaximumArea);
        }
        public void When_single_p_Then_hight()
        {
            var hight = new int[] { 5 };

            Assert.AreEqual(0, ContainerWithMostWater.MaxArea(hight));
        }
        public void When_three_p_Then_max()
        {
            var hight = new int[] { 2, 5, 6 };

            Assert.AreEqual(5, ContainerWithMostWater.MaxArea(hight));
        }
        public void When_two_p_Then_small_2()
        {
            var hight = new int[] { 5, 6 };

            Assert.AreEqual(5, ContainerWithMostWater.MaxArea(hight));
        }
        public void MaxAreaTestCase1()
        {
            var input = new[] { 1, 8, 6, 2, 5, 4, 8, 3, 7 };

            ContainerWithMostWater.MaxArea(input).Should().Be(49);
        }
        public void MaxAreaTestCase3()
        {
            var input = new[] { 4, 3, 2, 1, 4 };

            ContainerWithMostWater.MaxArea(input).Should().Be(16);
        }
        public void MaxAreaTestCase7()
        {
            var input = new[] { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 };

            ContainerWithMostWater.MaxArea(input).Should().Be(25);
        }
        public void MaxAreaTestCase6()
        {
            var input = new[] { 2, 3, 4, 5, 18, 17, 6 };

            ContainerWithMostWater.MaxArea(input).Should().Be(17);
        }
        public void MaxAreaTestCase5()
        {
            var input = new[] { 2, 1 };

            ContainerWithMostWater.MaxArea(input).Should().Be(1);
        }