public void SlidingExpiryTimeDoesntExpire()
 {
     TestClock clock = new TestClock {Now = DateTime.Now};
     InMemorySessionCache cache = new InMemorySessionCache(clock);
     cache.Duration = 1;
     cache.ExpiryMode = SessionExpiryMode.Sliding;
     string sessionToken = cache.AddToCache("johndoe");
     clock.TimePasses(TimeSpan.FromSeconds(31));
     string userName = cache.RetrieveFromCache(sessionToken);
     Assert.AreEqual("johndoe", userName);
     clock.TimePasses(TimeSpan.FromSeconds(31));
     userName = cache.RetrieveFromCache(sessionToken);
     Assert.AreEqual("johndoe", userName);
 }
 public void RemoveFromCacheRemovesSession()
 {
     InMemorySessionCache cache = new InMemorySessionCache();
     string sessionToken = cache.AddToCache("johndoe");
     cache.RemoveFromCache(sessionToken);
     string userName = cache.RetrieveFromCache(sessionToken);
     Assert.IsNull(userName);
 }
 public void AddToCacheReturnsGuid()
 {
     InMemorySessionCache cache = new InMemorySessionCache();
     string sessionToken = cache.AddToCache("johndoe");
     string userName = cache.RetrieveFromCache(sessionToken);
     Guid sessionGuid = new Guid(sessionToken);
     Assert.AreEqual("johndoe", userName);
 }
 public void FixedExpiryTimeExpires()
 {
     TestClock clock = new TestClock {Now = DateTime.Now};
     InMemorySessionCache cache = new InMemorySessionCache(clock);
     cache.Duration = 1;
     cache.ExpiryMode = SessionExpiryMode.Fixed;
     string sessionToken = cache.AddToCache("johndoe");
     clock.TimePasses(TimeSpan.FromSeconds(61));
     string userName = cache.RetrieveFromCache(sessionToken);
     Assert.IsNull(userName);
 }