public void SetDialog() { var state = new RumorState(); var wrong = false; var count = 0; state.OnSetDialog += (obj, str) => count++; state.OnAddDialog += (obj, str) => wrong = true; state.OnAddChoice += (index, str) => wrong = true; state.OnRemoveChoice += (index, str) => wrong = true; state.OnClear += (type) => wrong = true; // First use state.SetDialog("Narrator", "Hello World."); Assert.AreEqual(1, state.Dialog.Keys.Count); Assert.AreEqual(1, state.Dialog.Values.Count); Assert.True(state.Dialog["Narrator"] == "Hello World."); // Second use state.SetDialog("Someone", "Goodbye World."); Assert.AreEqual(1, state.Dialog.Keys.Count); Assert.AreEqual(1, state.Dialog.Values.Count); Assert.True(state.Dialog["Someone"] == "Goodbye World."); // Check callback Assert.AreEqual(2, count); Assert.IsFalse(wrong); }
public void SerializeRumorStateDialog() { var a = new RumorState(); a.SetDialog(null, "dialog"); var b = Reserialize(a); Assert.AreEqual(a.Dialog[null], b.Dialog[null]); }