コード例 #1
0
        public void CustomerRedisCacheSQLMonitorTest()
        {
            string connectionStrings = ConfigurationManager.ConnectionStrings["Northwind"].ConnectionString;
            string commandString     = "select CustomerID, CompanyName From dbo.Customers";

            DataRedisCache <Customer> dataRedisCache = new DataRedisCache <Customer>("localhost", "Customer_");
            DataManager dataManager = new DataManager(dataRedisCache, connectionStrings, commandString);

            var customers         = dataManager.GetData <Customer>();
            var customersFromCash = dataRedisCache.Get <Customer>(_user);

            Assert.IsTrue(customers.Any());
            Assert.IsTrue(customersFromCash.Any());
            Assert.IsTrue(customers.Count().Equals(customersFromCash.Count()));

            using (SqlConnection connection = new SqlConnection(connectionStrings))
                using (var command = connection.CreateCommand())
                {
                    connection.Open();
                    command.CommandText = "update dbo.Customers set CompanyName = 'Wolski  Zajazd+' where CustomerID = 'WOLZA'";
                    command.ExecuteNonQuery();
                }

            Thread.Sleep(1000);
            customersFromCash = dataRedisCache.Get <Customer>(_user);
            Assert.IsNull(customersFromCash);
        }
コード例 #2
0
        public void СategorieRedisCacheTimeoutTest()
        {
            DataRedisCache <Category> dataRedisCache = new DataRedisCache <Category>("localhost", "Сategorie_");
            DataManager dataManager = new DataManager(dataRedisCache);

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

            Assert.IsTrue(categories.Any());
            Assert.IsTrue(categoriesFromCash.Any());
            Assert.IsTrue(categories.Count().Equals(categoriesFromCash.Count()));

            Thread.Sleep(7000);
            Assert.IsNull(dataRedisCache.Get <Category>(_user));
        }