Пример #1
0
    public async Task ContextArgument()
    {
        var reader = new StringReader("<storyboard />");

        A.CallTo(() => parsingContext.IsSuccess).Returns(false);
        A.CallTo(() => parsingContext.ToString()).Returns("Erro proposital");
        A.CallTo(() => parsingContext.LogError(A<XmlReader>.Ignored, "Erro proposital")).DoesNothing();

        A.CallTo(() => rootBlockParser.ParseAsync(A<XmlReader>.Ignored, parsingContext))
            .ReturnsLazily(i =>
            {
                var reader = i.GetArgument<XmlReader>(0);
                var context = i.GetArgument<IParsingContext>(1);

                context.LogError(reader, "Erro proposital");

                return Task.FromResult(new List<INode>());
            });

        var ex = await Assert.ThrowsAsync<ParsingException>(
            () => sut.ParseAsync(reader)
        );

        ex.Message.Should().Be("Erro proposital");
    }