void IPostBusinessLogic.Patch(PostPatchDto post) { Post updatedPost = postRepository.GetById(post.Id); if (updatedPost == null) { return; } mapper.Map <PostPatchDto, Post>(post, updatedPost); postRepository.Update(updatedPost); postRepository.SaveChanges(); }
public void Patch_SavesRepoAfterUpdate() { //Arrange PostPatchDto postPatch = new PostPatchDto { Id = Guid.Parse("3fa85f64-5717-4562-b3fc-2c963f66afa6") }; Post post = mapper.Map <Post>(postPatch); postRepositoryMock.Setup(x => x.GetById(Guid.Parse("3fa85f64-5717-4562-b3fc-2c963f66afa6"))).Returns(post); //Act systemUnderTest.Patch(postPatch); //Assert postRepositoryMock.Verify(m => m.SaveChanges(), Times.Once); }
public void Patch_ReturnsNullIfPostGivenDoesNotExist() { //Arrange PostPatchDto postPatch = new PostPatchDto { Id = Guid.Parse("3fa85f64-5717-4562-b3fc-2c963f66afa6") }; Post post = mapper.Map <Post>(postPatch); postRepositoryMock.Setup(x => x.GetById(Guid.Parse("3fa85f64-5717-4562-b3fc-2c963f66afa6"))).Returns(() => null); //Act systemUnderTest.Patch(postPatch); //Assert postRepositoryMock.Verify(m => m.Update(post), Times.Never); postRepositoryMock.Verify(m => m.SaveChanges(), Times.Never); }
public async Task <PostReadDto> PatchPostAsync(PostPatchDto dto) { throw new System.NotImplementedException(); }