public void ShouldMapCartBaseFromModel() { // arrange var id = Guid.NewGuid(); var cartModel = new ShoppingCartModel { CustomerGuid = id }; var cartBase = new CartBase(); // act cartBase.MapCartBaseFromModel(cartModel); // assert cartBase.ExternalId.Should().Be(id.ToString("B").ToUpper()); }
/// <summary> /// Runs the processor. /// </summary> /// <param name="args">The arguments.</param> public override void Process(ServicePipelineArgs args) { Assert.ArgumentNotNull(args, "args"); // Prepare request/result objects var request = (GetCartsRequest)args.Request; var result = (GetCartsResult)args.Result; // Creates instance of WCF service client. using (var client = this.GetClient()) { var cartModels = client.GetCarts(); if (!cartModels.Any()) { // Returns empty collection if there are no carts. result.Carts = Enumerable.Empty <CartBase>(); return; } var carts = new List <CartBase>(); // Maps cart lines from NopCommerce cart model to OBEC cart. foreach (var cartModel in cartModels) { var cart = new CartBase(); cart.MapCartBaseFromModel(cartModel); carts.Add(cart); } if (request.UserIds.Any()) { // ToDo: // filter by user id here in some way } result.Carts = carts; } }