public void TurnContextStateCollection_SetNullKey() { var ts = new TurnContextStateCollection(); ts.Set(null, new object()); Assert.Fail("Should Fail due to null key"); }
public void TurnContextStateCollection_Set() { var ts = new TurnContextStateCollection(); var test = new object(); var test2 = new object(); ts.Set("test", test); ts.Set(test2); Assert.AreEqual(test, ts.Get <object>("test")); Assert.AreEqual(test2, ts.Get <object>()); Assert.AreNotEqual(test, ts.Get <object>()); ts.Set <object>("test", null); Assert.IsNull(ts.Get <object>("test")); Assert.AreEqual(test2, ts.Get <object>()); ts.Set <object>(null); Assert.IsNull(ts.Get <object>()); }
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_SetNullKey() { var ts = new TurnContextStateCollection(); Assert.Throws <ArgumentNullException>(() => ts.Set(null, new object())); }