Esempio n. 1
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);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        public void TestCreateTable()
        {
            DbEntry.DropAndCreate(typeof(BelongsMore));
            ArticleMore a = ArticleMore.FindById(1);

            Assert.AreEqual(0, a.Bms.Count);

            a.Bms.Add(new BelongsMore {
                Name = "mytest"
            });
            a.Save();

            a = ArticleMore.FindById(1);
            Assert.AreEqual(1, a.Bms.Count);
            Assert.AreEqual("mytest", a.Bms[0].Name);
        }
Esempio n. 4
0
        public void TestUpdate2()
        {
            ArticleMore a = ArticleMore.FindById(1);

            Assert.IsNotNull(a);
            Assert.AreEqual("The lovely bones", a.Name);
            Assert.AreEqual(1, a.Bms.Count);
            Assert.AreEqual("f1", a.Bms[0].Name);

            a.Bms[0].Name = "ok";
            a.Save();

            a = ArticleMore.FindById(1);
            Assert.IsNotNull(a);
            Assert.AreEqual("ok", a.Bms[0].Name);
        }
Esempio n. 5
0
        public void TestUpdate3()
        {
            ArticleMore a1 = ArticleMore.FindById(1);
            ArticleMore a2 = ArticleMore.FindById(2);

            a2.Bms.Add(a1.Bms[0]);
            a2.Save();

            a1 = ArticleMore.FindById(1);
            Assert.IsNotNull(a1);
            Assert.AreEqual("The lovely bones", a1.Name);
            Assert.AreEqual(0, a1.Bms.Count);

            a2 = ArticleMore.FindById(2);
            Assert.AreEqual(2, a2.Bms.Count);
            Assert.AreEqual("f1", a2.Bms[0].Name);
            Assert.AreEqual("f2", a2.Bms[1].Name);
        }
Esempio n. 6
0
        public void Test1()
        {
            ArticleMore a = ArticleMore.FindById(1);

            Assert.IsNotNull(a);
            Assert.AreEqual("The lovely bones", a.Name);
            Assert.AreEqual(1, a.Bms.Count);
            Assert.AreEqual("f1", a.Bms[0].Name);


            a = ArticleMore.FindById(2);
            Assert.AreEqual(1, a.Bms.Count);
            Assert.AreEqual("f2", a.Bms[0].Name);

            a = ArticleMore.FindById(3);
            Assert.AreEqual(2, a.Bms.Count);
            Assert.AreEqual("f3", a.Bms[0].Name);
            Assert.AreEqual("f4", a.Bms[1].Name);
        }
Esempio n. 7
0
 public void TestDelete2()
 {
     ArticleMore.FindById(1).Delete();
     // it's don't need to be.
     // Assert.AreEqual(0, DbEntry.Provider.ExecuteScalar("select [Article_Id] from [BelongsMore] Where [Id] = 1"));
 }