Exemplo n.º 1
0
        public void WhenAPostIsDeleted_ThenThePostIsDeletedFromTheService()
        {
            var service = new Mock<IAdminService>();
            var hub = new TestableAdminHub(service.Object, "Kevin");
            hub.DeleteBlogPost(It.IsAny<Guid>());

            service.Verify(s => s.DeleteBlogPost(It.IsAny<Guid>()), Times.Once());
        }
Exemplo n.º 2
0
        public void WhenAPostIsSentToTheHub_ThenThePostIsAdded()
        {
            var service = new Mock<IAdminService>();
            var hub = new TestableAdminHub(service.Object, "Kevin");
            service.Setup(s => s.AddBlogPost(It.IsAny<Post>())).Returns(new Post());
            hub.AddBlogPost(new NewPostViewModel());

            service.Verify(s => s.AddBlogPost(It.IsAny<Post>()), Times.Once());
        }
Exemplo n.º 3
0
 public void WhenAPostIsSentToTheHub_ThenTheCorrectDetailsAreSaved()
 {
     var service = new Mock<IAdminService>();
     var hub = new TestableAdminHub(service.Object, "Kevin");
     var post = new Post { Title = "title", Body = "body" };
     service.Setup(s => s.AddBlogPost(It.IsAny<Post>())).Returns(post);
     hub.AddBlogPost(new NewPostViewModel { Title = "title", Post = "body" });
     service.Verify(s => s.AddBlogPost(It.Is<Post>(p => p.Title == post.Title && p.Body == post.Body)),
                    Times.Once());
 }