예제 #1
0
        public IActionResult PutBankExpenditureNote([FromRoute] int deliveryOrderId, [FromBody] BankExpenditureNoteFormDto form)
        {
            try
            {
                VerifyUser();

                var id = _service.UpdateFromBankExpenditureNote(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));
            }
        }
예제 #2
0
        public void PutBankExpenditureNote_Return_InternalServerError()
        {
            //Setup
            Mock <IServiceProvider> serviceProviderMock = GetServiceProvider();
            var service = new Mock <IGarmentDebtBalanceService>();

            service
            .Setup(s => s.UpdateFromBankExpenditureNote(It.IsAny <int>(), It.IsAny <BankExpenditureNoteFormDto>()))
            .Throws(new Exception());

            serviceProviderMock
            .Setup(serviceProvider => serviceProvider.GetService(typeof(IGarmentDebtBalanceService)))
            .Returns(service.Object);

            //Act
            BankExpenditureNoteFormDto form = new BankExpenditureNoteFormDto();
            IActionResult response          = GetController(serviceProviderMock).PutBankExpenditureNote(1, form);

            //Assert
            int statusCode = this.GetStatusCode(response);

            Assert.Equal((int)HttpStatusCode.InternalServerError, statusCode);
        }