public void TestRemoveSearchRoute()
        {
            Configuration config = new Configuration();
            config.AutoCompleteRoute = "testRoute";
            config.MaxResults = 100;
            config.RecordIndentifier = "code";
            config.UpdateURL = "http://urltoupdatefrom";

            BasicRedisClientManager pooledClientManager = RedisClientManager.get();
            using (IRedisClient redisClient = pooledClientManager.GetClient())
            {

                IRedisTypedClient<Configuration> redis = redisClient.As<Configuration>();
                redis.SetEntry(config.AutoCompleteRoute, config);
            }

            InfinityEngine.Business.InfinityEngine infinityEngine = new InfinityEngine.Business.InfinityEngine();
            infinityEngine.RemoveSearchRoute(config.AutoCompleteRoute);

            using (IRedisClient redisClient = pooledClientManager.GetClient())
            {
                Configuration redisConfig = redisClient.Get<Configuration>(config.AutoCompleteRoute);
                Assert.IsNull(redisConfig);
            }
        }
        public string SearchTheRouteWithLimit(string routeName, string searchParam, string resultLimit)
        {
            List<Dictionary<string, string>> results = new List<Dictionary<string, string>>();

            InfinityEngine.Business.InfinityEngine infinityEngine = new InfinityEngine.Business.InfinityEngine();
            results = infinityEngine.SearchAutoCompleteCache(routeName, searchParam, int.Parse(resultLimit));
            return JsonConvert.SerializeObject(results);
        }
        public bool ConfigureSearchRoute(Configuration newConfig)
        {
            bool success = false;

            InfinityEngine.Business.InfinityEngine infinityEngine = new InfinityEngine.Business.InfinityEngine();
            success = infinityEngine.SaveSearchRoute(newConfig);

            return success;
        }
 public bool UpdateSearchRoute(string routeName, string updateKey)
 {
     bool success = false;
     InfinityEngine.Business.InfinityEngine infinityEngine = new InfinityEngine.Business.InfinityEngine();
     success = infinityEngine.UpdateFullCache(routeName, updateKey);
     if (success)
     {
         success = false;
         infinityEngine.UpdateAutoCompleteCache(routeName);
         success = true;
     }
     return success;
 }
        public void TestSaveNewSearchRoute()
        {
            Configuration config = new Configuration();
            config.AutoCompleteRoute = "testRoute";
            config.MaxResults = 100;
            config.RecordIndentifier = "code";
            config.UpdateURL = "http://urltoupdatefrom";

            InfinityEngine.Business.InfinityEngine infinityEngine = new InfinityEngine.Business.InfinityEngine();
            infinityEngine.SaveSearchRoute(config);

            BasicRedisClientManager pooledClientManager = RedisClientManager.get();
            using (IRedisClient redisClient = pooledClientManager.GetClient())
            {
                Configuration redisConfig = redisClient.Get<Configuration>(config.AutoCompleteRoute);
                Assert.IsTrue(redisConfig.AutoCompleteRoute.Equals(config.AutoCompleteRoute));
            }
        }
        public void TestSearchAutoCompleteCache()
        {
            Configuration config = new Configuration();
            config.AutoCompleteRoute = "testRoute";
            config.MaxResults = 100;
            config.RecordIndentifier = "Code";
            config.UpdateURL = "http://urltoupdatefrom";

            BasicRedisClientManager pooledClientManager = RedisClientManager.get();
            using (IRedisClient redisClient = pooledClientManager.GetClient())
            {
                IRedisTypedClient<Configuration> redis = redisClient.As<Configuration>();
                redis.SetEntry(config.AutoCompleteRoute, config);

                Dictionary<string,string> dataObj = new Dictionary<string,string>();
                dataObj["Code"] = "foo";
                dataObj["Desc"] = "bar";
                redisClient.Lists["cacheIndex:" + config.AutoCompleteRoute].Add(dataObj[config.RecordIndentifier]);
                redisClient.SetEntry("fullCache:" + config.AutoCompleteRoute + ":" + dataObj[config.RecordIndentifier], JsonConvert.SerializeObject(dataObj));

                redisClient.AddItemToSortedSet(config.AutoCompleteRoute + ":autocomplete:b", "foo", 0);
                redisClient.AddItemToSortedSet(config.AutoCompleteRoute + ":autocomplete:ba", "foo", 0);
                redisClient.AddItemToSortedSet(config.AutoCompleteRoute + ":autocomplete:bar", "foo", 0);
                redisClient.AddItemToSortedSet(config.AutoCompleteRoute + ":autocomplete:bar*", "foo", 0);
            }

            InfinityEngine.Business.InfinityEngine infinityEngine = new InfinityEngine.Business.InfinityEngine();
            List<Dictionary<string, string>> results = infinityEngine.SearchAutoCompleteCache(config.AutoCompleteRoute, "ba", 50);

            if (results.Count > 0)
            {
                Dictionary<string, string> firstResult = results[0];
                Assert.IsTrue(firstResult["Code"].Equals("foo") &&
                              firstResult["Desc"].Equals("bar"));
            }
            else
            {
                Assert.IsTrue(false);
            }
        }
        public void TestUpdateFullCachePartial()
        {
            Configuration config = new Configuration();
            config.AutoCompleteRoute = "testRoute";
            config.MaxResults = 100;
            config.RecordIndentifier = "id";
            config.UpdateURL = "http://localhost:8124/names";

            BasicRedisClientManager pooledClientManager = RedisClientManager.get();
            using (IRedisClient redisClient = pooledClientManager.GetClient())
            {
                IRedisTypedClient<Configuration> redis = redisClient.As<Configuration>();
                redis.SetEntry(config.AutoCompleteRoute, config);
            }

            InfinityEngine.Business.InfinityEngine infinityEngine = new InfinityEngine.Business.InfinityEngine();
            infinityEngine.UpdateFullCache(config.AutoCompleteRoute);
            infinityEngine.UpdateFullCache(config.AutoCompleteRoute, "stephen");

            using (IRedisClient redisClient = pooledClientManager.GetClient())
            {
                string data = redisClient.GetValue("fullCache:" + config.AutoCompleteRoute + ":567");
                Dictionary<string, string> dataDic = JsonConvert.DeserializeObject<Dictionary<string, string>>(data);
                Assert.IsTrue(dataDic["lastname"].Equals("smith"));
            }
        }
        public void TestUpdateFullCacheAll()
        {
            Configuration config = new Configuration();
            config.AutoCompleteRoute = "testRoute";
            config.MaxResults = 100;
            config.RecordIndentifier = "id";
            config.UpdateURL = "http://localhost:8124/names";

            BasicRedisClientManager pooledClientManager = RedisClientManager.get();
            using (IRedisClient redisClient = pooledClientManager.GetClient())
            {
                IRedisTypedClient<Configuration> redis = redisClient.As<Configuration>();
                redis.SetEntry(config.AutoCompleteRoute, config);
            }

            InfinityEngine.Business.InfinityEngine infinityEngine = new InfinityEngine.Business.InfinityEngine();
            infinityEngine.UpdateFullCache(config.AutoCompleteRoute);

            using (IRedisClient redisClient = pooledClientManager.GetClient())
            {
                string data = redisClient.GetValue("fullCache:" + config.AutoCompleteRoute + ":123");
                Assert.IsNotNull(data);
            }
        }
        public void TestUpdateAutoCompleteCache()
        {
            Configuration config = new Configuration();
            config.AutoCompleteRoute = "testRoute";
            config.MaxResults = 100;
            config.RecordIndentifier = "Code";
            config.UpdateURL = "http://urltoupdatefrom";

            BasicRedisClientManager pooledClientManager = RedisClientManager.get();
            using (IRedisClient redisClient = pooledClientManager.GetClient())
            {
                IRedisTypedClient<Configuration> redis = redisClient.As<Configuration>();
                redis.SetEntry(config.AutoCompleteRoute, config);

                Dictionary<string,string> dataObj = new Dictionary<string,string>();
                dataObj["Code"] = "foo";
                dataObj["Desc"] = "bar";
                redisClient.Lists["cacheIndex:" + config.AutoCompleteRoute].Add(dataObj[config.RecordIndentifier]);
                redisClient.SetEntry("fullCache:" + config.AutoCompleteRoute + ":" + dataObj[config.RecordIndentifier], JsonConvert.SerializeObject(dataObj));
            }

            InfinityEngine.Business.InfinityEngine infinityEngine = new InfinityEngine.Business.InfinityEngine();
            infinityEngine.UpdateAutoCompleteCache(config.AutoCompleteRoute);

            using (IRedisClient redisClient = pooledClientManager.GetClient())
            {
                string setName = config.AutoCompleteRoute + ":autocomplete:ba";
                List<string> setValues = redisClient.SortedSets[setName].GetAll();

                Assert.IsTrue(setValues.Count > 0);
            }
        }