public void Can_Trigger_Two_Emails_Without_Having_RecipientsCollections_Combining() { // check configuration to see if we want to do this if (!bool.Parse(ConfigurationManager.AppSettings["sendTestEmail"])) { Assert.Ignore("Skipping test"); } //// Arrange var monitor = new OrderConfirmationMonitor(MerchelloContext.Current.Gateways.Notification); var invoice = MockInvoiceDataMaker.GetMockInvoiceForTaxation(); MerchelloContext.Current.Services.InvoiceService.Save(invoice); var paymentMethods = MerchelloContext.Current.Gateways.Payment.GetPaymentGatewayMethods().ToArray(); Assert.IsTrue(paymentMethods.Any(), "There are no payment methods"); var paymentResult = invoice.AuthorizeCapturePayment( MerchelloContext.Current, paymentMethods.FirstOrDefault().PaymentMethod.Key, new ProcessorArgumentCollection()); //// Act var contact1 = "[email1]"; Notification.Trigger("OrderConfirmation", paymentResult, new [] { contact1 }); var contact2 = "[email2]"; Notification.Trigger("OrderConfirmation", paymentResult, new [] { contact2 }); }
public void Can_Rebuild_Order_Index() { //// Arrange PreTestDataWorker.DeleteAllOrders(); var invoice1 = MockInvoiceDataMaker.InvoiceForInserting(_address, 100); var invoice2 = MockInvoiceDataMaker.InvoiceForInserting(_address, 200); PreTestDataWorker.InvoiceService.Save(invoice1); PreTestDataWorker.InvoiceService.Save(invoice2); var order1 = invoice1.PrepareOrder(); var order2 = invoice2.PrepareOrder(); PreTestDataWorker.OrderService.Save(order1); PreTestDataWorker.OrderService.Save(order2); //// Act var timer = new Stopwatch(); timer.Start(); ExamineManager.Instance.IndexProviderCollection["MerchelloOrderIndexer"].RebuildIndex(); timer.Stop(); Console.Write("Time to index: " + timer.Elapsed.ToString()); //// Assert var searcher = ExamineManager.Instance.SearchProviderCollection["MerchelloOrderSearcher"]; var criteria = searcher.CreateSearchCriteria(Merchello.Examine.IndexTypes.Order); criteria.Field("allDocs", "1"); var results = searcher.Search(criteria); Assert.AreEqual(2, results.Count()); }
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()); }
public void Can_Map_An_Invoice_With_A_Custom_LineItemType_To_InvoiceDisplay() { //// Arrange var invoice = MockInvoiceDataMaker.GetMockInvoiceForTaxation(); Assert.NotNull(invoice, "Invoice is null"); var extendedData = new ExtendedDataCollection(); extendedData.SetValue(Constants.ExtendedDataKeys.Taxable, false.ToString()); var typeField = EnumTypeFieldConverter.LineItemType.Custom("CcFee"); //// Act var ccFee = new InvoiceLineItem( typeField.TypeKey, "CC Fee", "ccfee", 1, 1.0m, extendedData); invoice.Items.Add(ccFee); var display = invoice.ToInvoiceDisplay(); //// Assert Assert.NotNull(display); Assert.IsFalse(display.Items.Any(x => x.LineItemTypeField == null), "One or more of the LineItemTypeFields where null"); }
public void Can_Create_An_Invoice_With_A_CustomLineItem() { //// Arrange var invoice = MockInvoiceDataMaker.GetMockInvoiceForTaxation(); Assert.NotNull(invoice, "Invoice is null"); var extendedData = new ExtendedDataCollection(); extendedData.SetValue(Constants.ExtendedDataKeys.Taxable, false.ToString()); var typeField = EnumTypeFieldConverter.LineItemType.Custom("CcFee"); //// Act var ccFee = new InvoiceLineItem( typeField.TypeKey, "CC Fee", "ccfee", 1, 1.0m, extendedData); invoice.Items.Add(ccFee); Assert.IsTrue(invoice.CustomLineItems().Any()); }
public IEnumerable <IInvoice> MakeExistingInvoices(int count = 1) { var list = new List <IInvoice>(); for (var i = 0; i < count; i++) { list.Add(MockInvoiceDataMaker.GetMockInvoiceForTaxation()); } InvoiceService.Save(list); return(list); }
public void Can_Detect_A_ShipmentStatusChange() { //// Arrange var address = new Address() { Address1 = "111 Somewhere St.", Locality = "Bellingham", Region = "WA", PostalCode = "98225", CountryCode = "US", Name = "Merchello" }; var invoice = MockInvoiceDataMaker.GetMockInvoiceForTaxation(); var payment = new Payment(PaymentMethodType.Cash, invoice.Total) { Collected = true, Authorized = true }; MerchelloContext.Current.Services.PaymentService.Save(payment); MerchelloContext.Current.Services.InvoiceService.Save(invoice); var appliedPaymentService = ((ServiceContext)(MerchelloContext.Current.Services)).AppliedPaymentService; var appliedPayment = appliedPaymentService.CreateAppliedPaymentWithKey( payment.Key, invoice.Key, AppliedPaymentType.Debit, "Payment applied", payment.Amount); invoice = MerchelloContext.Current.Services.InvoiceService.GetByKey(invoice.Key); Assert.NotNull(invoice); var order = invoice.PrepareOrder(); MerchelloContext.Current.Services.OrderService.Save(order); var builder = new ShipmentBuilderChain(MerchelloContext.Current, order, order.Items.Select(x => x.Key), Guid.NewGuid(), Constants.DefaultKeys.ShipmentStatus.Packaging, "Track", "http://url.com", "carrier"); var attempt = builder.Build(); Assert.IsTrue(attempt.Success); }
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()); }
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. "; }
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()); }
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()); }
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()); }
public override void FixtureSetup() { base.FixtureSetup(); var invoices = ((InvoiceService)MerchelloContext.Current.Services.InvoiceService).GetAll(); MerchelloContext.Current.Services.InvoiceService.Delete(invoices); // add 60 invoices starting 60 days back var start = DateTime.Today.AddDays(-30); var end = DateTime.Today; while (start != end) { var inv = MockInvoiceDataMaker.GetMockInvoiceForTaxation(); inv.InvoiceDate = start; MerchelloContext.Current.Services.InvoiceService.Save(inv); start = start.AddDays(1); } _merchello = new MerchelloHelper(MerchelloContext.Current, false); }
public void Can_Prove_Serialized_Shipment_Stores_ExtendedDataCollection_In_LineItems() { //// Arrange var invoice = MockInvoiceDataMaker.GetMockInvoiceForTaxation(); Assert.NotNull(invoice, "Invoice is null"); //// Act var shipmentLineItems = invoice.ShippingLineItems().ToArray(); Assert.IsTrue(shipmentLineItems.Any()); var shipment = shipmentLineItems.First().ExtendedData.GetShipment <OrderLineItem>(); //// Assert Assert.NotNull(shipment, "Shipment was null"); Assert.IsTrue(shipment.Items.Any(), "Shipment did not contain any line items"); Assert.IsFalse(shipment.Items.All(x => x.ExtendedData.IsEmpty), "Extended data in one or more line items was empty"); Assert.IsTrue(shipment.Items.Any(x => x.ExtendedData.GetTaxableValue()), "Shipment does not contain any taxable items"); foreach (var item in shipment.Items) { Assert.IsTrue(invoice.Items.Any(x => x.Sku == item.Sku), "No item exists for sku " + item.Sku); } }
public void Init() { PreTestDataWorker.DeleteAllInvoices(); _invoice = MockInvoiceDataMaker.InvoiceForInserting(_address, 150); PreTestDataWorker.InvoiceService.Save(_invoice); }