Exemple #1
0
        public void DeleteCat()
        {
            ConsoleTitleUtil.ShowTestTitle("DeleteCat");

            int retval = TCat.delete(30);

            Assert.AreEqual(1, retval);   // 删除了一条记录
            Console.WriteLine("\n删除 {0} 条记录 \n", retval);

            TCat mycat = TCat.findById(30);

            Assert.IsNull(mycat);
        }
Exemple #2
0
        public void FindPropertyNull()
        {
            string    artIds = "";
            string    catIds = "";
            ArrayList list   = new ArrayList();
            IList     arts   = new ArrayList();

            for (int i = 0; i < 5; i++)
            {
                TCat cat = new TCat();
                cat.Name = "tempCat1";

                cat.insert();

                list.Add(cat);
                catIds += cat.Id + ",";

                TArticle art = new TArticle();
                art.Title = "这是什么地方的测试" + i;
                art.Cat   = cat;

                art.insert();

                arts.Add(art);
                artIds += art.Id + ",";

                cat.delete();
            }
            catIds = catIds.TrimEnd(',');
            artIds = artIds.TrimEnd(',');

            IList <TArticle> results = TArticle.find("Id in (" + artIds + ")").list();

            foreach (TArticle art in results)
            {
                Assert.IsNull(art.Cat);
                Console.WriteLine(art.Title);
                //Console.WriteLine( "Id:" + art.Cat.Id + " catNull:" + art.Cat.IsNull() + " nameNull:" + strUtil.IsNullOrEmpty( art.Cat.Name ) );
            }
        }
Exemple #3
0
        public void FindPropertyNull()
        {
            string artIds = "";
            string catIds = "";
            ArrayList list = new ArrayList();
            IList arts = new ArrayList();
            for (int i = 0; i < 5; i++) {
                TCat cat = new TCat();
                cat.Name = "tempCat1";

                cat.insert();

                list.Add( cat );
                catIds += cat.Id + ",";

                TArticle art = new TArticle();
                art.Title = "这是什么地方的测试" + i;
                art.Cat = cat;

                art.insert();

                arts.Add( art );
                artIds += art.Id + ",";

                cat.delete();

            }
            catIds = catIds.TrimEnd( ',' );
            artIds = artIds.TrimEnd( ',' );

            IList<TArticle> results = TArticle.find( "Id in (" + artIds + ")" ).list();
            foreach (TArticle art in results) {
                Assert.IsNull( art.Cat );
                Console.WriteLine( art.Title );
                //Console.WriteLine( "Id:" + art.Cat.Id + " catNull:" + art.Cat.IsNull() + " nameNull:" + strUtil.IsNullOrEmpty( art.Cat.Name ) );
            }
        }