Esempio n. 1
0
        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");
        }
Esempio n. 2
0
        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 });
        }
Esempio n. 3
0
        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());
        }
Esempio n. 4
0
        public void Can_Simulate_A_TriggeredOrderConfirmation()
        {
            // 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
            Notification.Trigger("OrderConfirmation", paymentResult, new [] { "*****@*****.**" });
            Notification.Trigger("OrderConfirmation", paymentResult, new[] { "*****@*****.**" });

            //// Assert

            // check email
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        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);
            }
        }