Example #1
0
        public void TestFindInvalid()
        {
            var myDataCache = new MyDataCache <MyKey, MyValue>();

            myDataCache.Add(new MyKey("key1"), new MyValue("value1"));

            myDataCache.InnerDict.Add(new MyKey("key2"), new MyValue("value2"));
            myDataCache.InnerDict.Add(new MyKey("key3"), new MyValue("value3"));
            myDataCache.InnerDict.Add(new MyKey("key4"), new MyValue("value3"));

            var items = myDataCache.Find().GetEnumerator();

            items.MoveNext().Should().Be(true);
            items.Current.Key.Should().Be(new MyKey("key1"));

            myDataCache.TryGet(new MyKey("key3")); // GETLINE

            items.MoveNext().Should().Be(true);
            items.Current.Key.Should().Be(new MyKey("key2"));
            items.MoveNext().Should().Be(true);
            items.Current.Key.Should().Be(new MyKey("key3"));
            items.MoveNext().Should().Be(true);
            items.Current.Key.Should().Be(new MyKey("key4"));
            items.MoveNext().Should().Be(false);
        }
Example #2
0
        public void TestFindRange()
        {
            myDataCache.Add(new MyKey("key1"), new MyValue("value1"));
            myDataCache.Add(new MyKey("key2"), new MyValue("value2"));

            myDataCache.InnerDict.Add(new MyKey("key3"), new MyValue("value3"));
            myDataCache.InnerDict.Add(new MyKey("key4"), new MyValue("value4"));

            var items = myDataCache.FindRange(new MyKey("key3").ToArray(), new MyKey("key5").ToArray()).ToArray();

            new MyKey("key3").Should().Be(items[0].Key);
            new MyValue("value3").Should().Be(items[0].Value);
            new MyKey("key4").Should().Be(items[1].Key);
            new MyValue("value4").Should().Be(items[1].Value);
            items.Length.Should().Be(2);

            // case 2 Need to sort the cache of myDataCache

            myDataCache = new MyDataCache();
            myDataCache.Add(new MyKey("key1"), new MyValue("value1"));
            myDataCache.Add(new MyKey("key2"), new MyValue("value2"));

            myDataCache.InnerDict.Add(new MyKey("key4"), new MyValue("value4"));
            myDataCache.InnerDict.Add(new MyKey("key3"), new MyValue("value3"));

            items = myDataCache.FindRange(new MyKey("key3").ToArray(), new MyKey("key5").ToArray()).ToArray();
            new MyKey("key3").Should().Be(items[0].Key);
            new MyValue("value3").Should().Be(items[0].Value);
            new MyKey("key4").Should().Be(items[1].Key);
            new MyValue("value4").Should().Be(items[1].Value);
            items.Length.Should().Be(2);

            // case 3 FindRange by Backward

            myDataCache = new MyDataCache();
            myDataCache.Add(new MyKey("key1"), new MyValue("value1"));
            myDataCache.Add(new MyKey("key2"), new MyValue("value2"));

            myDataCache.InnerDict.Add(new MyKey("key4"), new MyValue("value4"));
            myDataCache.InnerDict.Add(new MyKey("key3"), new MyValue("value3"));
            myDataCache.InnerDict.Add(new MyKey("key5"), new MyValue("value5"));

            items = myDataCache.FindRange(new MyKey("key5").ToArray(), new MyKey("key3").ToArray(), SeekDirection.Backward).ToArray();
            new MyKey("key5").Should().Be(items[0].Key);
            new MyValue("value5").Should().Be(items[0].Value);
            new MyKey("key4").Should().Be(items[1].Key);
            new MyValue("value4").Should().Be(items[1].Value);
            items.Length.Should().Be(2);
        }
Example #3
0
 public void Initialize()
 {
     myDataCache = new MyDataCache <MyKey, MyValue>();
 }
Example #4
0
 public void Init()
 {
     myDataCache = new MyDataCache <MyKey, MyValue>();
     cloneCache  = new CloneCache <MyKey, MyValue>(myDataCache);
 }
Example #5
0
 public void Init()
 {
     myDataCache = new MyDataCache();
     clonedCache = new ClonedCache(myDataCache);
 }
Example #6
0
 public void Initialize()
 {
     myDataCache = new MyDataCache();
 }