Exemplo n.º 1
0
        public void GetCacheTests()
        {
            string key       = "c2"; // rediste olan bir key ile get yaparken
            var    resultGet = cacheController.GetCache(key);

            Assert.IsNotNull(resultGet);

            key = "c3"; // rediste olmayan bir key ile get yaparken
            var ex = Assert.ThrowsException <Exception>(() => cacheController.GetCache(key));

            Assert.AreEqual("Key not found", ex.Message);

            key = ""; // key deðeri olmadan redise ulaþmaya çalýþtýðýnda
            ex  = Assert.ThrowsException <Exception>(() => cacheController.GetCache(key));
            Assert.AreEqual("Key cannot be null", ex.Message);
        }
Exemplo n.º 2
0
        public BaseAPI()
        {
            var code = HttpContext.Current.Request.Cookies["CodeLogin"];

            if (code != null)
            {
                var key = $"DNLoginAPIGetUserItemByCode_{code.Value}";
                if (Cache.KeyExistsCache(key))
                {
                    UserItem = (DNUserItem)Cache.GetCache(key);
                    var keyCache = "ltsPermissionrole" + code; // ltsPermissionProductAttribute
                    if (HttpRuntime.Cache[keyCache] == null)
                    {
                        HttpRuntime.Cache[keyCache] = CheckAdmin(UserItem.listRole);
                    }
                    IsAdmin = (bool)HttpRuntime.Cache[keyCache];
                }
            }
        }