public void DialogGetter(int offset)
        {
            DialogTree tree = m_project.ProjectDialogs.CreateNewDialogTree();

            Assert.IsNotNull(tree);
            Assert.IsNotNull(m_project.ProjectDialogs[tree]);
            DialogTreeIdentifier fakeTreeId = new DialogTreeIdentifier(tree.Id.DialogTreeId + offset);

            Assert.IsNull(m_project.ProjectDialogs[fakeTreeId]);

            DialogTreeBranch branch = tree.CreateNewBranch();

            Assert.IsNotNull(branch);
            Assert.IsNotNull(m_project.ProjectDialogs[branch]);
            DialogTreeBranchIdentifier fakeBranchId = new DialogTreeBranchIdentifier(branch.Id, branch.Id.DialogTreeBranchId + offset);

            Assert.IsNull(m_project.ProjectDialogs[fakeBranchId]);

            DialogSegment dialogSegment = branch.CreateNewDialog(CharacterId.DefaultId);

            Assert.IsNotNull(dialogSegment);
            Assert.IsNotNull(m_project.ProjectDialogs[dialogSegment.Id]);
            DialogSegmentIdentifier fakeSegmentId = new DialogSegmentIdentifier(dialogSegment.Id, dialogSegment.Id.DialogSegmentId + offset);

            Assert.IsNull(m_project.ProjectDialogs[fakeSegmentId]);
        }
Esempio n. 2
0
        public void ClearElements()
        {
            NpcChatProject project = new NpcChatProject();

            if (project.ProjectCharacters.RegisterNewCharacter(out int id, "bill"))
            {
                DialogTree       tree   = project.ProjectDialogs.CreateNewDialogTree();
                DialogTreeBranch branch = tree.CreateNewBranch();

                DialogSegment segment = branch.CreateNewDialog(id);
                Assert.NotNull(segment);

                DialogText one = DialogTypeStore.Instance.CreateEntity <DialogText>();
                one.Text = "one";
                segment.AddDialogElement(one);

                Assert.IsTrue(segment.SegmentParts.Count > 0);

                bool callback = false;
                segment.PropertyChanged += (sender, args) => callback = true;

                segment.ClearElements();

                Assert.AreEqual(0, segment.SegmentParts.Count);
                Assert.IsTrue(callback, "Failed to send callback for added type");
            }
            else
            {
                Assert.Fail("Failed to create character");
            }
        }
Esempio n. 3
0
        public void AddElement(Type dialogType)
        {
            NpcChatProject project = new NpcChatProject();

            if (project.ProjectCharacters.RegisterNewCharacter(out int id, "bill"))
            {
                DialogTree       tree   = project.ProjectDialogs.CreateNewDialogTree();
                DialogTreeBranch branch = tree.CreateNewBranch();

                DialogSegment segment = branch.CreateNewDialog(id);
                Assert.NotNull(segment);

                bool callback = false;
                segment.PropertyChanged += (sender, args) => callback = true;

                int            before  = segment.SegmentParts.Count;
                IDialogElement element = DialogTypeStore.Instance.CreateEntity(dialogType);
                segment.AddDialogElement(element);

                Assert.AreEqual(before + 1, segment.SegmentParts.Count);
                Assert.IsTrue(callback, "Failed to send callback for added type");
            }
            else
            {
                Assert.Fail("Failed to create character");
            }
        }
Esempio n. 4
0
        public void ChangeCharacter()
        {
            NpcChatProject project = new NpcChatProject();

            if (project.ProjectCharacters.RegisterNewCharacter(out int bill, "bill") &&
                project.ProjectCharacters.RegisterNewCharacter(out int tommy, "tommy"))
            {
                DialogTree       tree   = project.ProjectDialogs.CreateNewDialogTree();
                DialogTreeBranch branch = tree.CreateNewBranch();

                DialogSegment segment = branch.CreateNewDialog(bill);
                Assert.NotNull(segment);
                Assert.AreEqual(segment.CharacterId, bill, "Unexpected Character");

                bool callback = false;
                segment.PropertyChanged += (sender, args) => callback = true;

                segment.ChangeCharacter(tommy);

                Assert.AreEqual(segment.CharacterId, tommy, "Failed change character");
                Assert.IsTrue(callback, "Failed to send callback for character change");

                callback = false;
                segment.ChangeCharacter(bill);

                Assert.AreEqual(segment.CharacterId, bill, "Failed change character");
                Assert.IsTrue(callback, "Failed to send callback for character change");
            }
Esempio n. 5
0
        private CharacterDialogVM ElementTextEditTestCreation()
        {
            NpcChatProject   project = new NpcChatProject();
            DialogTree       tree    = project.ProjectDialogs.CreateNewDialogTree();
            DialogTreeBranch branch  = tree.CreateNewBranch();

            Assert.AreEqual(0, branch.Dialog.Count, "This is a new branch and shouldn't have any dialog inside it!");

            int charId;

            Assert.IsTrue(project.ProjectCharacters.RegisterNewCharacter(out charId, "Gerald"));
            DialogSegment dialogSegment = branch.CreateNewDialog(charId);

            Assert.AreEqual(1, branch.Dialog.Count, "Failed to create sample dialog segment");

            dialogSegment.ClearElements();
            Assert.AreEqual(0, dialogSegment.SegmentParts.Count);
            Assert.AreEqual("", dialogSegment.Text);

            CharacterDialogVM testVM = new CharacterDialogVM(project, dialogSegment)
            {
                EditMode         = EditMode.Elements,
                InspectionActive = false
            };

            // make sure creation was valid
            Assert.NotNull(testVM);
            Assert.AreSame(dialogSegment, testVM.DialogSegment);
            Assert.AreEqual(0, testVM.DialogSegment.SegmentParts.Count);

            return(testVM);
        }
Esempio n. 6
0
        public void ElementTextEditTestEditThenInspect()
        {
            CharacterDialogVM testVM        = ElementTextEditTestCreation();
            DialogSegment     dialogSegment = testVM.DialogSegment;

            testVM.EditMode         = EditMode.TextBlock;
            testVM.InspectionActive = true;
            Assert.AreEqual("", testVM.DialogDocument.Text());
            testVM.EditMode = EditMode.Elements;

            // add simple text element
            string elementName = new DialogText().ElementName;

            Assert.IsTrue(testVM.AddDialogElementCommand.CanExecute(elementName));
            testVM.AddDialogElementCommand.Execute(elementName);
            Assert.AreEqual(1, dialogSegment.SegmentParts.Count);

            // edit simple text
            const string simpleText = "This is some simple text";
            DialogText   element    = dialogSegment.SegmentParts.First() as DialogText;

            Assert.NotNull(element);
            element.Text = simpleText;

            // check that all of the characterDialogVMs text matches
            Assert.AreEqual(simpleText, element.Text);
            Assert.AreEqual(simpleText, dialogSegment.Text);
            testVM.EditMode = EditMode.TextBlock;
            Assert.AreEqual(simpleText, testVM.DialogDocument.Text());
        }
        public void DuplicateIdTest()
        {
            DialogTree       tree   = m_project.ProjectDialogs.CreateNewDialogTree();
            DialogTreeBranch branch = tree.CreateNewBranch();
            DialogSegment    one    = branch.CreateNewDialog(12);
            DialogSegment    two    = branch.CreateNewDialog(13);

            Assert.AreNotEqual(one.Id, two.Id);
        }
        public void NullRemove()
        {
            DialogTree       tree   = m_project.ProjectDialogs.CreateNewDialogTree();
            DialogTreeBranch branch = tree.CreateNewBranch();
            DialogSegment    one    = branch.CreateNewDialog(12);

            // remove existing
            Assert.IsFalse(branch.RemoveDialog((DialogSegment)null));
            Assert.IsFalse(branch.RemoveDialog((DialogSegmentIdentifier)null));
        }
        public void Contains()
        {
            DialogTree       tree   = m_project.ProjectDialogs.CreateNewDialogTree();
            DialogTreeBranch branch = tree.CreateNewBranch();
            DialogSegment    one    = branch.CreateNewDialog(12);
            DialogSegment    two    = branch.CreateNewDialog(13);

            Assert.IsTrue(branch.ContainsDialogSegment(one));
            Assert.IsTrue(branch.ContainsDialogSegment(one.Id));

            Assert.IsTrue(branch.ContainsDialogSegment(two));
            Assert.IsTrue(branch.ContainsDialogSegment(two.Id));
        }
        public void Contains2()
        {
            DialogTree       tree   = m_project.ProjectDialogs.CreateNewDialogTree();
            DialogTreeBranch branch = tree.CreateNewBranch();
            DialogSegment    one    = branch.CreateNewDialog(12);

            Assert.IsTrue(branch.ContainsDialogSegment(one));
            Assert.IsTrue(branch.ContainsDialogSegment(one.Id));

            Assert.IsTrue(branch.RemoveDialog(one));

            Assert.IsFalse(branch.ContainsDialogSegment(one));
            Assert.IsFalse(branch.ContainsDialogSegment(one.Id));
        }
        public void Contains3()
        {
            DialogTree       tree   = m_project.ProjectDialogs.CreateNewDialogTree();
            DialogTreeBranch branch = tree.CreateNewBranch();
            DialogSegment    one    = branch.CreateNewDialog(12);

            Assert.IsTrue(branch.ContainsDialogSegment(one));
            Assert.IsTrue(branch.ContainsDialogSegment(one.Id));

            //make an id that has a different initial identifier but an id of an existing segment
            DialogTree              tree2   = m_project.ProjectDialogs.CreateNewDialogTree();
            DialogTreeBranch        branch2 = tree2.CreateNewBranch();
            DialogSegmentIdentifier fakeId  = new DialogSegmentIdentifier(branch2.Id, one.Id.DialogSegmentId);

            Assert.IsFalse(branch.ContainsDialogSegment(fakeId));
        }
        public void DialogHasId()
        {
            DialogTree tree = m_project.ProjectDialogs.CreateNewDialogTree();

            Assert.IsTrue(m_project.ProjectDialogs.HasDialog(tree.Id));

            DialogTreeBranch branch = tree.CreateNewBranch();

            Assert.NotNull(branch);
            Assert.IsTrue(m_project.ProjectDialogs.HasDialog(branch.Id));

            DialogSegment dialogSegment = branch.CreateNewDialog(CharacterId.DefaultId);

            Assert.NotNull(dialogSegment);
            Assert.IsTrue(m_project.ProjectDialogs.HasDialog(dialogSegment.Id));
        }
        public void DialogHasIdFalse()
        {
            DialogTree tree = m_project.ProjectDialogs.CreateNewDialogTree();

            Assert.IsFalse(m_project.ProjectDialogs.HasDialog(new DialogTreeIdentifier(tree.Id.DialogTreeId + 1)));
            Assert.IsFalse(m_project.ProjectDialogs.HasDialog(new DialogTreeIdentifier(tree.Id.DialogTreeId + 10)));

            DialogTreeBranch branch = tree.CreateNewBranch();

            Assert.NotNull(branch);
            Assert.IsFalse(m_project.ProjectDialogs.HasDialog(new DialogTreeBranchIdentifier(branch.Id, branch.Id.DialogTreeBranchId + 1)));
            Assert.IsFalse(m_project.ProjectDialogs.HasDialog(new DialogTreeBranchIdentifier(branch.Id, branch.Id.DialogTreeBranchId + 10)));

            DialogSegment dialogSegment = branch.CreateNewDialog(CharacterId.DefaultId);

            Assert.NotNull(dialogSegment);
            Assert.IsFalse(m_project.ProjectDialogs.HasDialog(new DialogSegmentIdentifier(dialogSegment.Id, dialogSegment.Id.DialogSegmentId + 1)));
            Assert.IsFalse(m_project.ProjectDialogs.HasDialog(new DialogSegmentIdentifier(dialogSegment.Id, dialogSegment.Id.DialogSegmentId + 10)));
        }
Esempio n. 14
0
        public void CharacterIdentification()
        {
            NpcChatProject project = new NpcChatProject();

            int id;

            if (project.ProjectCharacters.RegisterNewCharacter(out id, "bill"))
            {
                DialogTree       tree    = project.ProjectDialogs.CreateNewDialogTree();
                DialogTreeBranch branch  = tree.CreateNewBranch();
                DialogSegment    segment = branch.CreateNewDialog(id);

                Assert.NotNull(segment);
                Assert.AreEqual(id, segment.CharacterId);
            }
            else
            {
                Assert.Fail("Failed to create character");
            }
        }
Esempio n. 15
0
        public void RemoveElement()
        {
            NpcChatProject project = new NpcChatProject();

            if (project.ProjectCharacters.RegisterNewCharacter(out int id, "bill"))
            {
                DialogTree       tree   = project.ProjectDialogs.CreateNewDialogTree();
                DialogTreeBranch branch = tree.CreateNewBranch();

                DialogSegment segment = branch.CreateNewDialog(id);
                Assert.NotNull(segment);
                segment.ClearElements();

                //ensure there are elements in the segment
                DialogText one = DialogTypeStore.Instance.CreateEntity <DialogText>();
                one.Text = "one";
                segment.AddDialogElement(one);
                DialogText two = DialogTypeStore.Instance.CreateEntity <DialogText>();
                one.Text = "two";
                segment.AddDialogElement(two);
                Assert.IsTrue(segment.SegmentParts.Count > 0);

                bool callback = false;
                segment.PropertyChanged += (sender, args) => callback = true;

                int before = segment.SegmentParts.Count;
                segment.RemoveDialogElement(one);

                Assert.AreEqual(before - 1, segment.SegmentParts.Count);
                Assert.IsTrue(callback, "Failed to send callback for added type");

                //ensure correct element is actually removed
                Assert.IsFalse(segment.SegmentParts.Contains(one));
                Assert.IsTrue(segment.SegmentParts.Contains(two));
            }
            else
            {
                Assert.Fail("Failed to create character");
            }
        }
Esempio n. 16
0
        public bool HasDialog(DialogSegmentIdentifier id)
        {
            DialogSegment dialogSegment = this[id];

            return(dialogSegment != null);
        }