Example #1
0
            public void It_should_trigger_the_current_pointer_choice_to_speak()
            {
                var choiceNode = A.Node.Build();
                var choice     = Substitute.For <IChoice>();

                choice.GetValidChildNode().Returns(choiceNode);

                var nodeNested = A.Node
                                 .WithChoice(choice)
                                 .Build();
                var node = A.Node
                           .WithNextResult(nodeNested)
                           .Build();

                _graph = A.Graph
                         .WithNextResult(node)
                         .Build();
                _playback = new DialoguePlayback(_graph, null, _events);

                _playback.Play();
                _playback.Next();
                _playback.SelectChoice(0);

                choiceNode.Received(1).Play(_playback);
            }
Example #2
0
                public void If_no_next_result_trigger_end_event()
                {
                    var node = A.Node
                               .WithNextResult(null)
                               .Build();

                    _graph = A.Graph
                             .WithNextResult(node)
                             .Build();
                    _playback = new DialoguePlayback(_graph, null, _events);

                    _playback.Play();
                    _playback.Next();

                    _playback.Events.End.Received(1).Invoke();
                }
Example #3
0
                public void It_should_trigger_speak_on_the_next_sibling_node()
                {
                    var nodeNested = A.Node.Build();
                    var node       = A.Node
                                     .WithNextResult(nodeNested)
                                     .Build();

                    _graph = A.Graph
                             .WithNextResult(node)
                             .Build();
                    _playback = new DialoguePlayback(_graph, null, _events);

                    _playback.Play();
                    _playback.Next();

                    nodeNested.Received(1).Play(_playback);
                }
Example #4
0
                public void BeforeEachMethod()
                {
                    _exitAction = A.Action
                                  .WithTickStatus(ActionStatus.Continue)
                                  .Build();
                    _nodeNested = A.Node.Build();
                    _node       = A.Node
                                  .WithExitAction(_exitAction)
                                  .WithNextResult(_nodeNested)
                                  .Build();
                    _graph = A.Graph
                             .WithNextResult(_node)
                             .Build();

                    _playback = new DialoguePlayback(_graph, null, _events);
                    _playback.Play();
                    _playback.Next();
                }
Example #5
0
                public void It_should_trigger_end_event_only_once_when_an_action_is_present()
                {
                    var action = A.Action.Build();
                    var node   = A.Node
                                 .WithNextResult(null)
                                 .WithEnterAction(action)
                                 .Build();

                    _graph = A.Graph
                             .WithNextResult(node)
                             .Build();
                    _playback = new DialoguePlayback(_graph, null, _events);

                    _playback.Play();
                    _playback.Next();

                    _playback.Events.End.Received(1).Invoke();
                }
Example #6
0
            public void It_should_not_crash_when_updating_multiple_actions_at_the_same_time()
            {
                var action = A.Action
                             .WithTickStatus(ActionStatus.Continue)
                             .Build();
                var node = A.Node
                           .WithExitAction(action)
                           .WithExitAction(action)
                           .Build();
                var graph = A.Graph
                            .WithNextResult(node)
                            .Build();

                _playback = new DialoguePlayback(graph, null, _events);

                _playback.Play();
                _playback.Next();
                action.Tick().Returns(ActionStatus.Success);
                _playback.Tick();
            }
Example #7
0
                public void It_should_emit_a_choice_event_if_next_node_has_choices()
                {
                    var choice     = Substitute.For <IChoice>();
                    var nodeNested = A.Node
                                     .WithChoice(choice)
                                     .Build();
                    var node = A.Node
                               .WithNextResult(nodeNested)
                               .Build();

                    _graph = A.Graph
                             .WithNextResult(node)
                             .Build();
                    _playback = new DialoguePlayback(_graph, null, _events);

                    _playback.Play();
                    _playback.Next();

                    nodeNested.Received(1).Play(_playback);
                }