public IActionResult PutInternalNote([FromRoute] int deliveryOrderId, [FromBody] InternalNoteFormDto form) { try { VerifyUser(); var id = _service.UpdateFromInternalNote(deliveryOrderId, form); var result = new ResultFormatter(ApiVersion, General.CREATED_STATUS_CODE, General.OK_MESSAGE).Ok(); return(NoContent()); } catch (Exception e) { var result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, result)); } }
public void PutInternalNote_Return_InternalServerError() { //Setup Mock <IServiceProvider> serviceProviderMock = GetServiceProvider(); var service = new Mock <IGarmentDebtBalanceService>(); service .Setup(s => s.UpdateFromInternalNote(It.IsAny <int>(), It.IsAny <InternalNoteFormDto>())) .Throws(new Exception()); serviceProviderMock .Setup(serviceProvider => serviceProvider.GetService(typeof(IGarmentDebtBalanceService))) .Returns(service.Object); //Act InternalNoteFormDto form = new InternalNoteFormDto(); IActionResult response = GetController(serviceProviderMock).PutInternalNote(1, form); //Assert int statusCode = this.GetStatusCode(response); Assert.Equal((int)HttpStatusCode.InternalServerError, statusCode); }