public void ApproveOrRejectTest_Approve() { //Arrange Guid blogId = Guid.NewGuid(); Blog blog = new Blog(); blog.Id = blogId; blog.State.Id = Guid.NewGuid(); iBlogDAMock.Setup(x => x.GetById(blogId)).Returns(blog); //Act iBlogBL.ApproveOrReject(blogId, Enums.Action.Approve); //Assert Assert.Equal(Guid.Parse(Enums.BlogState.Approved.GetValueByProperty(Enums.Property.Id)), blog.State.Id); Assert.True(blog.PublishDate != null); }
public IActionResult ApproveOrReject(Guid id, Enums.Action action) { try { bool sw = iBlogBL.ApproveOrReject(id, action); if (sw) { return(Ok()); } else { return(StatusCode(422)); } } catch (Exception) { // Exception must be handle by saving it in any kind of repository return(StatusCode(500)); } }