コード例 #1
0
    public void Failure(string text, string errorMessage)
    {
        var sut    = new TextSourceParser();
        var result = sut.Parse(text);

        result.IsError.Should().BeTrue();
        result.ErrorMessage.Should().Be(errorMessage);
    }
コード例 #2
0
    public void InterpolatorWithoutVariables(string text, params string[] interpolatorValues)
    {
        var sut    = new TextSourceParser();
        var result = sut.Parse(text);

        result.IsError.Should().BeFalse();

        result.TextSource.Should().BeOfType <TextSource>()
        .Which.Interpolator.Should().BeOfType <Interpolator>()
        .Which.Values.Should().BeEquivalentTo(
            interpolatorValues.Select(i => new { IsVariable = false, Value = i })
            );
    }
コード例 #3
0
    public void Success(string text, string expected = null)
    {
        if (expected is null)
        {
            expected = text;
        }

        var sut    = new TextSourceParser();
        var result = sut.Parse(text);

        result.IsError.Should().BeFalse();
        result.TextSource.ToString().Should().Be(expected);
    }
コード例 #4
0
    public void NoInterpolator(string text, string expected = null)
    {
        if (expected is null)
        {
            expected = text;
        }

        var sut    = new TextSourceParser();
        var result = sut.Parse(text);

        result.IsError.Should().BeFalse();
        result.TextSource.Should().BeOfType <TextSource>()
        .Which.Text.Should().Be(expected);
    }
コード例 #5
0
    public void TwoVariables()
    {
        var text   = "{MC} empurrou {antagonist} da ponte.";
        var sut    = new TextSourceParser();
        var result = sut.Parse(text);

        result.IsError.Should().BeFalse();

        result.TextSource.Should().BeOfType <TextSource>()
        .Which.Interpolator.Should().BeOfType <Interpolator>()
        .Which.Values.Should().BeEquivalentTo(new[]
        {
            new { IsVariable = true, Value = "MC" },
            new { IsVariable = false, Value = " empurrou " },
            new { IsVariable = true, Value = "antagonist" },
            new { IsVariable = false, Value = " da ponte." }
        });
    }