コード例 #1
0
ファイル: CartManagerTest.cs プロジェクト: Elta20042004/YoYo
 public void Serialize()
 {
     CartManager manager = new CartManager(new CookieUserDataRepository());
     manager.AddProduct(1);
     manager.AddProduct(2);
     List<int> current = manager.GetProducts();
 }
コード例 #2
0
ファイル: TireManager.cs プロジェクト: MonteTribal/Assets
 void Start()
 {
     cart = GetComponent<CartManager>();
     if(tires.Count == 0)
     {
         FindTires();
     }
 }
コード例 #3
0
        public async Task RemoveFromCart_WhitInValidProductId_ShouldThrow()
        {
            //Arrange
            var db = this.SetDb();

            await this.SeedProducts(db);

            var productRepo = new Repository <Product>(db);
            var wrapper     = new TestCartSessionWrapper();
            var cartManager = new CartManager(wrapper);

            var cartService = new CartService(productRepo, cartManager);

            await cartService.AddToCart(1);

            //Assert
            await Assert.ThrowsAsync <NullReferenceException>(async() => await cartService.RemoveFromCart(3));
        }
コード例 #4
0
        public void TestAddNewPromotionRule()
        {
            PromotionEngine promotionEngine     = new PromotionEngine();
            CartManager     promotedCartManager = new CartManager(new PromotionEngine());
            Product         product1            = new Product()
            {
                Id = 1, Name = "A", Price = 50
            };
            Product product2 = new Product()
            {
                Id = 2, Name = "B", Price = 30
            };
            Product product3 = new Product()
            {
                Id = 3, Name = "C", Price = 20
            };
            Product product4 = new Product()
            {
                Id = 4, Name = "D", Price = 15
            };

            Cart cart = new Cart()
            {
                Id = 1
            };

            cart.AddItems(new CartItem()
            {
                Product = product1, Quantity = 1
            });
            cart.AddItems(new CartItem()
            {
                Product = product2, Quantity = 1
            });
            cart.AddItems(new CartItem()
            {
                Product = product3, Quantity = 1
            });
            int expected = 100;
            int actual;

            actual = promotionEngine.ApplyPromotion(cart);
            Assert.AreEqual(expected, actual);
        }
コード例 #5
0
        public async Task GetAllItemsPerOrder_WithTwoDifferentItems_ShouldReturnCollectionOfTwoItems()
        {
            //Arrange
            var db = this.SetDb();

            await this.SeedProducts(db);

            await this.SeedUser(db);

            var productRepo = new Repository <Product>(db);

            var repo        = new Repository <Order>(db);
            var userRepo    = new Repository <CakeItUser>(db);
            var wrapper     = new TestCartSessionWrapper();
            var cartManager = new CartManager(wrapper);

            var item1 = new Item()
            {
                Product = await productRepo.GetByIdAsync(1), Quantity = 2
            };
            var item2 = new Item()
            {
                Product = await productRepo.GetByIdAsync(2), Quantity = 1
            };

            cartManager.SetCartItem(new List <Item> {
                item1, item2
            });

            var orderService = new OrderService(repo, userRepo, cartManager, this.Mapper);

            var userName = this.user.UserName;

            await orderService.CreateOrder(userName);

            //Act
            var result        = orderService.GetAllItemsPerOrder(1);
            var expectedCount = 2
            ;
            var actualCount = result.Count();

            //Assert
            Assert.Equal(expectedCount, actualCount);
        }
コード例 #6
0
        public void GetCartByUserId_InvalidUserId_UserCart()
        {
            //Arrange
            var options = GetContextOptions();

            using (var context = new ApplicationDbContext(options))
            {
                var cartManager = new CartManager(context);
                var userId      = "abcd";

                //Act
                var cart = cartManager.GetCartByUserId(userId);

                //Assert
                Assert.IsNull(cart);

                context.Database.EnsureDeleted();
            }
        }
        public JsonResult Setup()
        {
            try
            {
                var response = CartManager.TestSimulationSetUp(CommerceUserContext.Current.UserId);
                var result   = new BaseApiModel();

                if (!response)
                {
                    result.SetError("Test Simulation Failed!");
                }

                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                return(Json(new ErrorApiModel("Setup", e), JsonRequestBehavior.AllowGet));
            }
        }
コード例 #8
0
        public void UndoAddProductTest()
        {
            var rp = new TestReceiptPrinter();
            var m  = new CartManager(new Cart(), rp, new DiscountsProvider());
            var c1 = TestProducts.Cars.First();
            var c2 = TestProducts.Cars.Skip(1).First();

            m.AddProduct(c1);
            m.AddProduct(c1);
            m.AddProduct(c2);

            m.Undo();

            m.PrintReceipt();
            var state = rp.CartState;

            Assert.Equal(1, state.Products.Count);
            Assert.Equal(2, state.Products[c1]);
        }
コード例 #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CheckoutController" /> class.
        /// </summary>
        /// <param name="cartManager">The cart manager.</param>
        /// <param name="orderManager">The order manager.</param>
        /// <param name="accountManager">The account manager.</param>
        /// <param name="paymentManager">The payment manager.</param>
        /// <param name="shippingManager">The shipping manager.</param>
        /// <param name="contactFactory">The contact factory.</param>
        public CheckoutController(
            [NotNull] CartManager cartManager,
            [NotNull] OrderManager orderManager,
            [NotNull] AccountManager accountManager,
            [NotNull] PaymentManager paymentManager,
            [NotNull] ShippingManager shippingManager,
            [NotNull] ContactFactory contactFactory)
            : base(accountManager, contactFactory)
        {
            Assert.ArgumentNotNull(cartManager, "cartManager");
            Assert.ArgumentNotNull(orderManager, "orderManager");
            Assert.ArgumentNotNull(paymentManager, "paymentManager");
            Assert.ArgumentNotNull(shippingManager, "shippingManager");

            this.CartManager     = cartManager;
            this.OrderManager    = orderManager;
            this.PaymentManager  = paymentManager;
            this.ShippingManager = shippingManager;
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: ynssynk/GameStoreDemo
        static void Main(string[] args)
        {
            User user1 = new User()
            {
                Id = 1, FirstName = "Yunus", LastName = "Yanık", DateOfYear = 1993, UserName = "******", NationalityId = 12345
            };

            UserManager userManager = new UserManager(new UserCheckManager());

            userManager.Add(user1);
            Game game1 = new Game
            {
                CategoryId = 1, Description = "FPS", Developer = "SpaceY", Id = 1, Name = "Space Killer", Price = 15, Publisher = "SpaceY", ReleaseDate = new DateTime(2021)
            };
            CartManager cartManager = new CartManager(new MobilPayAdapter());

            cartManager.AddtoCart(game1, 1);
            cartManager.Purchase(user1);
        }
コード例 #11
0
        public ActionResult RemoveFromBasket(int itemid)
        {
            CartManager CartManager = new CartManager(this.sessionManager, this.db);

            int     itemCount      = CartManager.RemoveFromCart(itemid);
            int     cartItemsCount = CartManager.GetCartItemsCount();
            decimal cartTotal      = CartManager.GetCartTotalPrice();

            // Return JSON to process it in JavaScript
            var result = new BasketRemoveViewModel
            {
                RemoveItemId     = itemid,
                RemovedItemCount = itemCount,
                CartTotal        = cartTotal,
                CartItemsCount   = cartItemsCount
            };

            return(Json(result));
        }
コード例 #12
0
        public ActionResult IndexPost()
        {
            try
            {
                User user = new User();
                user.Id       = 1;
                user.Username = "******"; //TODO: User aus Session nehmen!!
                CalenderElement calElement = CalenderElementManager.GetCalenderElementWithId(Int32.Parse(Request.Form["id"]));
                CartManager.AddElementToCart(calElement, user);
                ViewBag.Message = "Film " + calElement.Movie.Title + " mit Startzeit " + calElement.Start + " wurde zu Ihrem Einkaufswagen hinzugefügt.";
            }
            catch (Exception e)
            {
                ViewBag.Message = "Fehler: " + e.Message;
            }
            List <CalenderElement> elements = CalenderElementManager.GetAllCalenderElements();

            return(View(elements));
        }
コード例 #13
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");
            UserManager userManager = new UserManager();

            if (userManager.ValidateUserLogin())
            {
                int         bookId      = Convert.ToInt32((context.Request["bookId"]));
                BookManager bookManager = new BookManager();
                Model.Book  bookModel   = bookManager.GetModel(bookId);
                if (bookModel != null)
                {
                    int         userId      = ((Model.User)context.Session["userInfo"]).Id;
                    CartManager cartManager = new CartManager();
                    //Model.Book bookModel = bookManager.GetModel(bookId);
                    Model.Cart cartModel = cartManager.GetModel(userId, bookId);
                    if (cartModel != null)
                    {
                        cartModel.Count = cartModel.Count + 1;
                        cartManager.Update(cartModel);
                    }
                    else
                    {
                        Cart modelCart = new Cart();
                        modelCart.Count = 1;
                        modelCart.Book  = bookModel;
                        modelCart.User  = (User)context.Session["userInfo"];
                        cartManager.Add(modelCart);
                    }

                    context.Response.Write("ok: Success");
                }
                else
                {
                    context.Response.Write("no: No Such Stuff");
                }
            }
            else
            {
                context.Response.Write("login: Please Login");
            }
        }
コード例 #14
0
ファイル: Program.cs プロジェクト: JoeMumm/AlbumApp-NG-Net452
        static void Main(string[] args)
        {
            GenericPrincipal principal = new GenericPrincipal(
                new GenericIdentity("Admin"), new string[] { "AlbumAppAdmin" });

            Thread.CurrentPrincipal = principal;

            Console.WriteLine("Starting up services ...");
            Console.WriteLine("");

            ObjectBase.Container         = AutoFacLoader.Init();
            AutofacHostFactory.Container = AutoFacLoader.Init();
            using (var container = AutofacHostFactory.Container) // ObjectBase.Container
            {
                SM.ServiceHost hostAccountManager   = new SM.ServiceHost(typeof(AccountManager));
                SM.ServiceHost hostInventoryManager = new SM.ServiceHost(typeof(InventoryManager));
                SM.ServiceHost hostCartManager      = new SM.ServiceHost(typeof(CartManager));
                SM.ServiceHost hostOrderManager     = new SM.ServiceHost(typeof(OrderManager));
                StartService(hostAccountManager, "AccountManager");
                StartService(hostInventoryManager, "InventoryManager");
                StartService(hostCartManager, "CartManager");
                StartService(hostOrderManager, "OrderManager");

                _cartManager = container.Resolve <CartManager>();

                System.Timers.Timer timer = new System.Timers.Timer(60000);
                timer.Elapsed += OnTimerElapsed;
                timer.Start();

                Console.WriteLine("Cart Item monitor started.");
                Console.WriteLine("");
                Console.WriteLine("Press [Enter] to exit.");
                Console.ReadLine();

                timer.Stop();
                Console.WriteLine("Cart Item monitor stopped.");

                StopService(hostAccountManager, "AccountManager");
                StopService(hostInventoryManager, "InventoryManager");
                StopService(hostCartManager, "CartManager");
                StopService(hostOrderManager, "OrderManager");
            }
        }
コード例 #15
0
ファイル: Cart.aspx.cs プロジェクト: dbanks86/OnlineStore
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!Page.IsPostBack)
                {
                    //email stored in cookie
                    var userEmail = CookieManager.GetEmailFromUserCookie();

                    //get cart items of user
                    var cartItems = services.CartService.GetUserCartItems(userEmail, Constants.DATABASE_TABLE_PRODUCTS);

                    if (cartItems.Any())
                    {
                        var cartItemsWebFormDtos = cartItems.Select(cartItem => CartManager.GetNewCartItemWebFormDTO(cartItem));

                        //count of cart items (sum of quantities of all cart items)
                        var cartItemsCount = cartItemsWebFormDtos.Sum(cartItem => cartItem.Quantity);

                        rptCartItems.DataSource = cartItemsWebFormDtos;
                        rptCartItems.DataBind();

                        var subTotal = cartItemsWebFormDtos.Sum(cartItem => cartItem.Price * cartItem.Quantity);

                        //set subtotal info
                        subTotalTd.InnerText  = string.Format("{0:C}", subTotal);
                        lblCartItemCount.Text = string.Format("({0} {1})", cartItemsCount, cartItemsCount == 1 ? "item" : "items");
                    }
                    else
                    {
                        subTotalTd.InnerText  = string.Format("{0:C}", 0);
                        lblCartItemCount.Text = string.Format("({0} {1})", 0, "items");
                        btnCheckout.Visible   = false;
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.LogException(ex, Path.GetFileName(Request.PhysicalPath));
                Server.Transfer(Constants.PAGE_GENERIC_ERROR);
            }
        }
コード例 #16
0
        public void CarManager_Method_TakeCartFromSession_Works_Correctly()
        {
            List <CartItem> mySession = new List <CartItem>();

            Mock <ISessionManager> mockSession    = new Mock <ISessionManager>();
            Mock <ISongRepository> mockRepository = new Mock <ISongRepository>();

            mockSession.Setup(x => x.Set <List <CartItem> >(It.IsAny <string>(),
                                                            It.IsAny <List <CartItem> >())).Callback((string e, List <CartItem> s) => mySession = s);

            mockSession.Setup(x => x.Get <List <CartItem> >(It.IsAny <string>())).Returns(mySession);

            mockRepository.Setup(x => x.Songs).Returns(new Song[] { new Song()
                                                                    {
                                                                        SongId = 1, NameSong = "Test1"
                                                                    },
                                                                    new Song()
                                                                    {
                                                                        SongId = 2, NameSong = "Test2"
                                                                    },
                                                                    new Song()
                                                                    {
                                                                        SongId = 3, NameSong = "Test3"
                                                                    },
                                                                    new Song()
                                                                    {
                                                                        SongId = 4, NameSong = "Test4"
                                                                    } });


            CartManager manager = new CartManager(mockSession.Object, mockRepository.Object);

            manager.Add(1);
            manager.Add(1);
            manager.Add(3);

            var result = manager.TakeCartFromSession();

            mockRepository.Verify(x => x.Songs);
            Assert.AreEqual(2, result.Count);
            Assert.IsInstanceOfType(result, typeof(List <CartItem>));
        }
コード例 #17
0
        public void RemoveMoreProductsThanExistsInCartOfAKind()
        {
            var rp = new TestReceiptPrinter();
            var m  = new CartManager(new Cart(), rp, new DiscountsProvider());
            var c1 = TestProducts.Cars.First();
            var c2 = TestProducts.Cars.Skip(1).First();

            m.AddProduct(c1);
            m.AddProduct(c1);
            m.AddProduct(c1);
            m.AddProduct(c2);

            m.RemoveProduct(c1, 5);

            m.PrintReceipt();
            var state = rp.CartState;

            Assert.Equal(1, state.Products.Count);
            Assert.False(state.Products.ContainsKey(c1));
        }
コード例 #18
0
    protected void UpdateButton_Click(object sender, EventArgs e)
    {
        CartManager manager = new CartManager(this.Cart);

        foreach (RepeaterItem item in CartRepeater.Items)
        {
            int qty = 0;
            if (int.TryParse(((TextBox)item.FindControl("QuantityTextBox")).Text, out qty))
            {
                manager.SetQuantity(item.ItemIndex, qty);
            }
            else
            {
                manager.Remove(item.ItemIndex);
            }
        }
        DeleteSavedCart();
        this.Cart = manager.ShoppingCart;
        BindCart();
    }
コード例 #19
0
        public void Configure(IApplicationBuilder app)
        {
            app.UseDetection();
            app.UseDeveloperExceptionPage();
            app.UseDatabaseErrorPage();
            app.UseStaticFiles();
            app.UseRouting();
            app.UseAuthentication();
            app.UseAuthorization();
            app.UseSession();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
                endpoints.MapRazorPages();
            });

            CartManager.Configure(app.ApplicationServices.GetRequiredService <IHttpContextAccessor>());
        }
コード例 #20
0
        static void Main(string[] args)
        {
            BaseCustomerManager customerManager = new CustomerManager(new CustomerCheckManager());

            Customer customer = new Customer
            {
                Id            = 1,
                FirstName     = "Ahmet",
                LastName      = "Gundogan",
                DateofBirth   = new DateTime(2000, 1, 1),
                NationalityId = "33333"
            };

            customerManager.Save(customer);


            Product game1 = new Product();

            game1.Id       = 1;
            game1.GameName = "First Game";
            game1.Price    = 10;

            Product game2 = new Product();

            game2.Id       = 2;
            game2.GameName = "Second Game";
            game2.Price    = 20;

            CartManager cartManager = new CartManager(customer);

            cartManager.Add(game1);
            cartManager.Add(game2);

            ICampaign campaign = new EndOfYearCampaign();

            // EndOfYearCampaign();
            //HolidayCampain();
            //EndOfSeriesDiscount();

            cartManager.Buy(campaign);
        }
コード例 #21
0
        public void CreateNewCart_NewCart_CartSuccessfullyAdded()
        {
            //Arrange
            var options = GetContextOptions();

            using (var context = new ApplicationDbContext(options))
            {
                var cartManager = new CartManager(context);
                var userId      = CreateFakeUser(context);

                //Act
                var cart = cartManager.CreateNewCart(userId);

                //Assert
                Assert.True(context.Carts.Any(c => c.UserId == userId));
                Assert.AreEqual(context.Carts.Count(c => c.UserId == userId), 1);
                Assert.AreEqual(context.Carts.FirstOrDefault(c => c.UserId == userId), cart);

                context.Database.EnsureDeleted();
            }
        }
コード例 #22
0
        public void GetCartByUserId_ValidUserId_UserCart()
        {
            //Arrange
            var options = GetContextOptions();

            using (var context = new ApplicationDbContext(options))
            {
                var cartManager = new CartManager(context);
                var userId      = CreateFakeUser(context);
                cartManager.CreateNewCart(userId);

                //Act
                var cart = cartManager.GetCartByUserId(userId);

                //Assert
                Assert.IsNotNull(cart);
                Assert.IsTrue(cart.UserId == userId);

                context.Database.EnsureDeleted();
            }
        }
コード例 #23
0
        protected void AddCartButton_Click(object sender, EventArgs e)
        {
            CartManager cartManager = new CartManager();

            if (Session["name"].ToString() == null || Session["name"].ToString() == "")
            {
                Response.Redirect("Lgoin.aspx");
            }
            string cartId = Session["CartId"].ToString();

            if (cartId != null && cartId != "")
            {
                cartManager.AddToCart(Amount.Text, productId, Session["name"].ToString(), cartId);
                Response.Redirect("ShoppingCart.aspx?CartId=" + cartId);
            }
            else
            {
                cartManager.AddToCart(Amount.Text, productId, Session["name"].ToString(), "");
                Response.Redirect("~/");
            }
        }
コード例 #24
0
        public ActionResult ListMyCarts()
        {
            CartManager cartManager;

            if (Session["cart"] != null)
            {
                cartManager = Session["cart"] as CartManager;
            }
            else
            {
                cartManager = new CartManager();
            }

            ListCartsViewModel model = new ListCartsViewModel
            {
                Carts      = cartManager.Carts,
                TotalPrice = cartManager.TotalPrice
            };

            return(View(model));
        }
コード例 #25
0
        public async Task CreateOrder_WithEmptyShoppingCart_ShouldThrow()
        {
            //Arrange
            var db = this.SetDb();

            await this.SeedProducts(db);

            await this.SeedUser(db);

            var repo        = new Repository <Order>(db);
            var userRepo    = new Repository <CakeItUser>(db);
            var wrapper     = new TestCartSessionWrapper();
            var cartManager = new CartManager(wrapper);

            var orderService = new OrderService(repo, userRepo, cartManager, this.Mapper);

            var userName = this.user.UserName;

            //Asser
            await Assert.ThrowsAsync <InvalidOperationException>(async() => await orderService.CreateOrder(userName));
        }
コード例 #26
0
ファイル: CartController.cs プロジェクト: jfkbcc/Shopper
        public IActionResult Index()
        {
            if (!CheckAuthentication())
            {
                return(View());
            }

            var customerId = HttpContext.Session.GetInt32("customer");

            if (customerId != null)
            {
                CartManager cartManager = CustomerManager.GetCustomerCart(dbContext, (int)customerId);
                if (cartManager != null)
                {
                    ViewData["ShoppingCart"] = cartManager.shoppingCart.Items.ToList();
                }
            }

            ViewData["ErrorMsg"] = HttpContext.Request.Query["err"];
            return(View());
        }
コード例 #27
0
        public JsonResult AddCartLines(IEnumerable <AddCartLineInputModel> inputModels)
        {
            try
            {
                Assert.ArgumentNotNull(inputModels, nameof(inputModels));

                var validationResult = this.CreateJsonResult();
                if (validationResult.HasErrors)
                {
                    return(Json(validationResult, JsonRequestBehavior.AllowGet));
                }

                var response = CartManager.AddLineItemsToCart(CommerceUserContext.Current.UserId, inputModels);
                var result   = new BaseApiModel(response.ServiceProviderResult);
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                return(Json(new ErrorApiModel("AddCartLines", e), JsonRequestBehavior.AllowGet));
            }
        }
コード例 #28
0
        public async Task EmptyCart_ShouldEmptyCart()
        {
            //Arange
            var db = this.SetDb();

            await this.SeedProducts(db);

            var productRepo = new Repository <Product>(db);
            var wrapper     = new TestCartSessionWrapper();
            var cartManager = new CartManager(wrapper);

            var cartService = new CartService(productRepo, cartManager);

            await cartService.AddToCart(1);

            //Act
            cartService.EmptyCart();

            //Assert
            Assert.Empty(cartManager.GetCartItem());
        }
コード例 #29
0
        public void ShouldReturnTheNewCartAfterAddID()
        {
            // Arrange
            IReadFromBrowser read   = new FakeReadCookie();
            CartManager      cart   = new CartManager(read);
            List <long>      listID = new List <long>()
            {
                23, 45, 32, 12, 2, 3
            };
            ShoppingCart shoppingCart = new ShoppingCart()
            {
                ProductIDs = listID, UserID = 3
            };

            //Act

            var currentCart = cart.AddProduct(90, shoppingCart);

            //Assert

            Assert.Contains <long>(90, currentCart.ProductIDs);
        }
コード例 #30
0
        public void CartManger_Can_Add_Object()
        {
            List <CartItem>        mySession      = new List <CartItem>();
            Mock <ISessionManager> mockSession    = new Mock <ISessionManager>();
            Mock <ISongRepository> mockRepository = new Mock <ISongRepository>();

            mockSession.Setup(x => x.Set <List <CartItem> >(It.IsAny <string>(),
                                                            It.IsAny <List <CartItem> >())).Callback((string e, List <CartItem> s) => mySession = s);

            mockSession.Setup(x => x.Get <List <CartItem> >(It.IsAny <string>())).Returns(mySession);

            mockRepository.Setup(x => x.Songs).Returns(new Song[] { new Song()
                                                                    {
                                                                        SongId = 1, NameSong = "Test1"
                                                                    },
                                                                    new Song()
                                                                    {
                                                                        SongId = 2, NameSong = "Test2"
                                                                    },
                                                                    new Song()
                                                                    {
                                                                        SongId = 3, NameSong = "Test3"
                                                                    },
                                                                    new Song()
                                                                    {
                                                                        SongId = 4, NameSong = "Test4"
                                                                    } });

            CartManager target = new CartManager(mockSession.Object, mockRepository.Object);

            target.Add(1);
            target.Add(2);
            target.Add(2);

            Assert.AreEqual(2, mySession.Count);
            Assert.AreEqual(1, mySession[0].Song.SongId);
            Assert.AreEqual(2, mySession[1].Song.SongId);
            Assert.AreEqual(2, mySession[1].Quantity);
        }
コード例 #31
0
        public async Task GetAllOrdersByUser_ShouldReturnCollectionOfOrders()
        {
            //Arrange
            var db = this.SetDb();

            await this.SeedProducts(db);

            await this.SeedUser(db);

            var productRepo = new Repository <Product>(db);

            var repo        = new Repository <Order>(db);
            var userRepo    = new Repository <CakeItUser>(db);
            var wrapper     = new TestCartSessionWrapper();
            var cartManager = new CartManager(wrapper);

            var item1 = new Item()
            {
                Product = await productRepo.GetByIdAsync(1), Quantity = 1
            };

            cartManager.SetCartItem(new List <Item> {
                item1
            });

            var orderService = new OrderService(repo, userRepo, cartManager, this.Mapper);

            var userName = this.user.UserName;

            await orderService.CreateOrder(userName);

            //Act
            var orders        = orderService.GetAllOrdersByUser(userName);
            var expectedCount = 1;
            var ectualCount   = orders.Count();

            //Asser
            Assert.Equal(expectedCount, ectualCount);
        }
コード例 #32
0
        public CartServiceTest()
        {
            ICartRepository    cartRepository    = new StubCartRepository();
            IProductRepository productRepository = new StubProductRepository();
            IUserRepository    userRepository    = new StubUserRepository();

            request           = new CartRequest();
            request.UserId    = USER_ID;
            request.ProductId = PRODUCT_ID;
            request.Quantity  = 1;
            AddUserOnRepository(userRepository);
            AddProductOnRepository(productRepository);
            IPointSystemConfigurationRepository configurationRepository = new StubPointSystemConfigurationRepository();

            configurationRepository.AddEntity(new PointSystemConfiguration()
            {
                PropertyName = ESportUtils.LOYALTY_PROPERTY_NAME, PropertyValue = 100
            });
            ICartManager cartManager = new CartManager(cartRepository, new StubCartItemRepository(), productRepository, userRepository, configurationRepository);

            cartService = new CartServiceImpl(cartManager, new SimpleCartDTOBuilder(), new PendingReviewDTOBuilder());
        }
コード例 #33
0
    protected void AddButton_Click(object sender, EventArgs e)
    {
        if (!string.IsNullOrWhiteSpace(CartProduct.ProductLink))
        {
            Response.Redirect(CartProduct.ProductLink);
            return;
        }
        if (!Page.IsValid)
            return;
        DeleteSavedCart();
        if (!AddToGiftRegistry())
            return;

        CartManager manager = new CartManager(this.Cart);
        manager.Add(new CartItem()
        {
            CatalogNumber = CartProduct.CatalogNumber,
            PricePerUnit = CartProduct.SalePrice == 0 ? CartProduct.Price : CartProduct.SalePrice,
            ProductID = CartProduct.ProductID,
            GiftRegistryProductID = WebUtility.GetDecodedIntFromQueryString("GiftRegistryProductID"),
            ProductName = CartProduct.ProductName,
            IsDownloadable = CartProduct.IsDownloadable,
            DownloadURL = CartProduct.DownloadURL,
            IsDownloadKeyRequired = CartProduct.IsDownloadKeyRequired,
            IsDownloadKeyUnique = CartProduct.IsDownloadKeyUnique,
            Quantity = Convert.ToInt32(QtyTextBox.Text),
            ProductOptions = ProductOptionsControl1.SelectedOptions,
            CustomFields = CustomFieldsControl1.CustomFields
        });
        this.Cart = manager.ShoppingCart;
        Response.Redirect("ShoppingCart.aspx");
    }
コード例 #34
0
ファイル: CheckOut.aspx.cs プロジェクト: Elta20042004/YoYo
 public CheckOut()
 {
     _productManager = new CartManager(new CookieUserDataRepository());
 }
コード例 #35
0
ファイル: Site.Master.cs プロジェクト: Elta20042004/YoYo
 public SiteMaster()
 {
     var repository = new CookieUserDataRepository();
     _productManager = new CartManager(repository);
     _rvManager = new RecentlyViewedManager(repository);
 }
コード例 #36
0
ファイル: InputManager.cs プロジェクト: MonteTribal/Assets
 void Start()
 {
     forces = GetComponent<ForcesManager>();
     cart = GetComponent<CartManager>();
     tires = GetComponent<TireManager>();
 }
コード例 #37
0
ファイル: Prod.aspx.cs プロジェクト: Elta20042004/YoYo
 public Prod()
 {
     var repository = new CookieUserDataRepository();
     _cartManager = new CartManager(repository);
     _rvManager = new RecentlyViewedManager(repository);
 }