コード例 #1
0
        public void WriteFullInvoiceTest()
        {
            // Arrange
            _fileRepositoryMock
            .Setup(mock => mock.WriteLines(It.IsAny <string>(), It.IsAny <List <string> >()));

            var jobsFileRepository = new JobsFileRepository(_fileRepositoryMock.Object);

            var invoiceInput = Invoice.Create(
                new List <InvoiceItem>
            {
                InvoiceItem.Create("item1", 10m),
                InvoiceItem.Create("item2", 10.25m),
                InvoiceItem.Create("item3", 10.25m)
            },
                30.50m);

            // Act
            jobsFileRepository.WriteInvoiceToFile("fakeFilePath", invoiceInput);

            // Assert
            _fileRepositoryMock.Verify(
                mock => mock.WriteLines(
                    "fakeFilePath",
                    new List <string> {
                "item1: $10.00", "item2: $10.25", "item3: $10.25", "total: $30.50"
            }));
        }
コード例 #2
0
        // TODO: Update
        // Query invoice history to calculate change in stock quantity
        // https://rechnung.zoechbauer.info/invoices/invoice_history/127

        private async Task <IEnumerable <InvoiceItem> > ExtractInvoiceItems(HttpRequest request)
        {
            string requestBody = await ReadRequestBodyToString(request);

            var invoiceData = JsonConvert.DeserializeObject <InvoiceEventDto>(requestBody);

            var purchasedItems = invoiceData.invoice_items.Select(i =>
                                                                  InvoiceItem.Create(i.custom_value2, i.product_key, i.qty));

            return(purchasedItems);
        }