Ejemplo n.º 1
0
        public void TestInitialize()
        {
            context = new TestDbContext();
            repo = new MBlogRepository(context);

            for (int i = 1; i <= 10; i++)
                context.Posts.Add(new Post() { Title = "Post " + i, PublishDate = DateTime.UtcNow.AddDays(11 - i) });
        }
Ejemplo n.º 2
0
        public void MBlogRepository_InsertOrUpdatePost_ShouldInsertPost()
        {
            var context = new TestDbContext();
            var repo = new MBlogRepository(context);
            var post = new Post()
            {
                Title = "Test Title",
            };

            repo.AddPost(post);

            Assert.AreEqual(1, context.Posts.Count());
        }
Ejemplo n.º 3
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);
        }