public void CachedObjectsOfDifferentType()
        {
            HttpSessionStateBase session = mocks.HtmlHelper.ViewContext.HttpContext.Session;
            GeneralExpense       item1   = NakedObjectsFramework.Persistor.Instances <GeneralExpense>().OrderBy(c => c.Id).First();
            GeneralExpense       item2   = NakedObjectsFramework.Persistor.Instances <GeneralExpense>().OrderByDescending(c => c.Id).First();

            session.AddObjectToSession(Surface, "key1", item1);
            session.AddObjectToSession(Surface, "key2", item2);
            Assert.IsNull(session.GetObjectFromSession <Claim>(Surface, "key1"));
            Assert.IsNull(session.GetObjectFromSession <Claim>(Surface, "key1"));
        }
        public void CachedObjectsOfBaseType()
        {
            HttpSessionStateBase session = mocks.HtmlHelper.ViewContext.HttpContext.Session;
            GeneralExpense       item1   = NakedObjectsFramework.Persistor.Instances <GeneralExpense>().OrderBy(c => c.Id).First();
            GeneralExpense       item2   = NakedObjectsFramework.Persistor.Instances <GeneralExpense>().OrderByDescending(c => c.Id).First();

            session.AddObjectToSession(NakedObjectsFramework, "key1", item1);
            session.AddObjectToSession(NakedObjectsFramework, "key2", item2);
            Assert.AreEqual(item1, session.GetObjectFromSession <GeneralExpense>(NakedObjectsFramework, "key1"));
            Assert.AreEqual(item2, session.GetObjectFromSession <AbstractExpenseItem>(NakedObjectsFramework, "key2"));
        }
        public void AddTransientToSession()
        {
            HttpSessionStateBase session = mocks.HtmlHelper.ViewContext.HttpContext.Session;
            var claim = NakedObjectsFramework.LifecycleManager.CreateInstance((IObjectSpec)NakedObjectsFramework.MetamodelManager.GetSpecification(typeof(Claim))).GetDomainObject <Claim>();

            session.AddObjectToSession(Surface, "key1", claim);
            Assert.AreSame(claim, session.GetObjectFromSession <Claim>(Surface, "key1"));
        }
        public void AddPersistentToSession()
        {
            HttpSessionStateBase session = mocks.HtmlHelper.ViewContext.HttpContext.Session;
            Claim claim = NakedObjectsFramework.Persistor.Instances <Claim>().First();

            session.AddObjectToSession(Surface, "key1", claim);
            Assert.AreSame(claim, session.GetObjectFromSession <Claim>(Surface, "key1"));
        }
        public void RemoveObjectFromCache()
        {
            HttpSessionStateBase session = mocks.HtmlHelper.ViewContext.HttpContext.Session;
            Claim claim = NakedObjectsFramework.Persistor.Instances <Claim>().First();

            session.AddObjectToSession(NakedObjectsFramework, "key1", claim);
            Assert.AreSame(claim, session.GetObjectFromSession <Claim>(NakedObjectsFramework, "key1"));
            session.ClearFromSession("key1");
            Assert.IsNull(session.GetObjectFromSession <Claim>(NakedObjectsFramework, "key1"));
        }