コード例 #1
0
        public void ThreeHouses()
        {
            var sol = new HouseRobber();

            Assert.AreEqual(4, sol.Rob(new int[] { 1, 3, 3 }));
            Assert.AreEqual(21, sol.Rob(new int[] { 10, 21, 10 }));
        }
コード例 #2
0
        public void Empty()
        {
            var sol = new HouseRobber();

            Assert.AreEqual(0, sol.Rob(null));
            Assert.AreEqual(0, sol.Rob(new int[0]));
        }
コード例 #3
0
        public void TwoHouses()
        {
            var sol = new HouseRobber();

            Assert.AreEqual(2, sol.Rob(new int[] { 1, 2 }));
            Assert.AreEqual(10, sol.Rob(new int[] { 10, 9 }));
        }
コード例 #4
0
        public void OneHouse()
        {
            var sol = new HouseRobber();

            Assert.AreEqual(1, sol.Rob(new int[] { 1 }));
            Assert.AreEqual(10, sol.Rob(new int[] { 10 }));
        }
コード例 #5
0
        public void FourHouses()
        {
            var sol = new HouseRobber();

            Assert.AreEqual(24, sol.Rob(new int[] { 1, 3, 3, 21 }));
            Assert.AreEqual(23, sol.Rob(new int[] { 10, 21, 13, 1 }));
            Assert.AreEqual(104, sol.Rob(new int[] { 5, 1, 98, 99 }));
        }
コード例 #6
0
        public void RobTests()
        {
            HouseRobber obj = new HouseRobber();

            //        Input: [1, 2, 3, 1]
            //Output: 4        }

            int[] nums = new int[] { 1, 2, 3, 1 };
            var   x    = obj.Rob(nums);

            //        Input: [2, 7, 9, 3, 1]
            //Output: 12
            nums = new int[] { 2, 7, 9, 3, 1 };
            x    = obj.Rob(nums);
        }
コード例 #7
0
ファイル: HouseRobberTests.cs プロジェクト: prose01/Exercises
        public void TestingRob(int[] nums, int expected)
        {
            var houseRobber = new HouseRobber();

            var result = houseRobber.Rob(nums);

            Assert.AreEqual(expected, result);
        }
コード例 #8
0
        public void Rob_ShouldReturn_MaximumAmount_ThatCanBeRobbed(int[] nums, int expectedAmount)
        {
            // Arrange
            var houseRobber = new HouseRobber();

            // Act
            var amount = houseRobber.Rob(nums);

            // Assert
            amount.Should().Be(expectedAmount);
        }
コード例 #9
0
        public void TestHouseRobber2()
        {
            var r = HouseRobber.HouseRobber2(new[] { 2, 7, 9, 3, 1 });

            Assert.AreEqual(r, 11);

            r = HouseRobber.Rob(new[] { 3, 5, 1, 9, 20 });
            Assert.AreEqual(r, 25);

            r = HouseRobber.HouseRobber2(new[] { 103, 5, 1, 9, 20, 100 });
            Assert.AreEqual(r, 124);
        }