Beispiel #1
0
 public void WhenTheUserIsAuthenticated_AndAPostsIsCreate_ThenTheNewPostIsReturned()
 {
     _service.Setup(s => s.CreatePost(It.IsAny<Post>()));
     var hub = new BlogHub(_service.Object);
     hub.Create(It.IsAny<BlogPostViewModel>());
     _service.Verify(s => s.CreatePost(It.IsAny<Post>()), Times.Once());
 }
Beispiel #2
0
 public void WhenThereArePostsInTheRepository_AndPostsAreRequested_AllPostsAreReturned()
 {
     var posts = new List<Post>
                     {
                         new Post {Body = "body1", Title = "title1"},
                         new Post {Body = "body2", Title = "title2"}
                     };
     _service.Setup(s => s.GetPosts()).Returns(posts);
     var hub = new BlogHub(_service.Object);
     hub.List().Count.Should().Be(posts.Count);
 }
Beispiel #3
0
 public void WhenTheUserNotIsAuthenticated_AndAPostsIsCreate_ThenAnExceptionIsThrown()
 {
     var hub = new BlogHub(_service.Object);
     Action act = () => hub.Create(new BlogPostViewModel());
     act.ShouldThrow<NotLoggedInException>();
 }
Beispiel #4
0
 public void WhenThereAreNoPosts_AndPostsAreRequested_AnEmptyListIsReturned()
 {
     _service.Setup(s => s.GetAllPosts()).Returns(new List<Post>());
     var hub = new BlogHub(_service.Object);
     hub.List(true).Count.Should().Be(0);
 }