Example #1
0
        public void GivenInput_WhenReadingEmail_ShouldReturnEnteredValue()
        {
            console.SetupInput("[email protected]\n");

            var value = console.Input.ReadEmail("Value");

            value.Should().Be(new MailAddress("*****@*****.**"));

            console.CapturedOutput.Should().Be("Value: ");
        }
Example #2
0
        public void GivenInput_WhenSelectingOption_ShouldReturnCorrectValue()
        {
            console.SetupInput("2\n");

            var value = console.Input.ReadOption("Select value:", "A", "B", "C");

            value.Should().Be("B");

            console.CapturedOutput.Should().Be("Select value:\n1. A\n2. B\n3. C\nChoose an option: ");
        }
Example #3
0
        public void GivenInput_WhenReadingString_ShouldReturnEnteredValue()
        {
            console.SetupInput("FOO\n");

            var value = console.Input.ReadString("Value");

            value.Should().Be("FOO");

            console.CapturedOutput.Should().Be("Value: ");
        }
Example #4
0
        public void GivenInput_WhenReadingInt_ShouldReturnEnteredValue()
        {
            console.SetupInput("2\n");

            var value = console.Input.ReadEnum <Fruit>("Value");

            value.Should().Be(Fruit.Banana);
        }
Example #5
0
        public void GivenInput_WhenReading_ShouldReturnEnteredValue()
        {
            console.SetupInput("123\n");

            var value = console.Input.ReadNullableInt("Value");

            value.Should().Be(123);

            console.CapturedOutput.Should().Be("Value: ");
        }
Example #6
0
        public void GivenInput_WhenReadingLong_ShouldReturnEnteredValue()
        {
            console.SetupInput("123\n");

            var value = console.Input.ReadLong("Value");

            value.Should().Be(123L);

            console.CapturedOutput.Should().Be("Value (default: 0): ");
        }
Example #7
0
        public void GivenTrueInput_WhenReadingBool_ShouldReturnTrue()
        {
            console.SetupInput("Enabled\n");

            var value = console.Input.ReadBool("Value");

            value.Should().Be(true);

            console.CapturedOutput.Should().Be("Value (default: False): ");
        }
Example #8
0
        public void GivenInput_WhenReadingIpAddress_ShouldReturnEnteredValue()
        {
            console.SetupInput("1.2.3.4\n");

            var value = console.Input.ReadIpAddress("Value");

            value.Should().Be(IPAddress.Parse("1.2.3.4"));

            console.CapturedOutput.Should().Be("Value: ");
        }
Example #9
0
        public void GivenInput_WhenReadingUrl_ShouldReturnEnteredValue()
        {
            console.SetupInput("http://example.com\n");

            var value = console.Input.ReadUrl("Value");

            value.Should().Be(new Uri("http://example.com"));

            console.CapturedOutput.Should().Be("Value: ");
        }