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); }
public void It_should_clear_if_playing_graph_calls_end() { var dialogueEmpty = new DialoguePlayback(A.Graph.Build(), null, new DialogueEvents()); _ctrl.Play(dialogueEmpty); Assert.AreEqual(null, _ctrl.ActiveDialogue); }
public void It_should_return_Play_dialogue_if_PlayChild_dialogue_calls_end_event() { var dialogueEmpty = new DialoguePlayback(A.Graph.Build(), null, new DialogueEvents()); _ctrl.Play(_playback); _ctrl.PlayChild(dialogueEmpty); Assert.AreEqual(_playback, _ctrl.ActiveDialogue); }
public void BeforeEach() { _graph = A.Graph .WithNextResult(A.Node.Build()) .Build(); _events = Substitute.For <IDialogueEvents>(); _playback = new DialoguePlayback(_graph, null, _events); }
public void It_should_call_Next_on_the_parent_if_End_is_called() { var playback = new DialoguePlayback(A.Graph.Build(), null, new DialogueEvents()); // Automatically calls End since the graph is empty _ctrl.PlayChild(playback); _parentPlayback.Received(1).Next(); }
public void It_should_bind_the_begin_event() { var beginResult = false; _ctrl.Events.Begin.AddListener(() => beginResult = true); var playback = new DialoguePlayback(A.Graph.Build(), null, new DialogueEvents()); _ctrl.Play(playback); Assert.IsTrue(beginResult); }
public void It_should_restore_the_parent_child_if_a_nested_child_ends() { var dialogueChild = Substitute.For <IDialoguePlayback>(); var dialogueEmpty = new DialoguePlayback(A.Graph.Build(), null, new DialogueEvents()); _ctrl.Play(_playback); _ctrl.PlayChild(dialogueChild); _ctrl.PlayChild(dialogueEmpty); Assert.AreEqual(dialogueChild, _ctrl.ActiveDialogue); }
public void It_should_bind_the_end_event() { var endResult = false; _ctrl.Events.End.AddListener(() => endResult = true); var playbackEmpty = new DialoguePlayback(A.Graph.Build(), null, new DialogueEvents()); _ctrl.Play(playbackEmpty); Assert.IsTrue(endResult); }
public void It_should_bind_the_choice_event() { var choiceResult = false; _ctrl.Events.Choice.AddListener((x, y, z) => choiceResult = true); var playback = new DialoguePlayback(A.Graph.Build(), null, new DialogueEvents()); _ctrl.PlayChild(playback); playback.Events.Choice.Invoke(null, null, null); Assert.IsTrue(choiceResult); }
public void It_should_bind_the_speak_event() { var speakResult = false; _ctrl.Events.Speak.AddListener((x, y) => speakResult = true); var playback = new DialoguePlayback(A.Graph.Build(), null, new DialogueEvents()); _ctrl.PlayChild(playback); playback.Events.Speak.Invoke(null, null); Assert.IsTrue(speakResult); }
public void It_should_trigger_play_on_the_root_child() { var node = A.Node.Build(); _graph = A.Graph .WithNextResult(node) .Build(); _playback = new DialoguePlayback(_graph, null, _events); _playback.Play(); node.Received(1).Play(_playback); }
public void BeforeEachMethod() { _enterAction = A.Action .WithTickStatus(ActionStatus.Continue) .Build(); _node = A.Node .WithEnterAction(_enterAction) .Build(); _graph = A.Graph .WithNextResult(_node) .Build(); _playback = new DialoguePlayback(_graph, null, _events); }
public void It_should_trigger_a_speak_event_with_the_root_child_dialogue() { var node = A.Node.Build(); node.Play(Arg.Do <IDialoguePlayback>(p => p.Events.Speak.Invoke(null, null))); _graph = A.Graph .WithNextResult(node) .Build(); _playback = new DialoguePlayback(_graph, null, _events); _playback.Play(); _playback.Events.Speak.ReceivedWithAnyArgs(1).Invoke(null, null); }
public void If_root_enter_action_returns_false_do_not_call_speak() { var node = A.Node.Build(); _graph = A.Graph .WithNextResult(node) .Build(); _graph.Root.EnterActions.Returns(new List <IAction> { _action }); _playback = new DialoguePlayback(_graph, null, _events); _playback.Play(); node.DidNotReceive().Play(_playback); }
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(); }
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); }
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(); }
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); }
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(); }