public async Task EditPostShouldUpdatePost() { //Arrange using (var context = new SocialNetworkDbContext(this._data.ContextOptions)) { var postService = new PostService(context, null); var editedPost = PostFakes.GetPost(); editedPost.PostId = 1; //Act await postService.EditPost(editedPost); //Assert context.Posts.ToList() .Find(i => i.PostId == 1).Content .Should() .Be(editedPost.Content); context.Posts.ToList() .Find(i => i.PostId == 1).CreatedOn .Should() .Be(editedPost.CreatedOn); } }
protected static Post CreatePostWithNumberOfVotes(int votes) { var post = PostFakes.VanillaPost(); post.Votes = votes; return(post); }
public async Task AddPostShouldStorePostOnDbAsync() { using (var context = new SocialNetworkDbContext(this._data.ContextOptions)) { var postService = new PostService(context, null); var post = PostFakes.GetPost(); await postService.AddPost(post); context.Posts.ToList() .Last() .Should() .BeEquivalentTo(post); } }