コード例 #1
0
        public void Can_Rebuild_Invoice_Index()
        {
            //// Arrange
            PreTestDataWorker.DeleteAllInvoices();
            var invoice1 = MockInvoiceDataMaker.InvoiceForInserting(_address, 100);
            var invoice2 = MockInvoiceDataMaker.InvoiceForInserting(_address, 200);

            PreTestDataWorker.InvoiceService.Save(invoice1);
            PreTestDataWorker.InvoiceService.Save(invoice2);

            //// Act
            var timer = new Stopwatch();

            timer.Start();
            ExamineManager.Instance.IndexProviderCollection["MerchelloInvoiceIndexer"].RebuildIndex();
            timer.Stop();
            Console.Write("Time to index: " + timer.Elapsed.ToString());

            //// Assert
            var searcher = ExamineManager.Instance.SearchProviderCollection["MerchelloInvoiceSearcher"];

            var criteria = searcher.CreateSearchCriteria(Merchello.Examine.IndexTypes.Invoice);

            criteria.Field("allDocs", "1");
            var results = searcher.Search(criteria);

            Assert.AreEqual(2, results.Count());
        }
コード例 #2
0
        public void Can_Add_An_Invoice_ToIndex()
        {
            //// Arrange
            var invoice3 = MockInvoiceDataMaker.InvoiceForInserting(_address, 300);

            invoice3.Items.Add(new InvoiceLineItem(LineItemType.Product, "test", "test", 1, 100));
            invoice3.Items.Add(new InvoiceLineItem(LineItemType.Product, "test2", "test2", 2, 100));
            PreTestDataWorker.InvoiceService.Save(invoice3);
            var order = invoice3.PrepareOrder(Core.MerchelloContext.Current);

            Core.MerchelloContext.Current.Services.OrderService.Save(order);
            var key = invoice3.Key;

            //// Act
            Core.MerchelloContext.Current.Services.InvoiceService.GetByKey(key);
            var searcher = ExamineManager.Instance.SearchProviderCollection["MerchelloInvoiceSearcher"];

            var criteria = searcher.CreateSearchCriteria(Merchello.Examine.IndexTypes.Invoice);

            criteria.Field("invoiceKey", key.ToString());
            var results = searcher.Search(criteria);

            //// Assert
            Assert.AreEqual(1, results.Count());
        }
コード例 #3
0
        public void Can_Create_InvoiceDiplay_From_Index_Document()
        {
            //// Arrange
            var invoice = MockInvoiceDataMaker.InvoiceForInserting(_address, 300);

            invoice.Items.Add(new InvoiceLineItem(LineItemType.Product, "test", "test", 1, 100));
            invoice.Items.Add(new InvoiceLineItem(LineItemType.Product, "test2", "test2", 2, 100));
            PreTestDataWorker.InvoiceService.Save(invoice);

            //// Act
            var invoiceDisplay = InvoiceQuery.GetByKey(invoice.Key);

            //// Assert
            Assert.NotNull(invoiceDisplay);
            Assert.AreEqual(Constants.DefaultKeys.InvoiceStatus.Unpaid, invoiceDisplay.InvoiceStatus.Key);
            Assert.AreEqual(invoice.Items.Count, invoiceDisplay.Items.Count());
        }
コード例 #4
0
        public void Init()
        {
            var address = new Address()
            {
                Name       = "Mindfly",
                Address1   = "114 W. Magnolia St.",
                Address2   = "Suite 300",
                Locality   = "Bellingham",
                Region     = "WA",
                PostalCode = "98225",
                Email      = "*****@*****.**",
                Phone      = "555-555-5555"
            };

            _invoice = MockInvoiceDataMaker.InvoiceForInserting(address, 599.99M);
            ((Invoice)_invoice).InvoiceNumber = 123;
            _invoice.Items.Add(new InvoiceLineItem(LineItemType.Product, "Xbox One", "Xbox1", 1, 486M));
            _invoice.Items.Add(new InvoiceLineItem(LineItemType.Product, "Xbox One TitanFall", "XB1-TitanFall", 2, 49.99M));
            _invoice.Items.Add(new InvoiceLineItem(LineItemType.Shipping, "Shipping", "Shipping", 1, 30.00M));
            _invoice.Items.Add(new InvoiceLineItem(LineItemType.Tax, "Sales Tax", "Tax", 1, 14.01M));


            _message
                = @"{{BillToName}}
Your address
{{BillToAddress1}}
{{BillToAddress2}}
{{BillToLocality}}, {{BillToRegion}} {{BillToPostalCode}}

Email : {{BillToEmail}}
Phone : {{BillToPhone}}

Invoice Number : {{InvoiceNumber}}

Items Purchased:

{{IterationStart[Invoice.Items]}}
+ {{Item.Name}} -> {{Item.Sku}} -> {{Item.UnitPrice}} -> {{Item.Quantity}} -> {{Item.TotalPrice}}
{{IterationEnd[Invoice.Items]}}

Thanks for the order.
";
        }
コード例 #5
0
        public void Can_Create_OrderDisplay_From_Index_Document()
        {
            //// Arrange
            var invoice = MockInvoiceDataMaker.InvoiceForInserting(_address, 300);

            invoice.Items.Add(new InvoiceLineItem(LineItemType.Product, "test", "test", 1, 100));
            invoice.Items.Add(new InvoiceLineItem(LineItemType.Product, "test2", "test2", 2, 100));
            PreTestDataWorker.InvoiceService.Save(invoice);

            var order = invoice.PrepareOrder();

            Core.MerchelloContext.Current.Services.OrderService.Save(order);

            //// Act
            var orderDisplay = OrderQuery.GetByKey(order.Key);

            //// Assert
            Assert.NotNull(orderDisplay);
            Assert.AreEqual(Constants.DefaultKeys.OrderStatus.NotFulfilled, orderDisplay.OrderStatus.Key);
            Assert.AreEqual(order.Items.Count, orderDisplay.Items.Count());
        }
コード例 #6
0
        public void Can_Updates_Index_With_InvoiceService_SaveEvent()
        {
            //// Arrange

            //// Act
            var invoice3 = MockInvoiceDataMaker.InvoiceForInserting(_address, 300);

            invoice3.Items.Add(new InvoiceLineItem(LineItemType.Product, "test", "test", 1, 100));
            invoice3.Items.Add(new InvoiceLineItem(LineItemType.Product, "test2", "test2", 2, 100));
            PreTestDataWorker.InvoiceService.Save(invoice3);

            var searcher = ExamineManager.Instance.SearchProviderCollection["MerchelloInvoiceSearcher"];

            var criteria = searcher.CreateSearchCriteria(Merchello.Examine.IndexTypes.Invoice);

            criteria.Field("invoiceKey", invoice3.Key.ToString());
            var results = searcher.Search(criteria);

            //// Assert
            Assert.AreEqual(1, results.Count());
        }
コード例 #7
0
        public void Can_Retrieve_Invoices_By_Customer_From_The_Index()
        {
            //// Arrange

            var customer = PreTestDataWorker.CustomerService.CreateCustomerWithKey(
                "rusty",
                "firstName",
                "lastName",
                "*****@*****.**");

            var invoice1 = MockInvoiceDataMaker.InvoiceForInserting(_address, 300);

            invoice1.Items.Add(new InvoiceLineItem(LineItemType.Product, "test", "test", 1, 100));
            invoice1.Items.Add(new InvoiceLineItem(LineItemType.Product, "test2", "test2", 2, 100));
            ((Invoice)invoice1).CustomerKey = customer.Key;

            var invoice2 = MockInvoiceDataMaker.InvoiceForInserting(_address, 100);

            invoice2.Items.Add(new InvoiceLineItem(LineItemType.Product, "test", "test", 1, 100));
            ((Invoice)invoice2).CustomerKey = customer.Key;

            var invoice3 = MockInvoiceDataMaker.InvoiceForInserting(_address, 300);

            invoice3.Items.Add(new InvoiceLineItem(LineItemType.Product, "test2", "test2", 3, 100));
            ((Invoice)invoice3).CustomerKey = customer.Key;

            PreTestDataWorker.InvoiceService.Save(invoice1);
            PreTestDataWorker.InvoiceService.Save(invoice2);
            PreTestDataWorker.InvoiceService.Save(invoice3);

            //// Act
            var merchello = new MerchelloHelper();

            var invoices = merchello.InvoicesByCustomer(customer.Key);

            //// Assert
            Assert.NotNull(invoices, "invoices was null");
            Assert.IsTrue(invoices.Any());
            Assert.AreEqual(3, invoices.Count());
        }
コード例 #8
0
 public void Init()
 {
     PreTestDataWorker.DeleteAllInvoices();
     _invoice = MockInvoiceDataMaker.InvoiceForInserting(_address, 150);
     PreTestDataWorker.InvoiceService.Save(_invoice);
 }