public void PersistSessionTest()
        {
            // création des objets réponses Request et Response pour le HtppContext
            HttpRequest request         = new HttpRequest("myFileName", "http://urlQuelconque", "BBQ=OUI");
            Encoding    requestEncoding = Encoding.GetEncoding("ISO-8859-1");

            request.ContentEncoding = requestEncoding;

            // generate cookie
            AspSessionPersistence persist = new AspSessionPersistence();
            string     key    = persist.GenerateSessionId();
            HttpCookie cookie = new HttpCookie(AppSettingsManager.CookieName);

            cookie.Values.Add(AppSettingsManager.CookieKey, key);
            request.Cookies.Add(cookie);
            Stream       str      = Stream.Null;
            StreamWriter sw       = new StreamWriter(str);
            HttpResponse response = new HttpResponse(sw);
            HttpContext  context  = new HttpContext(request, response);

            // Create AspSession
            AspSessionPersistenceTest pt = new AspSessionPersistenceTest();
            AspSession asp_session       = new AspSession(context);

            pt.CreateSessionState(asp_session.Contents);
            asp_session.PersistSession();
            var sessloaded = persist.LoadSession(key);

            foreach (var item in asp_session.Contents)
            {
                Assert.AreEqual(item.Value, sessloaded[item.Key]);
            }
        }
Exemple #2
0
        public void DeleteSessionTest()
        {
            PartitionResolver     pr      = new PartitionResolver();
            AspSessionPersistence persist = new AspSessionPersistence();
            var sessionid = persist.GenerateSessionId();

            persist.DeleteSession(sessionid);
            var sessionSaved = persist.LoadSession(sessionid);

            Assert.IsNull(sessionSaved, null);
        }
Exemple #3
0
        public void RefreshSessionTest()
        {
            PartitionResolver     pr      = new PartitionResolver();
            AspSessionPersistence persist = new AspSessionPersistence();
            AspSessionContents    st      = new AspSessionContents();

            this.CreateSessionState(st);
            var sessionid = persist.GenerateSessionId();

            persist.SaveSession(sessionid, st, 20);
            persist.RefreshSession(sessionid);
            var sessionSaved = persist.LoadSession(sessionid);

            Assert.IsNotNull(sessionSaved);
        }
Exemple #4
0
        public void SaveSessionTest()
        {
            PartitionResolver     pr      = new PartitionResolver();
            AspSessionPersistence persist = new AspSessionPersistence();
            AspSessionContents    st      = new AspSessionContents();

            this.CreateSessionState(st);
            var sessionid = persist.GenerateSessionId();

            persist.SaveSession(sessionid, st, 20);
            var sessionSaved = persist.LoadSession(sessionid);

            foreach (var item in sessionSaved)
            {
                Assert.AreEqual(item.Value, st[item.Key]);
            }
        }