Exemple #1
0
        private static void SetFulfillment_ShipToMe()
        {
            using (new SampleMethodScope())
            {
                var orderId = Buy3Items.Run(new AnonymousCustomerJeff().Context);
                orderId.Should().NotBeNull();
                HoldOrder(orderId);

                var view = Proxy.GetValue(
                    ShopsContainer.GetEntityView(
                        orderId,
                        "OrderFulfillmentDetails",
                        "SelectFulfillmentOption",
                        string.Empty));
                view.Should().NotBeNull();
                view.Policies.Should().BeEmpty();
                view.Properties.Should().NotBeEmpty();
                view.ChildViews.Should().BeEmpty();
                view.Properties.FirstOrDefault(p => p.Name.Equals("Option")).Value = "ShipToMe";

                var action = Proxy.DoCommand(ShopsContainer.DoAction(view));
                action.Messages.Any(m => m.Code.Equals("error", StringComparison.OrdinalIgnoreCase)).Should().BeFalse();

                view = action.Models.OfType <EntityView>().FirstOrDefault(v => v.Name.Equals(view.Name));
                view.Should().NotBeNull();
                view?.Policies.Should().BeEmpty();
                view?.Properties.Should().NotBeEmpty();
                view.Properties.FirstOrDefault(p => p.Name.Equals("Country")).Value = "CA";
                action = Proxy.DoCommand(ShopsContainer.DoAction(view));
                action.Messages.Any(m => m.Code.Equals("error", StringComparison.OrdinalIgnoreCase)).Should().BeFalse();

                view = action.Models.OfType <EntityView>().FirstOrDefault(v => v.Name.Equals(view.Name));
                view.Should().NotBeNull();
                view?.Policies.Should().BeEmpty();
                view?.Properties.Should().NotBeEmpty();
                view.Properties.FirstOrDefault(p => p.Name.Equals("AddressName")).Value   = "Home";
                view.Properties.FirstOrDefault(p => p.Name.Equals("State")).Value         = "ON";
                view.Properties.FirstOrDefault(p => p.Name.Equals("FirstName")).Value     = "first name";
                view.Properties.FirstOrDefault(p => p.Name.Equals("LastName")).Value      = "last name";
                view.Properties.FirstOrDefault(p => p.Name.Equals("Address1")).Value      = "123 street";
                view.Properties.FirstOrDefault(p => p.Name.Equals("Address2")).Value      = string.Empty;
                view.Properties.FirstOrDefault(p => p.Name.Equals("City")).Value          = "city";
                view.Properties.FirstOrDefault(p => p.Name.Equals("ZipPostalCode")).Value = "postalCode";
                view.Properties.FirstOrDefault(p => p.Name.Equals("PhoneNumber")).Value   = "phoneNumber";
                action = Proxy.DoCommand(ShopsContainer.DoAction(view));
                action.Messages.Any(m => m.Code.Equals("error", StringComparison.OrdinalIgnoreCase)).Should().BeFalse();

                view = action.Models.OfType <EntityView>().FirstOrDefault(v => v.Name.Equals(view.Name));
                view.Should().NotBeNull();
                view?.Policies.Should().BeEmpty();
                view?.Properties.Should().NotBeEmpty();
                view.Properties.FirstOrDefault(p => p.Name.Equals("FulfillmentOptionName")).Value =
                    "B146622D-DC86-48A3-B72A-05EE8FFD187A";
                action = Proxy.DoCommand(ShopsContainer.DoAction(view));
                action.Messages.Any(m => m.Code.Equals("error", StringComparison.OrdinalIgnoreCase)).Should().BeFalse();
            }
        }
        private static void SetOrderStatus()
        {
            using (new SampleMethodScope())
            {
                var container = new AnonymousCustomerJeff();

                var orderId = Buy3Items.Run(container.Context);
                var result  = Proxy.DoCommand(
                    new AnonymousCustomerJeff().Context.ShopsContainer().SetOrderStatus(orderId, "CustomStatus"));
                result.Messages.Should().NotContainErrors();

                var order = GetOrder(container.Context.ShopsContainer(), orderId);
                order.Should().NotBeNull();
                order.Status.Should().Be("CustomStatus");
            }
        }
Exemple #3
0
        private static void SetOrderStatus()
        {
            Console.WriteLine("Set order status");

            var container = new AnonymousCustomerJeff();

            var orderId = Buy3Items.Run(container.Context).Result;
            var result  = Proxy.DoCommand(new AnonymousCustomerJeff().Context.ShopsContainer().SetOrderStatus(orderId, "CustomStatus"));

            result.Messages.Any(m => m.Code.Equals("error", StringComparison.OrdinalIgnoreCase)).Should().BeFalse();

            var order = GetOrder(container.Context.ShopsContainer(), orderId);

            order.Should().NotBeNull();
            order.Status.Should().Be("CustomStatus");
        }
        public static void RunScenarios()
        {
            var value = Settings.Default.RequestedTestRuns;

            _requestedTestRuns = value;

            var opsUser = new DevOpAndre();

            Randomizer.Seed = new Random(3897234); // Set the randomizer seed if you wish to generate repeatable data sets.
            var testParties = new Faker <Party>()
                              .RuleFor(u => u.FirstName, f => f.Name.FirstName())
                              .RuleFor(u => u.LastName, f => f.Name.LastName())
                              .RuleFor(u => u.Email, (f, u) => f.Internet.Email(u.FirstName, u.LastName))
                              .RuleFor(u => u.AddressName, f => "FulfillmentPartyName")
                              .RuleFor(u => u.Address1, f => f.Address.StreetAddress(true))
                              .RuleFor(u => u.City, f => f.Address.City())
                              .RuleFor(u => u.StateCode, f => "WA")
                              .RuleFor(u => u.State, f => "Washington")
                              .RuleFor(u => u.ZipPostalCode, f => "93612")
                              .RuleFor(u => u.CountryCode, f => "US")
                              .RuleFor(u => u.Country, f => "United States")
                              .FinishWith((f, u) => { System.Console.WriteLine($"BogusUser Address1={u.Address1}|City={u.City}"); });

            using (new SampleScenarioScope("Orders"))
            {
                System.Console.ForegroundColor = ConsoleColor.Green;
                System.Console.WriteLine("---------------------------------------------------");
                System.Console.WriteLine($"Requested Runs: {_requestedTestRuns}");
                System.Console.WriteLine("---------------------------------------------------");
                System.Console.ForegroundColor = ConsoleColor.Cyan;

                for (var i = 1; i <= _requestedTestRuns; i++)
                {
                    try
                    {
                        //Anonymous Customer Jeff Order Samples
                        var bogusParty = testParties.Generate();
                        var jeff       = new AnonymousCustomerJeff();
                        jeff.Context.Components.OfType <ElectronicFulfillmentComponent>().First().EmailAddress =
                            bogusParty.Email;
                        var physicalFulfillmentComponent = jeff.Context.Components
                                                           .OfType <PhysicalFulfillmentComponent>()
                                                           .FirstOrDefault();
                        if (physicalFulfillmentComponent != null)
                        {
                            physicalFulfillmentComponent.ShippingParty = bogusParty;
                        }

                        var danaHab = new RegisteredHabitatCustomerDana();
                        bogusParty = testParties.Generate();
                        danaHab.Context.Components.OfType <ElectronicFulfillmentComponent>().First().EmailAddress =
                            bogusParty.Email;
                        physicalFulfillmentComponent = danaHab.Context.Components.OfType <PhysicalFulfillmentComponent>()
                                                       .FirstOrDefault();
                        if (physicalFulfillmentComponent != null)
                        {
                            physicalFulfillmentComponent.ShippingParty = bogusParty;
                        }

                        danaHab.Context.CustomerId = AddCustomer(
                            danaHab.Context.Components.OfType <ElectronicFulfillmentComponent>().First().EmailAddress,
                            danaHab.Context,
                            bogusParty.FirstName,
                            bogusParty.LastName);

                        // RegisteredCustomer Dana Order Samples
                        var danaAdv = new RegisteredCustomerDana();
                        bogusParty = testParties.Generate();
                        danaAdv.Context.Components.OfType <ElectronicFulfillmentComponent>().First().EmailAddress =
                            bogusParty.Email;
                        danaAdv.Context.CustomerId = AddCustomer(
                            danaAdv.Context.Components.OfType <ElectronicFulfillmentComponent>().First().EmailAddress,
                            danaAdv.Context,
                            bogusParty.FirstName,
                            bogusParty.LastName);

                        var lastSimplePhysical = SimplePhysical2Items.Run(jeff.Context);
                        var lastGiftCardOrder  = BuyGiftCards.Run(jeff.Context);
                        _createdGiftCard = jeff.Context.GiftCards.First();

                        var lastBuyWithGiftCard = BuyWithGiftCard.Run(jeff.Context);

                        SimplePhysicalRtrn15Coupon.Run(jeff.Context);
                        AddRemovePayment.Run(jeff.Context);
                        AddRemoveCoupon.Run(jeff.Context);

                        UseLimitedCouponMoreThanOnce.Run(jeff.Context);

                        OnSaleItem.Run(jeff.Context);
                        BuyBackOrderedItem.Run(jeff.Context);
                        BuyPreOrderableItem.Run(jeff.Context);
                        BuyAvailabilitySplitItem.Run(jeff.Context);
                        AddRemoveCartLine.Run(jeff.Context);
                        var lastSplitShipment = BuySplitShipment.Run(jeff.Context);

                        ////International
                        var katrina = new InternationalShopperKatrina();

                        var result = Proxy.GetValue(
                            katrina.Context.ShopsContainer()
                            .SellableItems.ByKey("Adventure Works Catalog,AW055 01,33")
                            .Expand(
                                "Components($expand=ChildComponents($expand=ChildComponents($expand=ChildComponents)))"));
                        result.Should().NotBeNull();
                        result.ListPrice.CurrencyCode.Should().Be("EUR");
                        result.ListPrice.Amount.Should().Be(1.0M);

                        ////These samples leverage EntityViews and EntityActions
                        ////For post order management
                        ////Place a Split shipment order and then put it on hold
                        SplitShipmentOnHold.Run(jeff.Context);
                        ////Place a Split shipment order, place it on hold and delete one of the lines
                        SplitShipmentThenDeleteLine.Run(jeff.Context);

                        ////Retrieve the Business User "View" for the SplitShipment end order.  The Order should still be in a Pending State
                        Proxy.GetValue(
                            jeff.Context.ShopsContainer()
                            .GetEntityView(lastSplitShipment, "Master", string.Empty, string.Empty));

                        var cancelOrderId = Buy3Items.Run(jeff.Context);
                        if (!string.IsNullOrEmpty(cancelOrderId))
                        {
                            CancelOrder(cancelOrderId);
                        }

                        ////RegisteredCustomer Dana Order Samples
                        SimplePhysical2Items.Run(danaAdv.Context);
                        BuyGiftCards.Run(danaAdv.Context);
                        BuyWarranty.Run(danaHab.Context, 1);

                        danaHab.GoShopping();

                        //Force the pending orders Minion to run
                        RunPendingOrdersMinion(opsUser.Context);

                        //Force the Released Orders Minion to run
                        RunReleasedOrdersMinion(opsUser.Context);

                        //The Following represent examples of using the Business User (BizOps) Api to handle Orders.
                        //At this stage, the orders have been released and only actions allowed on Released or Problem orders can occur

                        //Get the last SimplePhysical order to show how it is changed by the Minions
                        var orderMaster = Proxy.GetEntityView(
                            jeff.Context.ShopsContainer(),
                            lastSimplePhysical,
                            "Master",
                            string.Empty,
                            string.Empty);
                        if (!orderMaster.ChildViews.Any(p => p.Name.EqualsIgnoreCase("Shipments")))
                        {
                            ConsoleExtensions.WriteErrorLine($"LastSimplePhysical.MissingShipments: OrderId={lastSimplePhysical}");
                        }

                        ////Get the last SimplePhysical order to show how it is changed by the Minions
                        var lastGiftCardMaster = Proxy.GetEntityView(
                            jeff.Context.ShopsContainer(),
                            lastGiftCardOrder,
                            "Master",
                            string.Empty,
                            string.Empty);

                        ////There should not be a Shipments child EntityView because this was a Digital order
                        lastGiftCardMaster.ChildViews.Count(p => p.Name == "Shipments").Should().Be(0);

                        var giftCardNew = jeff.Context.ShopsContainer()
                                          .GiftCards.ByKey("Entity-GiftCard-" + _createdGiftCard)
                                          .Expand("Components($expand=ChildComponents)")
                                          .GetValue() as GiftCard;
                        giftCardNew.Should().NotBeNull();

                        var lastBuyWithGiftCardView = Proxy.GetEntityView(
                            jeff.Context.ShopsContainer(),
                            lastBuyWithGiftCard,
                            "Master",
                            string.Empty,
                            string.Empty);
                        var salesActivities =
                            lastBuyWithGiftCardView.ChildViews.First(p => p.Name == "SalesActivities") as EntityView;
                        salesActivities.ChildViews.Count.Should().Be(2);

                        // Example of updating the Order Status from via a service.  This is for external systems to push status updates
                        SetOrderStatus();
                    }
                    catch (Exception ex)
                    {
                        ConsoleExtensions.WriteColoredLine(ConsoleColor.Red, $"Test Exception - {ex.Message}");
                        ConsoleExtensions.WriteColoredLine(ConsoleColor.Red, $"Test Exception - {ex.StackTrace}");
                    }

                    System.Console.ForegroundColor = ConsoleColor.Cyan;
                    System.Console.WriteLine("---------------------------------------------------");
                    System.Console.WriteLine($"Test pass {i} of {_requestedTestRuns}");
                    System.Console.WriteLine($"Orders:{_totalOrders} Dollars:{_totalOrderDollars}");
                    System.Console.ForegroundColor = ConsoleColor.Cyan;
                }
            }
        }