Esempio n. 1
0
 public TextIO(TextReader input, TextWriter output)
 {
     _input             = input ?? throw new ArgumentNullException(nameof(input));
     _output            = output ?? throw new ArgumentNullException(nameof(output));
     _stringTokenReader = TokenReader.ForStrings(this);
     _numberTokenReader = TokenReader.ForNumbers(this);
 }
Esempio n. 2
0
    public void ReadTokens_QuantityNeededZero_ThrowsArgumentException()
    {
        var sut = TokenReader.ForStrings(new TextIO(new StringReader(""), _outputWriter));

        Action readTokens = () => sut.ReadTokens("", 0);

        readTokens.Should().Throw <ArgumentOutOfRangeException>()
        .WithMessage("'quantityNeeded' must be greater than zero.*")
        .WithParameterName("quantityNeeded");
    }
Esempio n. 3
0
    public void ReadTokens_ReadingValuesHasExpectedPromptsAndResults(
        string prompt,
        uint tokenCount,
        string input,
        string expectedOutput,
        string[] expectedResult)
    {
        var sut = TokenReader.ForStrings(new TextIO(new StringReader(input + NewLine), _outputWriter));

        var result = sut.ReadTokens(prompt, tokenCount);
        var output = _outputWriter.ToString();

        using var _ = new AssertionScope();
        output.Should().Be(expectedOutput);
        result.Select(t => t.String).Should().BeEquivalentTo(expectedResult);
    }