Ejemplo n.º 1
0
        public void PostBlog()
        {
            var             repo       = new Mock <BlogRepository>(db);
            BlogsController controller = new BlogsController(repo.Object);
            Blog            user       = new Blog {
                Id = 5, Title = "My Food Blog", Description = "An awesome food blog"
            };
            var data = controller.Post(user);

            Assert.AreEqual("Blog published successfully", data);
        }
        public void BlogControllerPost()
        {
            var newBlog = new Core.Data.Models.BlogItem();

            var result = _ctrl.Post(newBlog);

            Assert.AreEqual(HttpStatusCode.Created, result.StatusCode);

            var json = result.Content.ReadAsStringAsync().Result;
            var blog = JsonConvert.DeserializeObject <Core.Data.Models.Blog>(json);

            Assert.IsNotNull(blog);
            Assert.IsTrue(blog.Id != Guid.Empty && blog.Id != null);
        }