コード例 #1
0
        public void ClearChoices()
        {
            var state = new RumorState();

            var       wrong = false;
            var       count = 0;
            ClearType?type  = null;

            state.OnRemoveChoice += (index, str) => wrong = true;
            state.OnClear        += (t) => type = t;

            // Test Clear All
            state.AddChoice("a", null);
            state.AddChoice("b", null);
            state.Clear();
            Assert.AreEqual(0, state.Choices.Count);
            Assert.AreEqual(0, state.Consequences.Count);
            Assert.AreEqual(ClearType.ALL, type);

            // Test Clear Dialog
            state.AddChoice("a", null);
            state.AddChoice("b", null);
            state.ClearDialog();
            Assert.AreEqual(2, state.Choices.Count);
            Assert.True(state.Choices[0] == "a");
            Assert.True(state.Choices[1] == "b");
            Assert.AreEqual(2, state.Consequences.Count);
            Assert.True(state.Consequences[0].Count == 0);
            Assert.True(state.Consequences[1].Count == 0);
            Assert.AreEqual(ClearType.DIALOG, type);

            // Test Clear Choices
            state.AddChoice("a", null);
            state.AddChoice("b", null);
            state.ClearChoices();
            Assert.AreEqual(0, state.Choices.Count);
            Assert.AreEqual(0, state.Consequences.Count);
            Assert.AreEqual(ClearType.CHOICES, type);

            // Check callback
            Assert.AreEqual(0, count);
            Assert.IsFalse(wrong);
        }
コード例 #2
0
        public void ClearDialog()
        {
            var state = new RumorState();

            var       wrong = false;
            ClearType?type  = null;

            state.OnAddChoice    += (index, str) => wrong = true;
            state.OnRemoveChoice += (index, str) => wrong = true;
            state.OnClear        += (t) => type = t;

            // Test Clear All
            state.AddDialog("Narrator", "Hello World.");
            state.AddDialog("Someone", "Goodbye World.");
            state.Clear();
            Assert.AreEqual(0, state.Dialog.Keys.Count);
            Assert.AreEqual(0, state.Dialog.Values.Count);
            Assert.AreEqual(ClearType.ALL, type);

            // Test Clear Dialog
            state.AddDialog("Narrator", "Hello World.");
            state.AddDialog("Someone", "Goodbye World.");
            state.ClearDialog();
            Assert.AreEqual(0, state.Dialog.Keys.Count);
            Assert.AreEqual(0, state.Dialog.Values.Count);
            Assert.AreEqual(ClearType.DIALOG, type);

            // Test Clear Choices
            state.AddDialog("Narrator", "Hello World.");
            state.AddDialog("Someone", "Goodbye World.");
            state.ClearChoices();
            Assert.AreEqual(2, state.Dialog.Keys.Count);
            Assert.AreEqual(2, state.Dialog.Values.Count);
            Assert.True(state.Dialog["Narrator"] == "Hello World.");
            Assert.True(state.Dialog["Someone"] == "Goodbye World.");
            Assert.AreEqual(ClearType.CHOICES, type);

            // Check callback
            Assert.IsFalse(wrong);
        }