public static Task <string> Run(ShopperContext context)
        {
            var watch = new Stopwatch();

            watch.Start();

            try
            {
                var container = context.ShopsContainer();

                Console.WriteLine($"Begin {ScenarioName}");

                var orderId = BuySplitShipment.Run(context).Result;
                if (!string.IsNullOrEmpty(orderId))
                {
                    OrdersUX.HoldOrder(orderId);
                }

                var order = Orders.GetOrder(container, orderId);

                // order.Totals.GrandTotal.Amount.Should().Be(187.03000M);
                if (order.Totals.GrandTotal.Amount != 180.40M)
                {
                    ConsoleExtensions.WriteColoredLine(ConsoleColor.Red, $"GrandTotal Incorrect - Expecting:{180.40M} Actual:{order.Totals.GrandTotal.Amount}");
                }
                var lineToDelete = order.Lines.First();

                var action = new EntityView {
                    Action = "DeleteLineItem", EntityId = orderId, ItemId = lineToDelete.Id
                };
                container.DoAction(action).GetValue();

                watch.Stop();

                Console.WriteLine($"End {ScenarioName} - {watch.ElapsedMilliseconds} ms");

                return(Task.FromResult(orderId));
            }
            catch (Exception ex)
            {
                ConsoleExtensions.WriteColoredLine(ConsoleColor.Red, $"Exception in Scenario {ScenarioName} (${ex.Message}) : Stack={ex.StackTrace}");
                return(null);
            }
        }
示例#2
0
        public static string Run(ShopperContext context)
        {
            using (new SampleBuyScenarioScope())
            {
                try
                {
                    var container = context.ShopsContainer();

                    var orderId = BuySplitShipment.Run(context);
                    if (!string.IsNullOrEmpty(orderId))
                    {
                        OrdersUX.HoldOrder(orderId);
                    }

                    var order = Orders.GetOrder(container, orderId);
                    if (order.Totals.GrandTotal.Amount != 180.40M)
                    {
                        ConsoleExtensions.WriteColoredLine(
                            ConsoleColor.Red,
                            $"GrandTotal Incorrect - Expecting:{180.40M} Actual:{order.Totals.GrandTotal.Amount}");
                    }

                    var lineToDelete = order.Lines.First();
                    var action       = new EntityView
                    {
                        Action   = "DeleteLineItem",
                        EntityId = orderId,
                        ItemId   = lineToDelete.Id
                    };
                    container.DoAction(action).GetValue();
                    return(orderId);
                }
                catch (Exception ex)
                {
                    ConsoleExtensions.WriteColoredLine(
                        ConsoleColor.Red,
                        $"Exception in Scenario {ScenarioName} (${ex.Message}) : Stack={ex.StackTrace}");
                    return(null);
                }
            }
        }
示例#3
0
        public static string Run(ShopperContext context)
        {
            using (new SampleBuyScenarioScope())
            {
                try
                {
                    var container = context.ShopsContainer();

                    var orderId = BuySplitShipment.Run(context);
                    if (!string.IsNullOrEmpty(orderId))
                    {
                        OrdersUX.HoldOrder(orderId);
                    }

                    var journalizedOrdersMetadata =
                        container.GetListMetadata($"JournalEntries-ByEntity-{orderId}").GetValue();
                    System.Console.WriteLine(
                        $"List:{journalizedOrdersMetadata.ListName} Count:{journalizedOrdersMetadata.Count}");

                    var journalizedOrdersList = container.GetList(
                        $"JournalEntries-ByEntity-{orderId}",
                        "Sitecore.Commerce.Plugin.Journaling.JournalEntry, Sitecore.Commerce.Plugin.Journaling",
                        0,
                        10)
                                                .Expand("Items")
                                                .GetValue();

                    journalizedOrdersList.TotalItemCount.Should().Be(2);

                    return(orderId);
                }
                catch (Exception ex)
                {
                    ConsoleExtensions.WriteColoredLine(
                        ConsoleColor.Red,
                        $"Exception in Scenario {ScenarioName} (${ex.Message}) : Stack={ex.StackTrace}");
                    return(null);
                }
            }
        }
示例#4
0
        public static Task <string> Run(ShopperContext context)
        {
            var watch = new Stopwatch();

            watch.Start();

            try
            {
                var container = context.ShopsContainer();

                Console.WriteLine($"Begin {ScenarioName}");

                var orderId = BuySplitShipment.Run(context).Result;
                if (!string.IsNullOrEmpty(orderId))
                {
                    OrdersUX.HoldOrder(orderId);
                }

                var journalizedOrdersMetadata = container.GetListMetadata($"JournalEntries-ByEntity-{orderId}").GetValue();
                Console.WriteLine($"List:{journalizedOrdersMetadata.ListName} Count:{journalizedOrdersMetadata.Count}");


                var journalizedOrdersList = container.GetList($"JournalEntries-ByEntity-{orderId}",
                                                              "Sitecore.Commerce.Plugin.Journaling.JournalEntry, Sitecore.Commerce.Plugin.Journaling", 0, 10).Expand("Items").GetValue();

                journalizedOrdersList.TotalItemCount.Should().Be(2);

                watch.Stop();

                Console.WriteLine($"End {ScenarioName} - {watch.ElapsedMilliseconds} ms");

                return(Task.FromResult(orderId));
            }
            catch (Exception ex)
            {
                ConsoleExtensions.WriteColoredLine(ConsoleColor.Red, $"Exception in Scenario {ScenarioName} (${ex.Message}) : Stack={ex.StackTrace}");
                return(null);
            }
        }