Example #1
0
        public void СategorieMemoryCacheSQLMonitorTest()
        {
            string connectionStrings = ConfigurationManager.ConnectionStrings["Northwind"].ConnectionString;
            string commandString     = "select CategoryID, CategoryName From dbo.Categories";

            DataMemoryCache dataMemoryCache = new DataMemoryCache("Сategorie_");
            DataManager     dataManager     = new DataManager(dataMemoryCache, connectionStrings, commandString);

            var categories         = dataManager.GetData <Category>();
            var categoriesFromCash = dataMemoryCache.Get <Category>(_user);

            Assert.IsTrue(categories.Any());
            Assert.AreEqual(categories, categoriesFromCash);

            using (SqlConnection connection = new SqlConnection(connectionStrings))
                using (var command = connection.CreateCommand())
                {
                    connection.Open();
                    command.CommandText = "update dbo.Categories set CategoryName = 'MyCat88' where CategoryID = 11";
                    command.ExecuteNonQuery();
                }

            Thread.Sleep(1000);
            categoriesFromCash = dataMemoryCache.Get <Category>(_user);
            Assert.IsNull(categoriesFromCash);
        }
Example #2
0
        public void СategorieMemoryCacheTimeoutTest()
        {
            DataMemoryCache dataMemoryCache = new DataMemoryCache("Сategorie_");
            DataManager     dataManager     = new DataManager(dataMemoryCache);

            var categories         = dataManager.GetData <Category>();
            var categoriesFromCash = dataMemoryCache.Get <Category>(_user);

            Assert.IsTrue(categories.Any());
            Assert.AreEqual(categories, categoriesFromCash);

            Thread.Sleep(7000);
            Assert.IsNull(dataMemoryCache.Get <Category>(_user));
        }
Example #3
0
        public void EmployeeMemoryCacheTest()
        {
            DataMemoryCache dataMemoryCache = new DataMemoryCache("Employee_");
            DataManager     dataManager     = new DataManager(dataMemoryCache);

            var employees         = dataManager.GetData <Employee>();
            var employeesFromCash = dataMemoryCache.Get <Employee>(_user);

            Assert.IsTrue(employees.Any());
            Assert.AreEqual(employees, employeesFromCash);
        }