예제 #1
0
        public void RepromptsWhenResponseAboveMaxValue(string response, int maxValue)
        {
            var(stdOut, stdIn) = TestFx.ConsoleDefaults();

            (int result, string output) = TestFx.RepromptWithInvalidFirstIntegerResponse("", response,
                                                                                         $"{maxValue - 1}", null, maxValue);
            Assert.Equal(maxValue - 1, result);

            TestFx.ResetConsole(stdOut, stdIn);
        }
예제 #2
0
        public void RepromptsWhenResponseBelowMinValue(string response, int minValue)
        {
            var(stdOut, stdIn) = TestFx.ConsoleDefaults();

            (int result, string output) = TestFx.RepromptWithInvalidFirstIntegerResponse("", response,
                                                                                         $"{minValue + 1}", minValue);
            Assert.Equal(minValue + 1, result);

            TestFx.ResetConsole(stdOut, stdIn);
        }
예제 #3
0
        [InlineData("-2147483649")] // One below int.MinValue
        public void DoesNotOutputHelpMessageWithVerboseOff(string response)
        {
            var(stdOut, stdIn) = TestFx.ConsoleDefaults();

            (int result, string output) =
                TestFx.RepromptWithInvalidFirstIntegerResponse("", response, "15", verbose: false);

            Assert.DoesNotContain("whole number", output);
            TestFx.ResetConsole(stdOut, stdIn);
        }
예제 #4
0
        [InlineData("-2147483649")] // One below int.MinValue
        public void RepromptsWhenResponseIsInvalid(string response)
        {
            var(stdOut, stdIn) = TestFx.ConsoleDefaults();

            (int result, string output) = TestFx.RepromptWithInvalidFirstIntegerResponse("", response,
                                                                                         "15", int.MinValue);
            Assert.Equal(15, result);

            TestFx.ResetConsole(stdOut, stdIn);
        }
예제 #5
0
        [InlineData("-2147483649")] // One below int.MinValue
        public void OutputsHelpMessageWithInvalidResponse(string response)
        {
            var(stdOut, stdIn) = TestFx.ConsoleDefaults();

            (int result, string output) = TestFx.RepromptWithInvalidFirstIntegerResponse("", response, "15");

            string expected =
                $"Please supply a whole number between {int.MinValue} and {int.MaxValue}.";

            Assert.Contains(expected, output);
            TestFx.ResetConsole(stdOut, stdIn);
        }