Ejemplo n.º 1
0
        private void TestBasicOptions()
        {
            const string fName = "test_fname";
            const string lName = "test_lname";

            var store = new SessionStore();

            var key = Guid.NewGuid().ToString();

            store.Add(Category, key, new TestData()
            {
                FirstName = fName,
                LastName  = lName
            });

            var storedVal = store.Get <TestData>(Category, key);

            Assert.IsNotNull(storedVal);
            Assert.IsTrue(fName.Equals(storedVal.FirstName), "First name did not match.");
            Assert.IsTrue(lName.Equals(storedVal.LastName), "Last name did not match.");

            store.Remove(Category, key);

            storedVal = store.Get <TestData>(Category, key);

            Assert.IsNull(storedVal);
        }
Ejemplo n.º 2
0
        public IHttpActionResult RemoveSession(string sessionId)
        {
            var session = GetSession(sessionId);

            session.KillApplication();

            SessionStore.Remove(new Guid(sessionId));
            return(Ok($"Session {session.SessionId} successfully removed"));
        }
Ejemplo n.º 3
0
        public async Task LogOut()
        {
            var request = new RequestLogOut();

            SendService.SendRequestAsync(request).ConfigureAwait(false);

            await SessionStore.Remove().ConfigureAwait(false);

            ClientSettings.Session.AuthKey = null;
        }
        /// <summary>
        /// Disposes the session associated with the specified session key.
        /// </summary>
        /// <param name="sessionKey">The session key.</param>
        public void DisposeSession(Guid sessionKey)
        {
            lock (syncRoot)
            {
                if (SessionStore.ContainsKey(sessionKey))
                {
                    // Dispose session if it exists
                    if (SessionStore[sessionKey] != null)
                    {
                        SessionStore[sessionKey].Dispose();
                    }

                    SessionStore.Remove(sessionKey);
                }
            }
        }
Ejemplo n.º 5
0
        public void TestAsyncAdd()
        {
            const string fName = "test_fname";
            const string lName = "test_lname";

            var store = new SessionStore();

            var key = Guid.NewGuid().ToString();

            store.AddAsync(Category, key, new TestData()
            {
                FirstName = fName,
                LastName  = lName
            });



            TestData storedVal = null;

            WaitTillCondition(() =>
            {
                storedVal = store.Get <TestData>(Category, key);

                if (storedVal == null)
                {
                    return(false);
                }
                return(true);
            }, 3000);


            Assert.IsNotNull(storedVal, "The stored value could not be retrieved, either the async add did not work or retrieve failed within the given time frame.");
            Assert.IsTrue(fName.Equals(storedVal.FirstName), "First name did not match.");
            Assert.IsTrue(lName.Equals(storedVal.LastName), "Last name did not match.");

            store.Remove(Category, key);

            storedVal = store.Get <TestData>(Category, key);

            Assert.IsNull(storedVal);
        }