Exemplo n.º 1
0
        public async Task RunAsync_ShouldReturnRunningAndRaiseEventWhenDone()
        {
            // Arrange
            var        child1     = new TestNode();
            var        node       = new SequenceNode <object>("", child1);
            ResultType?nodeResult = null;

            node.Finished += (r) =>
            {
                nodeResult = r;
            };

            // Act
            await node.BeforeRunAsync();

            var result = await node.RunAsync();

            child1.TriggerFinishedEvent(ResultType.Succeeded);

            // Assert
            Assert.Equal(ResultType.Running, result);
            Assert.NotNull(nodeResult);
            Assert.Equal(ResultType.Succeeded, nodeResult);
        }
Exemplo n.º 2
0
        public async Task RunAsync_ShouldReturnRunningAndTriggerEventWithFailed_WhenChildRunsThenSucceeds()
        {
            // Arrange
            var        child      = new TestNode();
            var        node       = new InverterNode <object>("", child);
            ResultType?nodeResult = null;

            node.Finished += (r) =>
            {
                nodeResult = r;
            };

            // Act
            await node.BeforeRunAsync();

            var result = await node.RunAsync();

            child.TriggerFinishedEvent(ResultType.Succeeded);

            // Assert
            Assert.Equal(ResultType.Running, result);
            Assert.NotNull(nodeResult);
            Assert.Equal(ResultType.Failed, nodeResult);
        }