public void Cache_Get_Set()
        {
            var cache = Container.Resolve <IEntityCache>();

            var msr = new ManualResetEvent(false);

            Task.Run(async() =>
            {
                var l1 = new List <CacheTest1>();
                var l2 = new List <CacheTest2>();

                for (var i = 0; i < 15; i++)
                {
                    var c1 = new CacheTest1
                    {
                        Field = "F" + i
                    };

                    l1.Add(c1);

                    await cache.SetEntity(c1.Field, c1);

                    var c2 = new CacheTest2
                    {
                        Field = "F" + i
                    };

                    l2.Add(c2);

                    await cache.SetEntity(c2.Field, c2);
                }

                await cache.SetEntity("List1", l1);
                await cache.SetEntity("List2", l2);

                var c1Out = await cache.GetEntity <List <CacheTest1> >("List1", TimeSpan.FromSeconds(5));
                var c2Out = await cache.GetEntity <List <CacheTest2> >("List2", TimeSpan.FromSeconds(5));

                Assert.IsNotNull(c1Out);
                Assert.IsNotNull(c2Out);

                Assert.AreEqual(c2Out.Count, 15);
                Assert.AreEqual(c1Out.Count, 15);

                await cache.Delete <List <CacheTest1> >("List1");

                var c1Out2 = await cache.GetEntity <List <CacheTest1> >("List1", TimeSpan.FromSeconds(5));
                var c2Out2 = await cache.GetEntity <List <CacheTest2> >("List2", TimeSpan.FromSeconds(5));

                var c1OutMissingBadName = await cache.GetEntity <List <CacheTest1> >("List3", TimeSpan.FromSeconds(5));

                Assert.IsNotNull(c2Out2);
                Assert.IsNull(c1Out2);
                Assert.IsNull(c1OutMissingBadName);

                var c1Out3 = await cache.GetEntity <List <CacheTest2> >("List1", TimeSpan.FromSeconds(5));
                var c2Out3 = await cache.GetEntity <List <CacheTest1> >("List2", TimeSpan.FromSeconds(5));

                Assert.IsNull(c2Out3);
                Assert.IsNull(c1Out3);

                var f1 = await cache.GetEntity <CacheTest1>("F1", TimeSpan.FromSeconds(5));
                var f2 = await cache.GetEntity <CacheTest2>("F1", TimeSpan.FromSeconds(5));

                Assert.IsNotNull(f1);
                Assert.IsNotNull(f2);


                await cache.Delete <CacheTest1>("F1");

                var f12 = await cache.GetEntity <CacheTest1>("F1", TimeSpan.FromSeconds(5));
                var f22 = await cache.GetEntity <CacheTest2>("F1", TimeSpan.FromSeconds(5));

                Assert.IsNull(f12);
                Assert.IsNotNull(f22);

                msr.Set();
            });

            var msrResult = msr.WaitOne(3000);

            Assert.IsTrue(msrResult, "MSR not set, means assertion failed in task");
        }
        public void Cache_Get_Set()
        {
            var cache = Container.Resolve<IEntityCache>();

            var msr = new ManualResetEvent(false);

            Task.Run(async () =>
            {
                var l1 = new List<CacheTest1>();
                var l2 = new List<CacheTest2>();

                for (var i = 0; i < 15; i++)
                {
                    var c1 = new CacheTest1
                    {
                        Field = "F" + i
                    };

                    l1.Add(c1);

                    await cache.SetEntity(c1.Field, c1);

                    var c2 = new CacheTest2
                    {
                        Field = "F" + i
                    };

                    l2.Add(c2);

                    await cache.SetEntity(c2.Field, c2);
                }

                await cache.SetEntity("List1", l1);
                await cache.SetEntity("List2", l2);

                var c1Out = await cache.GetEntity<List<CacheTest1>>("List1", TimeSpan.FromSeconds(5));
                var c2Out = await cache.GetEntity<List<CacheTest2>>("List2", TimeSpan.FromSeconds(5));

                Assert.IsNotNull(c1Out);
                Assert.IsNotNull(c2Out);

                Assert.AreEqual(c2Out.Count, 15);
                Assert.AreEqual(c1Out.Count, 15);

                await cache.Delete<List<CacheTest1>>("List1");

                var c1Out2 = await cache.GetEntity<List<CacheTest1>>("List1", TimeSpan.FromSeconds(5));
                var c2Out2 = await cache.GetEntity<List<CacheTest2>>("List2", TimeSpan.FromSeconds(5));

                var c1OutMissingBadName = await cache.GetEntity<List<CacheTest1>>("List3", TimeSpan.FromSeconds(5));

                Assert.IsNotNull(c2Out2);
                Assert.IsNull(c1Out2);
                Assert.IsNull(c1OutMissingBadName);

                var c1Out3 = await cache.GetEntity<List<CacheTest2>>("List1", TimeSpan.FromSeconds(5));
                var c2Out3 = await cache.GetEntity<List<CacheTest1>>("List2", TimeSpan.FromSeconds(5));

                Assert.IsNull(c2Out3);
                Assert.IsNull(c1Out3);

                var f1 = await cache.GetEntity<CacheTest1>("F1", TimeSpan.FromSeconds(5));
                var f2 = await cache.GetEntity<CacheTest2>("F1", TimeSpan.FromSeconds(5));

                Assert.IsNotNull(f1);
                Assert.IsNotNull(f2);


                await cache.Delete<CacheTest1>("F1");

                var f12 = await cache.GetEntity<CacheTest1>("F1", TimeSpan.FromSeconds(5));
                var f22 = await cache.GetEntity<CacheTest2>("F1", TimeSpan.FromSeconds(5));

                Assert.IsNull(f12);
                Assert.IsNotNull(f22);

                msr.Set();
            });

            var msrResult = msr.WaitOne(3000);
            Assert.IsTrue(msrResult, "MSR not set, means assertion failed in task");
        }