Commits

Mike Podonyi  committed d6f7a69

implement NoCache, more Test for PropertyDicovery

  • Participants
  • Parent commits 11dd3cc

Comments (0)

Files changed (6)

File src/Empi.Camino.Test/DataStoreFactoryTest.cs

 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Microsoft.VisualStudio.TestTools.UnitTesting.Web;
 using System.Web;
+using Empi.Camino.Configuration;
 namespace Empi.Camino.Test
 {
     
         {
             GetDataStoreTestInternal(DataStoreFactory.GetCacheDataStore);
         }
+
+        /// <summary>
+        ///A test for GetDataStore Cache disabled
+        ///</summary>
+        [TestMethod()]
+        [HostType("ASP.NET")]
+        [DeploymentItem("Empi.Camino.dll")]
+        public void GetNoCacheDataStoreTest()
+        {
+            RetailerSettings.GetRetailerSettings.EnableCache = false;
+            GetDataStoreTestInternal(DataStoreFactory.GetCacheDataStore);
+        }
     }
 }

File src/Empi.Camino.Test/SettingsTest.cs

 using Empi.Camino.Configuration;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using System.Configuration;
+using System;
 
 namespace Empi.Camino.Test
 {
             [DefaultSettingValue("dummyValue")]
             [System.ComponentModel.ReadOnly(true)]
             [SettingsSerializeAsAttribute(SettingsSerializeAs.String)]
+            [Fake]
             internal string Dummytest
             {
                 get { return (string)this["Retailer-Dummytest"]; }
                 set { this["Retailer-Dummytest"] = value; }
             }
-        }
+        } 
+        
+        [AttributeUsage(AttributeTargets.Property)]
+        private class FakeAttribute: Attribute
+        {}
+
 
 		/// <summary>
 		///A test for MyDbId
 			Assert.AreEqual<string>("sdafgreg", actual);
 		}
 
-        ///// <summary>
-        /////A test for Powertest
-        /////</summary>
-        //[TestMethod()]
-        //[DeploymentItem("Empi.Camino.dll")]
-        //public void PowertestTest()
-        //{
-        //    RetailerSettings_Accessor target = RetailerSettings_Accessor.GetRetailerSettings; // TODO: Initialize to an appropriate value
-        //    string expected = "Mike"; // TODO: Initialize to an appropriate value
-        //    string actual;
-        //    target.Powertest = expected;
-        //    actual = target.Powertest;
-        //    Assert.AreEqual(expected, actual);
-        //    //Assert.Inconclusive("Verify the correctness of this test method.");
-        //}
-
         /// <summary>
         ///A test for MyDbState
         ///</summary>
         }
 
         /// <summary>
+        ///A test for MyDbState
+        ///</summary>
+        [TestMethod()]
+        [DeploymentItem("Empi.Camino.dll")]
+        public void EnableCacheTest()
+        {
+            Assert.IsTrue(TestSettings.GetTestSettings.EnableCache);
+
+            TestSettings.GetTestSettings.EnableCache = false;
+
+            Assert.IsFalse(TestSettings.GetTestSettings.EnableCache);
+
+            TestSettings.GetTestSettings.EnableCache = true;
+
+            Assert.IsTrue(TestSettings.GetTestSettings.EnableCache);
+        }
+
+
+        /// <summary>
         ///A test for GetRetailerSettings
         ///</summary>
         [TestMethod()]
 
             Assert.AreEqual(typeof(string), testProperty.PropertyType);
 
+            Assert.IsTrue(testProperty.ThrowOnErrorDeserializing);
+
+            Assert.IsTrue(testProperty.ThrowOnErrorSerializing);
+
+            Assert.Equals(testProperty.SerializeAs, SettingsSerializeAs.String);
+
+            Assert.IsInstanceOfType(testProperty.Provider, typeof(CaminoSettingsProvider));
+
+            Assert.IsInstanceOfType(testProperty.Attributes[typeof(FakeAttribute)], typeof(FakeAttribute));
+
+
             //MP: more Tests here
         }
 	}

File src/Empi.Camino/Configuration/Settings.cs

 			}
 		}
 
-        internal bool IsCachingEnabled
+        [CaminoSetting("Common-Cache-Enabled")]
+        [DefaultSettingValue("true")]
+        internal bool EnableCache
         {
             get
+            { //MP:test it
+#if DEBUG
+                return true;
+#else
+                return (bool) this["Common-Cache-Enabled"];
+#endif
+            }
+            set
             {
-                
-                return true; //MP: Changes something here
+                this["Common-Cache-Enabled"] = value;
             }
         }
 

File src/Empi.Camino/Empi.Camino.csproj

     <Compile Include="Web\Data\IDataStateWrapper.cs" />
     <Compile Include="Web\Data\IDataStore.cs" />
     <Compile Include="Web\Data\ItemStateWrapper.cs" />
+    <Compile Include="Web\Data\NoCacheStateWrapper.cs" />
     <Compile Include="Web\Data\SessionStateWrapper.cs" />
   </ItemGroup>
   <ItemGroup>

File src/Empi.Camino/Utils.cs

                 string retVal = mapping[match.Groups["identifier"].Value];
                 if (string.IsNullOrEmpty(retVal) && throwException)
                 {
-                    throw new KeyErrorException(); // TODO: more Infos
+                    throw new KeyErrorException(); //MP: more Infos
                 }
                 else if (string.IsNullOrEmpty(retVal))
                 {

File src/Empi.Camino/Web/Data/DataStoreFactory.cs

                     else
                         return new DataStore(new ApplicationStateWrapper());
                 case DataStoreType.CacheDataStore:
-                    if (RetailerSettings.GetRetailerSettings.IsCachingEnabled)
+                    if (RetailerSettings.GetRetailerSettings.EnableCache)
                     {
                         if (!Utils.IsWebApplication)
                             return new DataStore(_CacheStateMock);
                             return new DataStore(new CacheStateWrapper());
                     }
                     else
-                        return new DataStore(new CacheStateWrapper());  //MP: implement this
+                        return new DataStore(new NoCacheStateWrapper());  
                 case DataStoreType.ItemsDataStore:
                     if (!Utils.IsWebApplication)
                         return new DataStore(_ItemsStateMock);