public void TurnContextStateCollection_PopPushSetFirst() { var ts = new TurnContextStateCollection(); var test1 = new object(); var test2 = new object(); var test3 = new object(); Assert.IsNull(ts.Pop <object>(), "pop with no pushes is null"); ts.Set(test1); Assert.AreEqual(test1, ts.Get <object>(), "test1 should be current"); Assert.AreNotEqual(test2, ts.Get <object>(), "test1 should be current"); Assert.AreNotEqual(test3, ts.Get <object>(), "test1 should be current"); ts.Push(test2); ts.Push(test3); // test3 should be current object Assert.AreNotEqual(test1, ts.Get <object>(), "test3 should be current"); Assert.AreNotEqual(test2, ts.Get <object>(), "test3 should be current"); Assert.AreEqual(test3, ts.Get <object>(), "test3 should be current"); Assert.AreEqual(test2, ts.Pop <object>(), "pop should return test2"); Assert.AreNotEqual(test1, ts.Get <object>(), "test2 should be current"); Assert.AreEqual(test2, ts.Get <object>(), "test2 should be current"); Assert.AreNotEqual(test3, ts.Get <object>(), "test2 should be current"); Assert.AreEqual(test1, ts.Pop <object>(), "pop should return test1"); Assert.AreEqual(test1, ts.Get <object>(), "test1 should be current"); Assert.AreNotEqual(test2, ts.Get <object>(), "test1 should be current"); Assert.AreNotEqual(test3, ts.Get <object>(), "test1 should be current"); Assert.AreEqual(test1, ts.Pop <object>(), "pop should return test1"); Assert.AreEqual(test1, ts.Get <object>(), "test1 should be current"); Assert.AreNotEqual(test2, ts.Get <object>(), "test1 should be current"); Assert.AreNotEqual(test3, ts.Get <object>(), "test1 should be current"); Assert.AreEqual(test1, ts.Pop <object>(), "pop should return test1"); Assert.AreEqual(test1, ts.Get <object>(), "test1 should be current"); Assert.AreNotEqual(test2, ts.Get <object>(), "test1 should be current"); Assert.AreNotEqual(test3, ts.Get <object>(), "test1 should be current"); }
public void TurnContextStateCollection_PopPushKey() { var ts = new TurnContextStateCollection(); var test1 = new object(); var test2 = new object(); var test3 = new object(); var key = "test"; Assert.IsNull(ts.Pop <object>(key), "pop with no pushes is null"); ts.Push(key, test1); ts.Push(key, test2); ts.Push(key, test3); // test3 should be current object Assert.AreNotEqual(test1, ts.Get <object>(key), "test3 should be current"); Assert.AreNotEqual(test2, ts.Get <object>(key), "test3 should be current"); Assert.AreEqual(test3, ts.Get <object>(key), "test3 should be current"); Assert.AreEqual(test2, ts.Pop <object>(key), "pop should return test2"); Assert.AreNotEqual(test1, ts.Get <object>(key), "test2 should be current"); Assert.AreEqual(test2, ts.Get <object>(key), "test2 should be current"); Assert.AreNotEqual(test3, ts.Get <object>(key), "test2 should be current"); Assert.AreEqual(test1, ts.Pop <object>(key), "pop should return test1"); Assert.AreEqual(test1, ts.Get <object>(key), "test1 should be current"); Assert.AreNotEqual(test2, ts.Get <object>(key), "test1 should be current"); Assert.AreNotEqual(test3, ts.Get <object>(key), "test1 should be current"); Assert.AreEqual(null, ts.Pop <object>(key), "pop should return null"); Assert.IsNull(ts.Get <object>(key), "null should be current"); Assert.AreEqual(null, ts.Pop <object>(key), "pop with nothing should be null"); Assert.IsNull(ts.Get <object>(key), "null should be current"); }