Exemplo n.º 1
0
        public void TestThread()
        {
            DbContext db = new MSSqlDBContext();
            var       p  = new LuaPersonCacheBLL(db);
            var       a  = new LuaAddressCacheBLL(db);

            TestInit(p, a);

            List <Task> ts       = new List <Task>();
            int         forcount = 100;

            for (int i = 0; i < forcount; i++)
            {
                ts.Add(Task.Run(() =>
                {
                    DbContext db1 = new MSSqlDBContext();
                    var pt        = new LuaPersonCacheBLL(db1);
                    var at        = new LuaAddressCacheBLL(db1);
                    pt.Add();
                    pt.Count();
                    pt.Update();
                    pt.Delete();

                    at.Add();
                    at.Count();
                    at.Update();
                    at.Delete();
                }));
            }
            Task.WaitAll(ts.ToArray());

            TestDelete(p, a);
        }
Exemplo n.º 2
0
        public void Test4()
        {
            TestInit();

            //查询缓存测试
            var a1      = a.Get();
            var acount1 = a.Count();

            Assert.True(a1?.Count > 0);
            Assert.True(acount1 > 0);
            //再添加
            Assert.True(a.Add() > 0);
            //因为配置了查询缓存,而且Add并没有进行清理缓存
            Assert.True(a1?.Count == a.Get()?.Count);
            Assert.True(acount1 == a.Count());

            //p.Update() 会清理 Address表下的所有缓存
            Assert.True(p.Update() > 0);
            Assert.True(a1?.Count != a.Get()?.Count);
            Assert.True(acount1 != a.Count());

            TestDelete();
        }