예제 #1
0
        public void TestInsertRelations2()
        {
            var r = new ReaderMore {
                Name = "test"
            };
            var a = new ArticleMore {
                Name = "art"
            };
            var b = new BelongsMore {
                Name = "b"
            };

            r.Bms.Add(b);
            a.Bms.Add(b);
            r.Save();
            //a.Save();

            ReaderMore r1 = ReaderMore.FindById(r.Id);

            Assert.AreEqual("test", r1.Name);
            Assert.AreEqual(1, r1.Bms.Count);
            Assert.AreEqual("b", r1.Bms[0].Name);
            Assert.AreEqual("test", r1.Bms[0].Reader.Name);
            Assert.AreEqual("art", r1.Bms[0].Article.Name);
        }
예제 #2
0
        public void TestDelete()
        {
            ArticleMore.FindById(1).Delete();

            ReaderMore r = ReaderMore.FindById(2);

            Assert.AreEqual("f1", r.Bms[0].Name);
            Assert.IsNull(r.Bms[0].Article);
        }
예제 #3
0
        public void TestDelete3()
        {
            ArticleMore a = ArticleMore.FindById(1);

            Assert.AreEqual("f1", a.Bms[0].Name);
            a.Delete();

            Assert.IsNull(ArticleMore.FindById(1));
            ReaderMore r = ReaderMore.FindById(2);

            Assert.AreEqual(1, r.Bms.Count);
            Assert.AreEqual("f1", r.Bms[0].Name);
        }
예제 #4
0
        public void TestInsert()
        {
            var r = new ReaderMore {
                Name = "test"
            };

            r.Save();

            ReaderMore r1 = ReaderMore.FindById(r.Id);

            Assert.AreEqual("test", r1.Name);
            Assert.AreEqual(0, r1.Bms.Count);
        }
예제 #5
0
        public void Test2()
        {
            ReaderMore r = ReaderMore.FindById(1);

            Assert.IsNotNull(r);
            Assert.AreEqual("tom", r.Name);
            Assert.AreEqual(1, r.Bms.Count);
            Assert.AreEqual("f3", r.Bms[0].Name);

            r = ReaderMore.FindById(2);
            Assert.AreEqual(1, r.Bms.Count);
            Assert.AreEqual("f1", r.Bms[0].Name);

            r = ReaderMore.FindById(3);
            Assert.AreEqual(2, r.Bms.Count);
            Assert.AreEqual("f2", r.Bms[0].Name);
            Assert.AreEqual("f4", r.Bms[1].Name);
        }