Exemple #1
0
        public void GetInvoicesByCustomerReturnsCorrectItemsFromRepository()
        {
            //// Arrange
            Guid key = Guid.NewGuid();

            int     invoiceId1 = 1;
            Invoice invoice    = CreateFakeInvoice(invoiceId1, key);

            int     invoiceId2 = 2;
            Invoice invoice2   = CreateFakeInvoice(invoiceId2, key);

            int     invoiceId3 = 3;
            Invoice invoice3   = CreateFakeInvoice(invoiceId3, key);

            List <Invoice> invoiceList = new List <Invoice>();

            invoiceList.Add(invoice);
            invoiceList.Add(invoice2);
            invoiceList.Add(invoice3);

            List <int> invoiceIds = new List <int>()
            {
                invoiceId1, invoiceId3
            };

            var MockInvoiceService = new Mock <IInvoiceService>();

            MockInvoiceService.Setup(cs => cs.GetInvoicesByCustomer(key)).Returns(invoiceList);

            MerchelloContext merchelloContext = GetMerchelloContext(MockInvoiceService.Object);

            InvoiceApiController ctrl = new InvoiceApiController(merchelloContext, tempUmbracoContext);

            //// Act
            var result = ctrl.GetInvoicesByCustomer(key);

            //// Assert
            Assert.AreEqual(invoiceList, result);
        }