public void SystemCache_HashUpdate()
        {
            var key = "myhash";

            var cache = new SystemCache();

            cache.Clear();
            Random rnd = new Random(DateTime.Now.Millisecond);

            var dict = new Dictionary <string, DummyObject>();

            for (int i = 1; i <= 1000; i++)
            {
                var dummy = new DummyObject()
                {
                    Id = i, Name = "for test"
                };
                if (!dict.ContainsKey(dummy.Id.ToString()))
                {
                    dict.Add(dummy.Id.ToString(), dummy);
                }
            }


            cache.AddToHash <DummyObject>(key, dict);

            var count = cache.HashCount(key);

            // get random

            List <string> keys = new List <string>(dict.Keys);
            var           k    = keys[rnd.Next(keys.Count)];
            var           obj  = dict[k];

            Assert.True(cache.ExistsInHash <DummyObject>(key, obj.Id.ToString()));

            var cachedObj = cache.GetFromHash <DummyObject>(key, obj.Id.ToString());

            // update
            cachedObj.Name = "update";
            // create change set dict
            // update
            cache.UpdateInHash <DummyObject>(key, cachedObj.Id.ToString(), cachedObj);

            var updatedObj = cache.GetFromHash <DummyObject>(key, obj.Id.ToString());

            Assert.True(updatedObj.Name == "update");

            var newcount = cache.HashCount(key);

            Assert.Equal(count, newcount);
            cache.Clear();
        }
        public void SystemCache_Hash()
        {
            var key = "myhash";

            var cache = new SystemCache();

            long count = cache.Count;

            Random rnd = new Random(DateTime.Now.Millisecond);

            var dict = new Dictionary <string, DummyObject>();

            for (int i = 1; i <= 1000; i++)
            {
                var dummy = new DummyObject()
                {
                    Id = rnd.Next(10001, 99999), Name = "for test"
                };
                if (!dict.ContainsKey(dummy.Id.ToString()))
                {
                    dict.Add(dummy.Id.ToString(), dummy);
                }
            }


            cache.AddToHash <DummyObject>(key, dict);
            // get random

            List <string> keys = new List <string>(dict.Keys);
            var           k    = keys[rnd.Next(keys.Count)];
            var           obj  = dict[k];

            Assert.True(cache.ExistsInHash <DummyObject>(key, obj.Id.ToString()));

            var cachedObj = cache.GetFromHash <DummyObject>(key, obj.Id.ToString());

            Assert.Equal(obj, cachedObj);
        }