コード例 #1
0
            public void TestUnique()
            {
                var storage       = new SessionDataStorage();
                var firstSession  = storage.CreateSession();
                var secondSession = storage.CreateSession();

                Assert.AreNotSame(firstSession, secondSession);
                Assert.AreNotEqual(firstSession, secondSession);
            }
コード例 #2
0
            public void TestNotNull()
            {
                var storage = new SessionDataStorage();
                var session = storage.CreateSession();

                Assert.NotNull(session);
            }
コード例 #3
0
            public void TestException()
            {
                var storage = new SessionDataStorage();
                var session = storage.CreateSession();
                var newKey  = new Guid();

                Assert.Throws <KeyNotFoundException>(() => storage.GetSession(newKey));
            }
コード例 #4
0
            public void TestNotNull()
            {
                var storage          = new SessionDataStorage();
                var session          = storage.CreateSession();
                var retrievedSession = storage.GetSession(session.Id);

                Assert.NotNull(retrievedSession);
            }
コード例 #5
0
            public void TestRemaining()
            {
                var storage = new SessionDataStorage();
                var session = storage.CreateSession();

                storage.Cleanup();
                var retrievedSession = storage.GetSession(session.Id);

                Assert.AreSame(session, retrievedSession);
            }
コード例 #6
0
            public void TestGetString()
            {
                var storage = new SessionDataStorage();

                for (var i = 0; i < 3; i++)
                {
                    storage.CreateSession();
                }

                var session = storage.CreateSession();

                for (var i = 0; i < 7; i++)
                {
                    storage.CreateSession();
                }

                var retrievedSession = storage.GetSession(session.Id.ToString());

                Assert.AreSame(session, retrievedSession);
            }
コード例 #7
0
            public void TestRemoval()
            {
                var storage = new SessionDataStorage();
                var session = storage.CreateSession();

                session.Expiration = DateTime.Now.Subtract(new TimeSpan(1));
                var retrievedSession = storage.GetSession(session.Id);

                Assert.AreSame(session, retrievedSession);
                storage.Cleanup();
                Assert.Throws <KeyNotFoundException>(() => storage.GetSession(session.Id));
            }