Exemple #1
0
        public void DeleteSessionAppSpecific()
        {
            // create two sessions of different appId
            // it should delete only 1
            CreateSessionData(1, DateTime.Now.Subtract(new TimeSpan(1, 10, 0)));
            CreateSessionData(2, DateTime.Now.Subtract(new TimeSpan(1, 0, 0)));

            MySqlSessionStateStore session = new MySqlSessionStateStore();

            NameValueCollection config = new NameValueCollection();

            config.Add("connectionStringName", "LocalMySqlServer");
            config.Add("applicationName", "/");
            config.Add("enableExpireCallback", "false");
            session.Initialize("SessionTests", config);

            int i = 0;

            while (CountSessions() == 2 && (i < 10))
            {
                Thread.Sleep(500);
                i++;
            }

            session.Dispose();
            Assert.Equal(1, CountSessions());
        }
Exemple #2
0
        private void SetSessionItemExpiredCallback(bool includeCallback)
        {
            _evt     = new AutoResetEvent(false);
            calledId = null;

            CreateSessionData(1, DateTime.Now.Subtract(new TimeSpan(1, 0, 0)));

            MySqlSessionStateStore session = new MySqlSessionStateStore();

            NameValueCollection config = new NameValueCollection();

            config.Add("connectionStringName", "LocalMySqlServer");
            config.Add("applicationName", "/");
            config.Add("enableExpireCallback", includeCallback ? "true" : "false");
            session.Initialize("SessionProvTest", config);
            if (includeCallback)
            {
                session.SetItemExpireCallback(expireCallback);
            }
            Thread.Sleep(1000);
            session.Dispose();
        }