Exemple #1
0
        /// <summary>
        /// <see cref="M:Microsoft.Samples.NLayerApp.Infrastructure.CrossCutting.Caching.Remove"/>
        /// </summary>
        /// <param name="cacheKey"><see cref="M:Microsoft.Samples.NLayerApp.Infrastructure.CrossCutting.Caching.Remove"/></param>
        public bool Remove(CacheKey cacheKey)
        {
            if (cacheKey != null)
            {
                DataCache defaultCache = _cacheFactory.GetDefaultCache();

                return(defaultCache.Remove(cacheKey.GetCacheKey()));
            }
            else
            {
                return(false);
            }
        }
        public void CacheKey_CheckVaryParamsFromNullAnonimousType_Test()
        {
            //arrange
            string keyName    = "fakeName";
            object varyParams = null;

            //act
            CacheKey key = new CacheKey(keyName, varyParams);

            string result = key.GetCacheKey();

            //assert
            Assert.AreEqual(result, string.Format("{0}#", keyName));
        }
        public void CacheKey_CheckVaryParamsFromAnonimousType_Test()
        {
            //arrange
            string keyName    = "fakeName";
            object varyParams = new { PropertyA = "ParamA", PropertyB = 2 };

            //act
            CacheKey key = new CacheKey(keyName, varyParams);

            string result = key.GetCacheKey();

            string expected = string.Format("{0}#{1};{2};{3};{4}", keyName, "PropertyA", "ParamA", "PropertyB", "2");

            //assert
            Assert.AreEqual(result, expected);
        }