예제 #1
0
        public static InvestPlan Input(string investPlans)
        {
            var result = new InvestPlan(investPlans);

            result.ProcessInvestment();
            return(result);
        }
예제 #2
0
        public void WhenInputIs10ThenEmpty()
        {
            var result = InvestPlan.Input(@"0
10
1 2 3 1 1 1 1 1 1 1 1 1").Output();

            Assert.AreEqual("Case 1: 1 3 20", result);
        }
예제 #3
0
        public void WhenInputIsOneThenImpossible()
        {
            var result = InvestPlan.Input(@"0
1
1 1 1 1 1 1 1 1 1 1 1 1").Output();

            Assert.AreEqual("Case 1: IMPOSSIBLE", result);
        }
예제 #4
0
        public void WhenMultipleInputsThenMultipleResults()
        {
            var result = InvestPlan.Input(@"0
10
1 2 3 1 1 1 1 1 1 1 1 1
20
1 5 10 2 1 6 1 1 2 20 1 1").Output();

            Assert.AreEqual("Case 1: 1 3 20\nCase 2: 1 10 380", result);
        }
예제 #5
0
        public void WhenInputIsNullOrEmptyThenThrowException()
        {
            try
            {
                InvestPlan.Input(string.Empty).Output();
            }
            catch (ArgumentOutOfRangeException ex)
            {
                Assert.AreEqual("index", ex.ParamName);
                Assert.IsTrue(true);
            }

            try
            {
                InvestPlan.Input(null).Output();
            }
            catch (NullReferenceException)
            {
                Assert.IsTrue(true);
            }
        }
예제 #6
0
        public void WhenInputIsOnlyZeroThenEmpty()
        {
            var result = InvestPlan.Input("0").Output();

            Assert.AreEqual(string.Empty, result);
        }