Exemple #1
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);
        }