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}");
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 5
0
 public ActionResult View(GetInvoice getInvoice)
 {
     return(View(getInvoice.ExecuteItem()));
 }