示例#1
0
    public async Task ParseAsync(XmlReader reader, IParsingContext parsingContext, IParentParsingContext parentParsingContext)
    {
        var myContext = new TextParentParsingContext();
        await elementParser.ParseAsync(reader, parsingContext, myContext, Settings);

        var parsedText = myContext.ParsedText;

        parsingContext.SceneContext.Reset();

        if (string.IsNullOrWhiteSpace(parsedText))
        {
            var node = new PauseNode(myContext.When);
            parentParsingContext.AddNode(node);
            return;
        }

        var value = int.Parse(parsedText);

        if (value <= 0)
        {
            parsingContext.LogError(reader, "O tempo de espera precisa ser maior que zero.");
            return;
        }

        if (value > 5000)
        {
            parsingContext.LogError(reader, "O tempo de espera não pode ser maior que 5000.");
            return;
        }

        var timedPauseNode = new TimedPauseNode(TimeSpan.FromMilliseconds(value), myContext.When);

        parentParsingContext.AddNode(timedPauseNode);
    }
示例#2
0
    public void Initialization()
    {
        var when     = A.Dummy <ICondition>();
        var duration = TimeSpan.FromMilliseconds(123456);

        var sut = new TimedPauseNode(duration, when);

        sut.When.Should().BeSameAs(when);
        sut.Duration.Should().Be(duration);
    }
示例#3
0
    public async Task EnterAsyncWithStateArgShouldDoNothing()
    {
        var context = A.Dummy <INavigationContext>();
        var invoker = new TestInvoker(context);

        var duration = TimeSpan.FromMilliseconds(234567);

        var sut = new TimedPauseNode(duration, null);
        await sut.EnterAsync(context, null);

        invoker.Count.Should().Be(0);
    }
示例#4
0
    public async Task EnterAsync()
    {
        var context = A.Dummy <INavigationContext>();
        var invoker = new TestInvoker(context);

        var duration = TimeSpan.FromMilliseconds(234567);

        var sut = new TimedPauseNode(duration, null);
        var ret = await sut.EnterAsync(context);

        ret.Should().BeNull();

        invoker.ShouldContainSingle <ITimedPauseEvent>(
            i => i.Should().BeEquivalentTo(new { Duration = duration })
            );
    }