public void GetInvoice_EmptyId_ExceptionRaised()
        {
            var client     = CreateClient();
            var getInvoice = new GetInvoice
            {
                Id = Guid.Empty
            };
            var ex = Assert.Throws <WebServiceException>(() => client.Get <InvoiceResponse>(getInvoice));

            Assert.IsTrue(ex.ErrorCode == "NotEqual");
            Assert.IsTrue(ex.ErrorMessage == "Specify nonempty Id for Invoice.");
        }
        public void GetInvoice_NonExistingId_ExceptionRaised()
        {
            var  client        = CreateClient();
            Guid nonExistingId = Guid.NewGuid();
            var  getInvoice    = new GetInvoice
            {
                Id = nonExistingId
            };
            var ex = Assert.Throws <WebServiceException>(() => client.Get <InvoiceResponse>(getInvoice));

            Assert.IsTrue(ex.ErrorCode == "NotFound");
            Assert.IsTrue(ex.ErrorMessage == $"There is no Invoice with id : {nonExistingId}");
        }
        public void GetInvoice_CorrectId_InvoiceReturned()
        {
            var getInvoice = new GetInvoice
            {
                Id = softwareInvoiceResponse.Id
            };

            var service  = appHost.Container.Resolve <InvoiceService>();
            var response = service.Get(getInvoice);

            Assert.IsTrue(response.Id == softwareInvoiceResponse.Id);
            Assert.IsTrue(response.Number == softwareInvoiceResponse.Number);
        }
Beispiel #4
0
        public InvoiceResponse Get(GetInvoice request)
        {
            try
            {
                InvoiceModel invoice = invoiceRepository.Find(request.Id);
                if (invoice == default(InvoiceModel))
                {
                    throw HttpError.NotFound($"There is no Invoice with id : {request.Id}");
                }

                return(invoice.ConvertTo <InvoiceResponse>());
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Something went wrong while getting Invoice.");
                throw;
            }
        }
 public ActionResult View(GetInvoice getInvoice)
 {
     return(View(getInvoice.ExecuteItem()));
 }