public void SessionService_SetCookie_Success() { byte[] bytes = null; SessionContainerFake fakeObject = new SessionContainerFake { TestPropertyInt = 25, TestPropertyString = "blah" }; _session .When(x => x.TryGetValue("fakesession", out bytes)) .Do(x => x[1] = System.Text.Encoding.ASCII.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(fakeObject))); _target.Set("fakesession", fakeObject); SessionContainerFake cachedObject = _target.Get <SessionContainerFake>("fakesession"); Assert.IsNotNull(cachedObject); Assert.AreEqual(fakeObject.TestPropertyInt, cachedObject.TestPropertyInt); Assert.AreEqual(fakeObject.TestPropertyString, cachedObject.TestPropertyString); }
public void SessionService_GetCookie_Fail() { SessionContainerFake cachedCookie = _target.Get <SessionContainerFake>("fakesession"); Assert.IsNull(cachedCookie); }