public void Process(OrderStatusMessage orderStatusMessage)
        {
            // Get the connection string from configuration
            string connectionString =
                ConfigurationManager.ConnectionStrings["Main"]
                    .ConnectionString;

            Order order = null;

            using (SqlConnection connection =
                new SqlConnection(connectionString))
            {
                // go get some data from the database
                order = fetchData(orderStatusMessage, connection);
            }

            // Apply the changes to the Order from the OrderStatusMessage
            updateTheOrder(order);

            // International orders have a unique set of business rules
            if (order.IsInternational)
            {
                processInternationalOrder(order);
            }

                // We need to treat larger orders in a special manner
            else if (order.LineItems.Count > 10)
            {
                processLargeDomesticOrder(order);
            }

                // Smaller domestic orders
            else
            {
                processRegularDomesticOrder(order);
            }

            // Ship the order if it's ready
            if (order.IsReadyToShip())
            {
                ShippingGateway gateway = new ShippingGateway();

                // Transform the Order object into a Shipment
                ShipmentMessage message =
                    createShipmentMessageForOrder(order);
                gateway.SendShipment(message);
            }
        }
        public void Can_run_activity_processshipment()
        {
            var orderGroup = CreateCart();

            orderGroup.OrderForms[0].Shipments[0].ShippingMethodId = "FlatRate";

            var gateway0 = new ShippingGateway
            {
                ClassType = "VirtoCommerce.Shipping.SimpleShippingGateway, VirtoCommerce.SimpleShippingGateway",
                Name      = "SimpleShippingGateway"
            };
            var option = new ShippingOption {
                Name = "default", Description = "Default", ShippingGateway = gateway0
            };
            var option2 = new ShippingOption {
                Name = "default2", Description = "Default2", ShippingGateway = gateway0
            };
            var shippingMethods = new List <ShippingMethod>
            {
                new ShippingMethod
                {
                    ShippingMethodId = "FreeShipping",
                    Name             = "FreeShipping",
                    DisplayName      = "Free Shipping",
                    Description      = "Free Shipping",
                    Currency         = "USD",
                    BasePrice        = 0,
                    IsActive         = true,
                    ShippingOption   = option
                },
                new ShippingMethod
                {
                    ShippingMethodId = "FlatRate",
                    Name             = "FlatRate",
                    DisplayName      = "Flat Rate",
                    Description      = "Flat Rate",
                    Currency         = "USD",
                    BasePrice        = 10,
                    IsActive         = true,
                    ShippingOption   = option2
                }
            };

            option.ShippingMethods.Add(shippingMethods[0]);
            option2.ShippingMethods.Add(shippingMethods[1]);

            var repository = new Mock <IShippingRepository>();

            repository.Setup(x => x.ShippingOptions).Returns(() => new[] { option, option2 }.AsQueryable());
            // initializing UnityContainer
            var initializedLocator = Locator;

            // mocking the IShippingRepository into UnityContainer as SimpleShippingGateway resolves it.
            _container.RegisterInstance(repository.Object);

            var activity = new ProcessShipmentActivity();
            var result   = InvokeActivity(activity, orderGroup);
            var order    = result.OrderGroup;

            foreach (var shipment in order.OrderForms[0].Shipments)
            {
                Assert.True(shipment.ShippingCost == 10m);
            }
        }
		public void Can_run_activity_processshipment()
		{
			var orderGroup = CreateCart();
			orderGroup.OrderForms[0].Shipments[0].ShippingMethodId = "FlatRate";

			var gateway0 = new ShippingGateway
						{
							ClassType = "VirtoCommerce.Shipping.SimpleShippingGateway, VirtoCommerce.SimpleShippingGateway",
							Name = "SimpleShippingGateway"
						};
			var option = new ShippingOption { Name = "default", Description = "Default", ShippingGateway = gateway0 };
			var option2 = new ShippingOption { Name = "default2", Description = "Default2", ShippingGateway = gateway0 };
			var shippingMethods = new List<ShippingMethod>
				{
					new ShippingMethod
						{
							ShippingMethodId = "FreeShipping",
							Name = "FreeShipping",
							DisplayName = "Free Shipping",
							Description = "Free Shipping",
							Currency = "USD",
							BasePrice = 0,
							IsActive = true,
							ShippingOption = option
						},
					new ShippingMethod
						{
							ShippingMethodId = "FlatRate",
							Name = "FlatRate",
							DisplayName = "Flat Rate",
							Description = "Flat Rate",
							Currency = "USD",
							BasePrice = 10,
							IsActive = true,
							ShippingOption = option2
						}
				};
			option.ShippingMethods.Add(shippingMethods[0]);
			option2.ShippingMethods.Add(shippingMethods[1]);

			var repository = new Mock<IShippingRepository>();
			repository.Setup(x => x.ShippingOptions).Returns(() => new[] { option, option2 }.AsQueryable());
			// initializing UnityContainer
			var initializedLocator = Locator;
			// mocking the IShippingRepository into UnityContainer as SimpleShippingGateway resolves it.
			_container.RegisterInstance(repository.Object);

			var activity = new ProcessShipmentActivity();
			var result = InvokeActivity(activity, orderGroup);
			var order = result.OrderGroup;

			foreach (var shipment in order.OrderForms[0].Shipments)
			{
				Assert.True(shipment.ShippingCost == 10m);
			}
		}