Example #1
0
        public void Call_Should_CreateExitNode()
        {
            // Arrange
            TestContent content = new TestContent();
            DialogOptionEnd <TestContent> dialogOption = new DialogOptionEnd <TestContent>(content);

            // Act
            DialogNode <TestContent> exitNoe = DialogNode <TestContent> .CreateExitNode(content : content, endOption : dialogOption);

            // Assert
            Assert.Single(exitNoe.DialogOptions);
            Assert.Equal(dialogOption, exitNoe.DialogOptions.FirstOrDefault());
            Assert.Equal(content, exitNoe.Content);
        }
Example #2
0
        public void SimpleDialogStraight_Should_BePlayed()
        {
            //Arrange
            TestContent stepOneContent   = new TestContent("Hello! What's up?");
            TestContent stepTwoContent   = new TestContent("What one?");
            TestContent stepThreeContent = new TestContent("What's next?");

            DialogNode <TestContent> nodeThree = DialogNode <TestContent> .CreateExitNode(
                content : stepThreeContent,
                endOption : new DialogOptionEnd <TestContent>(new TestContent("Three lol.")));

            DialogNode <TestContent> nodeTwo = DialogNode <TestContent> .CreateNew(
                content : stepTwoContent,
                dialogOptions : new List <IDialogOption <TestContent> >
            {
                new DialogOptionNext <TestContent>(content: new TestContent("Two."), nextNode: nodeThree),
            });

            DialogNode <TestContent> nodeOne = DialogNode <TestContent> .CreateNew(
                content : stepOneContent,
                dialogOptions : new List <IDialogOption <TestContent> >
            {
                new DialogOptionNext <TestContent>(content: new TestContent("One."), nextNode: nodeTwo),
            });

            Dialog <TestContent> dialog = Dialog <TestContent> .CreateNew(startNode : nodeOne);

            // Act && Assert
            // Step 1
            Assert.Equal(stepOneContent, dialog.CurrentNode.Content);
            // Step 2
            dialog.CurrentNode.DialogOptions.FirstOrDefault().Select();
            Assert.Equal(stepTwoContent, dialog.CurrentNode.Content);
            // Step 3
            dialog.CurrentNode.DialogOptions.FirstOrDefault().Select();
            Assert.Equal(stepThreeContent, dialog.CurrentNode.Content);
        }
Example #3
0
        public void SimpleDialogWithBranch_Should_BePlayed(bool isFirstBranch)
        {
            //Arrange
            TestContent optionOneContent = new TestContent("Hi, I am fine.");
            TestContent optionTwoContent = new TestContent("Hi, evrything is so bad.");


            DialogNode <TestContent> nodeThree = DialogNode <TestContent> .CreateExitNode(
                content : new TestContent("I am sorry for you."),
                endOption : new DialogOptionEnd <TestContent>(new TestContent("Yeah")));

            DialogNode <TestContent> nodeTwo = DialogNode <TestContent> .CreateExitNode(
                content : new TestContent("So good."),
                endOption : new DialogOptionEnd <TestContent>(new TestContent("Bye")));

            DialogNode <TestContent> nodeOne = DialogNode <TestContent> .CreateNew(
                content : new TestContent("Hello! What's up?"),
                dialogOptions : new List <IDialogOption <TestContent> >
            {
                new DialogOptionNext <TestContent>(content: optionOneContent, nextNode: nodeTwo),
                new DialogOptionNext <TestContent>(content: optionTwoContent, nextNode: nodeThree)
            });

            Dialog <TestContent> dialog = Dialog <TestContent> .CreateNew(startNode : nodeOne);

            // Act && Assert
            if (isFirstBranch)
            {
                dialog.CurrentNode.DialogOptions.FirstOrDefault(o => o.Content == optionOneContent).Select();
                Assert.Equal(nodeTwo, dialog.CurrentNode);
            }
            else
            {
                dialog.CurrentNode.DialogOptions.FirstOrDefault(o => o.Content == optionTwoContent).Select();
                Assert.Equal(nodeThree, dialog.CurrentNode);
            }
        }