public void AddToCacheReturnsGuid()
        {
            FileBasedSessionCache cache = new FileBasedSessionCache();

            cache.StoreLocation = cacheLocation;
            string sessionToken = cache.AddToCache("johndoe");
            string userName     = cache.RetrieveFromCache(sessionToken);
            Guid   sessionGuid  = new Guid(sessionToken);

            Assert.AreEqual("johndoe", userName);
        }
        public void RemoveFromCacheRemovesSession()
        {
            FileBasedSessionCache cache = new FileBasedSessionCache();

            cache.StoreLocation = cacheLocation;
            string sessionToken = cache.AddToCache("johndoe");

            cache.RemoveFromCache(sessionToken);
            string userName = cache.RetrieveFromCache(sessionToken);

            Assert.IsNull(userName);
        }
        public void NonStoredValueReturnsNull()
        {
            FileBasedSessionCache cache = new FileBasedSessionCache();

            cache.StoreLocation = cacheLocation;
            string sessionToken = cache.AddToCache("johndoe");
            string key          = "An item";

            object result = cache.RetrieveSessionValue(sessionToken, key);

            Assert.IsNull(result);
        }
        public void StoreSessionValueIsStored()
        {
            FileBasedSessionCache cache = new FileBasedSessionCache();

            cache.StoreLocation = cacheLocation;
            string sessionToken = cache.AddToCache("johndoe");
            string key          = "An item";
            object value        = Guid.NewGuid();

            cache.StoreSessionValue(sessionToken, key, value);
            object result = cache.RetrieveSessionValue(sessionToken, key);

            Assert.AreEqual(value, result);
        }
        public void InitialiseWithSessions()
        {
            // Generate a cache
            FileBasedSessionCache cache = new FileBasedSessionCache();

            cache.StoreLocation = cacheLocation;
            cache.Initialise();
            string sessionToken = cache.AddToCache("johndoe");
            string key          = "An item";
            object value        = Guid.NewGuid();

            cache.StoreSessionValue(sessionToken, key, value);

            // Reload it
            cache = new FileBasedSessionCache();
            cache.StoreLocation = cacheLocation;
            cache.Initialise();
            object result = cache.RetrieveSessionValue(sessionToken, key);

            Assert.AreEqual(value.ToString(), result);
        }