Ejemplo n.º 1
0
        public void Cache_DataAddedAndReceived_ShouldPass()
        {
            var storage = new AsteriskStorage();
            var datetime = new ChangeableTime();
            var cache = new Cache<int, string>(16,1000,10000,storage,datetime);

            cache.Get(1);
            cache.Get(2);

            Assert.AreEqual("1",cache[1]);
            Assert.AreEqual("2",cache.Get(2));
        }
Ejemplo n.º 2
0
        public void Cache_DataAddedAndReceived_ShouldPass()
        {
            var storage  = new AsteriskStorage();
            var datetime = new ChangeableTime();
            var cache    = new Cache <int, string>(16, 1000, 10000, storage, datetime);

            cache.Get(1);
            cache.Get(2);

            Assert.AreEqual("1", cache[1]);
            Assert.AreEqual("2", cache.Get(2));
        }
Ejemplo n.º 3
0
        public void Cache_DataAddedAndReceived_ShouldPass()
        {
            var storage = new AsteriskStorage();
            //datetime -> dateTime
            var datetime = new ChangeableTime();                                        //this magic number to const
            var cache    = new Cache <int, string>(16, 1000, 10000, storage, datetime); // needs more space

            cache.Get(1);
            cache.Get(2);

            Assert.AreEqual("1", cache[1]);
            Assert.AreEqual("2", cache.Get(2));
        }
Ejemplo n.º 4
0
        public void Cache_DataAddedAndReceived_ShouldPass()
        {
            var storage = new AsteriskStorage();
            //datetime -> dateTime
            var datetime = new ChangeableTime(); //this magic number to const
            var cache = new Cache<int, string>(16,1000,10000,storage,datetime);// needs more space

            cache.Get(1);
            cache.Get(2);

            Assert.AreEqual("1",cache[1]);
            Assert.AreEqual("2",cache.Get(2));
        }
Ejemplo n.º 5
0
        public void Cache_AddedInFull_ShouldPass()
        {
            var storage = new AsteriskStorage();
            var datetime = new ChangeableTime();
            var cache = new Cache<int, string>(2,1000,10000,storage,datetime);

            cache.Get(1);
            datetime.AddTime(300);

            cache.Get(2);

            cache.Get(3);

            Assert.AreEqual("2", cache.Get(2));
            Assert.AreEqual("3", cache[3]);
            Assert.AreEqual("1*", cache.Get(1));
        }
Ejemplo n.º 6
0
        public void Cache_AddedInFull_ShouldPass()
        {
            var storage  = new AsteriskStorage();
            var datetime = new ChangeableTime();
            var cache    = new Cache <int, string>(2, 1000, 10000, storage, datetime);

            cache.Get(1);
            datetime.AddTime(300);

            cache.Get(2);

            cache.Get(3);

            Assert.AreEqual("2", cache.Get(2));
            Assert.AreEqual("3", cache[3]);
            Assert.AreEqual("1*", cache.Get(1));
        }
Ejemplo n.º 7
0
        public void Cache_ReceivedAfterSlideExpired_ShouldPass()
        {
            var storage  = new AsteriskStorage();
            var datetime = new ChangeableTime();
            var cache    = new Cache <int, string>(16, 1000, 10000, storage, datetime);

            cache.Get(1);
            cache.Get(2);

            datetime.AddTime(1500);
            cache.Get(1);

            cache.Get(3);

            Assert.AreEqual("1", cache[1]);
            Assert.AreEqual("2*", cache.Get(2));
        }
Ejemplo n.º 8
0
        public void Cache_AddedInFull_ShouldPass()
        {
            var storage = new AsteriskStorage();
            //datetime -> dateTime
            var datetime = new ChangeableTime();                                       //this magic number to const
            var cache    = new Cache <int, string>(2, 1000, 10000, storage, datetime); // needs more space

            cache.Get(1);
            datetime.AddTime(300);

            cache.Get(2);

            cache.Get(3);

            Assert.AreEqual("2", cache.Get(2));
            Assert.AreEqual("3", cache[3]);
            Assert.AreEqual("1*", cache.Get(1));
        }
Ejemplo n.º 9
0
        public void Cache_ReceivedAfterAbsoluteExpired_ShouldPass()
        {
            var storage = new AsteriskStorage();
            var datetime = new ChangeableTime();
            var cache = new Cache<int, string>(16, 1000, 10000, storage, datetime);

            cache.Get(1);
            cache.Get(2);

            datetime.AddTime(10101);
            cache.Get(1);
            cache.Get(2);

            cache.Get(3);

            Assert.AreEqual("1*", cache[1]);
            Assert.AreEqual("2*", cache.Get(2));
        }
Ejemplo n.º 10
0
        public void Cache_AddedInFull_ShouldPass()
        {
            var storage = new AsteriskStorage();
            //datetime -> dateTime
            var datetime = new ChangeableTime();//this magic number to const
            var cache = new Cache<int, string>(2,1000,10000,storage,datetime);// needs more space

            cache.Get(1);
            datetime.AddTime(300);

            cache.Get(2);

            cache.Get(3);

            Assert.AreEqual("2", cache.Get(2));
            Assert.AreEqual("3", cache[3]);
            Assert.AreEqual("1*", cache.Get(1));
        }
Ejemplo n.º 11
0
        public void Cache_ReceivedAfterAbsoluteExpired_ShouldPass()
        {
            var storage = new AsteriskStorage();
            //datetime -> dateTime
            var datetime = new ChangeableTime();//this magic number to const
            var cache    = new Cache <int, string>(16, 1000, 10000, storage, datetime);

            cache.Get(1);
            cache.Get(2);

            datetime.AddTime(10101);
            cache.Get(1);
            cache.Get(2);

            cache.Get(3);

            Assert.AreEqual("1*", cache[1]);
            Assert.AreEqual("2*", cache.Get(2));
        }
Ejemplo n.º 12
0
        public void Cache_AddedDeletedDataFromStorage_ShouldPass()
        {
            var storage = new AsteriskStorage();
            var datetime = new ChangeableTime();
            var cache = new Cache<int, string>(2,1000,10000,storage,datetime);

            cache.Get(1);
            datetime.AddTime(400);
            cache.Get(2);
            datetime.AddTime(400);

            cache.Get(3);

            Assert.AreEqual("1*", cache[1]); //Indexer and Get will add deleted data from storage
            datetime.AddTime(0);
            Assert.AreEqual("2*", cache.Get(2));
            datetime.AddTime(0);
            Assert.AreEqual("3*", cache[3]);
        }
Ejemplo n.º 13
0
        public void Cache_AddedDeletedDataFromStorage_ShouldPass()
        {
            var storage  = new AsteriskStorage();
            var datetime = new ChangeableTime();
            var cache    = new Cache <int, string>(2, 1000, 10000, storage, datetime);

            cache.Get(1);
            datetime.AddTime(400);
            cache.Get(2);
            datetime.AddTime(400);

            cache.Get(3);

            Assert.AreEqual("1*", cache[1]); //Indexer and Get will add deleted data from storage
            datetime.AddTime(0);
            Assert.AreEqual("2*", cache.Get(2));
            datetime.AddTime(0);
            Assert.AreEqual("3*", cache[3]);
        }
Ejemplo n.º 14
0
        static void Main(string[] args)
        {
            var storage  = new PiStorage();
            var datetime = new ChangeableTime();
            var cache    = new Cache <int, string>(2, 1000, 10000, storage, datetime);

            cache.Add(1, "One");
            datetime.AddTime(400);
            cache.Add(2, "Two");
            datetime.AddTime(400);
            cache.Add(3, "Three");

            Console.WriteLine("Pi" + cache[1]); //Indexer and Get will add deleted data from storage
            datetime.AddTime(0);
            Console.WriteLine("Pi" + cache.Get(2));
            datetime.AddTime(0);
            Console.WriteLine("Pi" + cache[3]);

            Console.ReadKey();
        }