Exemplo n.º 1
0
        public void MBlogRepository_InsertOrUpdatePost_ShouldUpdatePost()
        {
            var context = new TestDbContext();
            var repo = new MBlogRepository(context);
            var newTitle = "NewTitle";
            var post = new Post()
            {
                Title = "Test Title",
            };
            var post2 = post;
            post2.Title = newTitle;

            repo.AddPost(post);
            repo.AddPost(post2);

            Assert.AreEqual(1, context.Posts.Count());
            Assert.AreEqual(newTitle, context.Posts.ToArray()[0].Title);
        }
Exemplo n.º 2
0
        public void MBlogRepository_InsertOrUpdatePost_ShouldInsertSecondPost()
        {
            var context = new TestDbContext();
            var repo = new MBlogRepository(context);
            var post = new Post()
            {
                Title = "Test Title",
            };
            var post2 = new Post()
            {
                Title = "Test Title New Post",
            };

            repo.AddPost(post);
            repo.AddPost(post2);

            Assert.AreEqual(2, context.Posts.Count());
        }