Beispiel #1
0
        public void PossibleBranchLinkAdded2()
        {
            NpcChatProject project = new NpcChatProject();
            DialogTree     tree    = project.ProjectDialogs.CreateNewDialogTree();

            DialogTreeBranch a = tree.GetStart();

            a.Name = "A";
            BranchTestScriptView branchTest = new BranchTestScriptView();
            TreeBranchVM         aBranch    = new TreeBranchVM(project, branchTest, a);

            branchTest.Branches.Add(aBranch);

            Assert.IsFalse(aBranch.AreBranchLinksPossible, "Branch links are possible as there are no other branches");
            Assert.AreEqual(0, aBranch.PotentialBranchLinks.Count);

            DialogTreeBranch b = tree.CreateNewBranch();

            b.Name = "B";
            TreeBranchVM bBranch = new TreeBranchVM(project, branchTest, b);

            branchTest.Branches.Add(bBranch);

            //no relation between the branches so all links are possible
            TestBranchPossibility(aBranch, b);
            TestBranchPossibility(bBranch, a);

            // link a to b so that the options for both branches are limited
            RelationshipCreate(a, b);

            //A is parent of B so there should be no possible actions
            TestBranchPossibility(aBranch);
            TestBranchPossibility(bBranch);
        }
Beispiel #2
0
        /// <summary>
        /// Performs a series of tests to ensure a tree branches possible links are correct based on the expected links in the <see cref="children"/> parameter
        /// </summary>
        /// <param name="branch">tree branch VM to test</param>
        /// <param name="children">all expected links, if any</param>
        private void TestBranchPossibility(TreeBranchVM branch, params DialogTreeBranch[] children)
        {
            bool shouldHaveLinks = children.Any();

            Assert.AreEqual(shouldHaveLinks, branch.AreBranchLinksPossible);
            if (shouldHaveLinks)
            {
                Assert.GreaterOrEqual(0, branch.SelectedBranchLinkIndex);
            }

            Assert.AreEqual(children.Length, branch.PotentialBranchLinks.Count, "Unexpected amount of children found");
            foreach (DialogTreeBranch link in children)
            {
                Assert.IsTrue(branch.PotentialBranchLinks.Any(s => s == link),
                              $"branch '{branch.DialogBranch.Name}' is expected to have '{link.Name}' as a potential link... but it doesn't!");
            }

            foreach (TreeBranchLinkInfoVM link in branch.BranchLinks)
            {
                if (children.Any(c => c == link.Child))
                {
                    Assert.Fail($"Potential branch link contained inside '{branch.DialogBranch.Name}' that is an actual branch link!");
                }
            }
        }
Beispiel #3
0
        public void PossibleBranchLinkPreExisting()
        {
            NpcChatProject project = new NpcChatProject();
            DialogTree     tree    = project.ProjectDialogs.CreateNewDialogTree();

            DialogTreeBranch a = tree.GetStart();

            a.Name = "A";
            BranchTestScriptView branchTest = new BranchTestScriptView();
            TreeBranchVM         aBranch    = new TreeBranchVM(project, branchTest, a);

            branchTest.Branches.Add(aBranch);

            //no other branches so there shouldn't be any possibilities
            TestBranchPossibility(aBranch);

            DialogTreeBranch b = tree.CreateNewBranch();

            b.Name = "B";
            RelationshipCreate(a, b);

            TreeBranchVM bBranch = new TreeBranchVM(project, branchTest, b);

            branchTest.Branches.Add(bBranch);

            //branches already linked so there shouldn't be any possible links
            TestBranchPossibility(aBranch);
            TestBranchPossibility(bBranch);
        }
Beispiel #4
0
        public void PossibleBranchLinkAdded()
        {
            NpcChatProject project = new NpcChatProject();
            DialogTree     tree    = project.ProjectDialogs.CreateNewDialogTree();

            DialogTreeBranch a = tree.GetStart();

            a.Name = "A";
            BranchTestScriptView branchTest = new BranchTestScriptView();
            TreeBranchVM         aBranch    = new TreeBranchVM(project, branchTest, a);

            branchTest.Branches.Add(aBranch);

            TestBranchPossibility(aBranch);

            DialogTreeBranch b = tree.CreateNewBranch();

            b.Name = "B";

            TestBranchPossibility(aBranch, b);
        }
Beispiel #5
0
        public void PossibleBranchLinkDeleted()
        {
            NpcChatProject       project    = new NpcChatProject();
            DialogTree           tree       = project.ProjectDialogs.CreateNewDialogTree();
            BranchTestScriptView branchTest = new BranchTestScriptView();

            DialogTreeBranch a = tree.GetStart();

            a.Name = "A";
            TreeBranchVM aBranch = new TreeBranchVM(project, branchTest, a);

            branchTest.Branches.Add(aBranch);

            DialogTreeBranch b = tree.CreateNewBranch();

            b.Name = "B";
            TreeBranchVM bBranch = new TreeBranchVM(project, branchTest, b);

            branchTest.Branches.Add(bBranch);

            DialogTreeBranch c = tree.CreateNewBranch();

            c.Name = "C";
            TreeBranchVM cBranch = new TreeBranchVM(project, branchTest, c);

            branchTest.Branches.Add(cBranch);

            RelationshipCreate(a, b);
            RelationshipCreate(b, c);

            TestBranchPossibility(aBranch, c);
            TestBranchPossibility(bBranch);
            TestBranchPossibility(cBranch);

            tree.RemoveBranch(b);

            TestBranchPossibility(aBranch, c);
            TestBranchPossibility(cBranch, a);
        }