Esempio n. 1
0
        public void Pipeline_CC_Workflow_Should_Send_Acknowledgment_Email_To_Customer()
        {
            Order order = GetTestOrder();

            using (WorkflowRuntime workflowRuntime = new WorkflowRuntime()) {
                AutoResetEvent waitHandle = new AutoResetEvent(false);
                workflowRuntime.WorkflowCompleted  += delegate(object sender, WorkflowCompletedEventArgs e) { waitHandle.Set(); };
                workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e) {
                    Debug.WriteLine(e.Exception.Message);
                    waitHandle.Set();
                };

                WorkflowInstance instance = workflowRuntime.CreateWorkflow(
                    typeof(Commerce.Pipelines.SubmitOrderWorkflow), GetParams(order));

                instance.Start();

                waitHandle.WaitOne();

                //execution should be finished
                //check the mailers
                TestMailerService mailer = _mailerService as TestMailerService;
                Assert.IsTrue(mailer.SentMail.Count > 0);

                //the first email should be to the customer
                Assert.AreEqual(MailerType.CustomerOrderReceived, mailer.SentMail[0].MailType);
            }
        }
Esempio n. 2
0
        public void Pipeline_WWF_Shipping_Should_Send_Email_To_Customer()
        {
            Order order = GetTestOrder();

            using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())
            {
                AutoResetEvent waitHandle = new AutoResetEvent(false);
                workflowRuntime.WorkflowCompleted  += delegate(object sender, WorkflowCompletedEventArgs e) { waitHandle.Set(); };
                workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e)
                {
                    Debug.WriteLine(e.Exception.Message);
                    waitHandle.Set();
                };
                DateTime         estimatedDelivery = DateTime.Now.AddDays(5);
                WorkflowInstance instance          = workflowRuntime.CreateWorkflow(
                    typeof(Commerce.Pipelines.ShipOrderWorkflow), GetShippingParams(order, "12345", estimatedDelivery));

                instance.Start();

                waitHandle.WaitOne();

                //execution should be finished
                //check the order for status


                TestMailerService mailer = _mailerService as TestMailerService;

                Assert.AreEqual(1, mailer.SentMail.Count);
                Assert.AreEqual(MailerType.CustomerOrderShipped, mailer.SentMail[0].MailType);
            }
        }
Esempio n. 3
0
        public void Pipeline_CC_Workflow_Should_Succeed_With_Valid_Order_And_Card_And_Address_And_Send_User_Thankyou_Admin_Notification()
        {
            Order order = GetTestOrder();

            using (WorkflowRuntime workflowRuntime = new WorkflowRuntime()) {
                AutoResetEvent waitHandle = new AutoResetEvent(false);
                workflowRuntime.WorkflowCompleted  += delegate(object sender, WorkflowCompletedEventArgs e) { waitHandle.Set(); };
                workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e) {
                    Debug.WriteLine(e.Exception.Message);
                    waitHandle.Set();
                };

                var parameters = GetParams(order);

                WorkflowInstance instance = workflowRuntime.CreateWorkflow(
                    typeof(Commerce.Pipelines.SubmitOrderWorkflow), parameters);

                instance.Start();
                waitHandle.WaitOne();
                //check the Repository and see if the status for the order has been updated
                Order checkOrder = _orderService.GetOrder(order.ID);
                Assert.AreEqual(OrderStatus.Verified, checkOrder.Status);

                //execution should be finished
                //check the mailers
                TestMailerService mailer = _mailerService as TestMailerService;
                Assert.IsTrue(mailer.SentMail.Count > 0);

                //the first email should be to the customer
                Assert.AreEqual(MailerType.CustomerOrderReceived, mailer.SentMail[0].MailType);

                //if success, the admin should be second
                Assert.AreEqual(MailerType.AdminOrderReceived, mailer.SentMail[1].MailType);
            }
        }
Esempio n. 4
0
        public void Pipeline_CC_Workflow_Should_Fail_And_Notify_Customer_When_Invalid_Address()
        {
            Order order = GetTestOrder();

            //this tells the test address service to throw
            order.ShippingAddress.City = "Fail Town";

            using (WorkflowRuntime workflowRuntime = new WorkflowRuntime()) {
                AutoResetEvent waitHandle = new AutoResetEvent(false);
                workflowRuntime.WorkflowCompleted  += delegate(object sender, WorkflowCompletedEventArgs e) { waitHandle.Set(); };
                workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e) {
                    Debug.WriteLine(e.Exception.Message);
                    waitHandle.Set();
                };

                WorkflowInstance instance = workflowRuntime.CreateWorkflow(
                    typeof(Commerce.Pipelines.SubmitOrderWorkflow), GetParams(order));

                try {
                    instance.Start();
                    waitHandle.WaitOne();
                } catch {
                }

                //execution should be finished
                //check the mailers
                TestMailerService mailer = _mailerService as TestMailerService;
                Assert.IsTrue(mailer.SentMail.Count > 0);

                //the first email should be to the customer
                Assert.AreEqual(MailerType.CustomerOrderReceived, mailer.SentMail[0].MailType);
                Assert.AreEqual(MailerType.CustomerAddressValidationFailed, mailer.SentMail[1].MailType);
            }
        }
Esempio n. 5
0
        public void Pipeline_Default_Shipping_Should_Send_Email_To_Customer()
        {
            Order    order             = GetTestOrder();
            DateTime estimatedDelivery = DateTime.Now.AddDays(5);

            _pipeline.ShipOrder(order, "12345", estimatedDelivery);

            TestMailerService mailer = _mailerService as TestMailerService;

            Assert.AreEqual(1, mailer.SentMail.Count);
            Assert.AreEqual(MailerType.CustomerOrderShipped, mailer.SentMail[0].MailType);
        }
Esempio n. 6
0
        public void Pipeline_CC_Workflow_Should_Fail_And_Notify_Customer_When_CC_AuthFails()
        {
            Order order = GetTestOrder();

            using (WorkflowRuntime workflowRuntime = new WorkflowRuntime()) {
                AutoResetEvent waitHandle = new AutoResetEvent(false);
                workflowRuntime.WorkflowCompleted  += delegate(object sender, WorkflowCompletedEventArgs e) { waitHandle.Set(); };
                workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e) {
                    Debug.WriteLine(e.Exception.Message);
                    waitHandle.Set();
                };

                var parameters = GetParams(order);

                //reset the payment service to throw
                parameters["PaymentServiceInterface"] = new ThrowPaymentService();

                WorkflowInstance instance = workflowRuntime.CreateWorkflow(
                    typeof(Commerce.Pipelines.SubmitOrderWorkflow), parameters);

                try {
                    instance.Start();
                    waitHandle.WaitOne();
                } catch {
                }

                //execution should be finished
                //check the mailers
                TestMailerService mailer = _mailerService as TestMailerService;
                Assert.IsTrue(mailer.SentMail.Count > 0);

                //the first email should be to the customer
                Assert.AreEqual(MailerType.CustomerOrderReceived, mailer.SentMail[0].MailType);
                Assert.AreEqual(MailerType.CustomerPaymentAuthFailed, mailer.SentMail[1].MailType);
            }
        }