示例#1
0
        public void Test_can_create_content()
        {
            using (var ctx = new ContentModelContainer())
            {
                var content = new Content
                {
                    Title = "My first article",
                    StandFirst = "My test standfirst",
                    Body = "Ooh yeah love that sexy body"
                };
                var author = new Author
                {
                    FirstName = "Brian",
                    Surname = "Clough"
                };
                content.Author = author;
                ctx.Content.AddObject(content);
                ctx.SaveChanges();
                Assert.AreNotEqual(0, content.Id);
                if (ctx.Authors.Count() == 0)
                    Assert.Fail("Author was not inserted");
                Assert.AreEqual("Brian", content.Author.FirstName);

                content.Title = "A different title";
                ctx.SaveChanges();
                content = ctx.Content.Where(c => c.Title == "A different title").Single();

            }
        }
示例#2
0
 public ContentRepository(ContentModelContainer context)
 {
     Context = context;
 }