示例#1
0
        public void Run_ValidNumbers_UserShouldBeToldToEnterAnotherNumbers()
        {
            var program = new FakeProgram();

            var sb = new StringBuilder();
            using (var sw = new StringWriter(sb))
            {
                Console.SetOut(sw);
                program.Run("1,2,3");
            }

            var expected = new StringBuilder();
            expected.AppendLine("The result is 6");
            expected.AppendLine("Another input please");

            sb.ToString().Should().Be(expected.ToString());
        }
示例#2
0
        public void Run_ValidNumbersProvidedTwiceAndEmptyString_TwoSumsAndTwoEnterAnotherNumbersShouldBeOutputToConsole()
        {
            var program = new FakeProgram()
                .WithNumbers("1,2");

            var sb = new StringBuilder();
            using (var sw = new StringWriter(sb))
            {
                Console.SetOut(sw);
                program.Run("1,2,3");
            }

            var expected = new StringBuilder();
            expected.AppendLine("The result is 6");
            expected.AppendLine("Another input please");
            expected.AppendLine("The result is 3");
            expected.AppendLine("Another input please");

            sb.ToString().Should().Be(expected.ToString());
        }