예제 #1
0
        public void RemoveShoppingCartProduct_WithCorrectData_ShouldSuccessfullyRemove()
        {
            string errorMessagePrefix = "ShoppingCartsService RemoveShoppingCartProduct() method does not work properly.";

            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            this.SeedData(context);
            this.shoppingCartsService = new ShoppingCartsService(context, new UniShopUsersService(context),
                                                                 new ProductsService(context, new ChildCategoriesService(context, new ParentCategoriesService(context))));

            UniShopUser user      = context.Users.First();
            int         productId = context.Products.First().Id;

            ShoppingCartProduct testShoppingCartProduct = new ShoppingCartProduct
            {
                ProductId      = productId,
                ShoppingCartId = user.ShoppingCartId,
                Quantity       = 2
            };

            context.Add(testShoppingCartProduct);
            context.SaveChanges();

            int expectedCount = user.ShoppingCart.ShoppingCartProducts.Count() - 1;

            bool actualResult = this.shoppingCartsService.RemoveShoppingCartProduct(productId, user.UserName);
            int  actualCount  = user.ShoppingCart.ShoppingCartProducts.Count();

            Assert.True(actualResult, errorMessagePrefix);
            Assert.Equal(expectedCount, actualCount);
        }
예제 #2
0
        public void ReduceQuantity_WithShoppingCartProductQuantityOne_ShouldReturnFalse()
        {
            string errorMessagePrefix = "ShoppingCartsService ReduceQuantity() method does not work properly.";

            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            this.SeedData(context);
            this.shoppingCartsService = new ShoppingCartsService(context, new UniShopUsersService(context),
                                                                 new ProductsService(context, new ChildCategoriesService(context, new ParentCategoriesService(context))));

            UniShopUser user      = context.Users.First();
            int         productId = context.Products.Where(p => p.Quantity == 0).First().Id;

            ShoppingCartProduct testShoppingCartProduct = new ShoppingCartProduct
            {
                ProductId      = productId,
                ShoppingCartId = user.ShoppingCartId,
                Quantity       = 1
            };

            context.Add(testShoppingCartProduct);
            context.SaveChanges();

            int expectedCount = testShoppingCartProduct.Quantity;

            bool actualResult = this.shoppingCartsService.ReduceQuantity(productId, user.UserName);
            int  actualCount  = testShoppingCartProduct.Quantity;

            Assert.False(actualResult, errorMessagePrefix);
            Assert.Equal(expectedCount, actualCount);
        }
 public ShoppingCartsController(
     IShoppingCartsService shoppingCarts,
     ICurrentUserService currentUser)
 {
     this.shoppingCarts = shoppingCarts;
     this.currentUser   = currentUser;
 }
예제 #4
0
 public CartController(UserManager <Account> userManager, IShoppingCartsService shoppingCartsService,
                       IProductsService productsService)
 {
     _shoppingCartsService = shoppingCartsService;
     _productsService      = productsService;
     this.userManager      = userManager;
 }
예제 #5
0
        public void AddShoppingCartProduct_WithExistentShoppingCartProductAndProductQuantityMoreThenOne_ShouldSuccessfullyIncreaseQuantity()
        {
            string errorMessagePrefix = "ShoppingCartsService AddShoppingCartProduct() method does not work properly.";

            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            this.SeedData(context);
            this.shoppingCartsService = new ShoppingCartsService(context, new UniShopUsersService(context),
                                                                 new ProductsService(context, new ChildCategoriesService(context, new ParentCategoriesService(context))));

            UniShopUser user      = context.Users.First();
            int         productId = context.Products.First().Id;

            ShoppingCartProduct testShoppingCartProduct = new ShoppingCartProduct
            {
                ProductId      = productId,
                ShoppingCartId = user.ShoppingCartId,
                Quantity       = 1
            };

            context.Add(testShoppingCartProduct);
            context.SaveChanges();

            ShoppingCartProduct shoppingCartProduct = context.ShoppingCartProducts
                                                      .First(s => s.ShoppingCartId == user.ShoppingCartId && s.ProductId == productId);

            int expectedCount = shoppingCartProduct.Quantity + 1;

            bool actualResult = this.shoppingCartsService.AddShoppingCartProduct(productId, user.UserName);
            int  actualCount  = shoppingCartProduct.Quantity;

            Assert.True(actualResult, errorMessagePrefix);
            Assert.Equal(expectedCount, actualCount);
        }
예제 #6
0
        public RegisterPresenter(IRegisterView view,
                                 IUserFactory userFactory,
                                 IShoppingCartFactory shoppingCartFactory,
                                 IShoppingCartsService shoppingCartsService) : base(view)
        {
            if (userFactory == null)
            {
                throw new ArgumentNullException("User factory cannot be null.");
            }

            if (shoppingCartFactory == null)
            {
                throw new ArgumentNullException("Shopping cart factory cannot be null.");
            }

            if (shoppingCartsService == null)
            {
                throw new ArgumentNullException("Shopping cart repository cannot be null.");
            }

            this.userFactory          = userFactory;
            this.shoppingCartFactory  = shoppingCartFactory;
            this.shoppingCartsService = shoppingCartsService;
            this.View.Registering    += OnRegistering;
            this.View.SigningIn      += OnSigningIn;
        }
예제 #7
0
 public LoginModel(SignInManager <XeonUser> signInManager, ILogger <LoginModel> logger,
                   IUsersService userService, IShoppingCartsService shoppingCartService)
 {
     _signInManager       = signInManager;
     _logger              = logger;
     _userService         = userService;
     _shoppingCartService = shoppingCartService;
 }
예제 #8
0
 public OrdersService(UniShopDbContext context, IUniShopUsersService uniShopUsersService,
                      IShoppingCartsService shoppingCartsService, ISuppliersService suppliersService, IProductsService productsService)
 {
     this.context              = context;
     this.uniShopUsersService  = uniShopUsersService;
     this.shoppingCartsService = shoppingCartsService;
     this.suppliersService     = suppliersService;
     this.productsService      = productsService;
 }
예제 #9
0
 public LoginModel(
     SignInManager <PhotoPavilionUser> signInManager,
     ILogger <LoginModel> logger,
     IShoppingCartsService shoppingCartsService)
 {
     this.signInManager        = signInManager;
     this.logger               = logger;
     this.shoppingCartsService = shoppingCartsService;
 }
예제 #10
0
 public OrdersService(
     ApplicationDbContext dbContext,
     IShoppingCartsService shoppingCartService,
     IMapper mapper)
 {
     this.shoppingCartService = shoppingCartService;
     this.dbContext           = dbContext;
     this.mapper = mapper;
 }
예제 #11
0
 public ShoppingCartController(
     IShoppingCartsService shoppingCartService,
     IProductsService productSevice,
     IMapper mapper)
 {
     this.shoppingCartService = shoppingCartService;
     this.productSevice       = productSevice;
     this.mapper = mapper;
 }
예제 #12
0
 public ShoppingCartsController(
     IShoppingCartsService shoppingCartService,
     IUsersService usersService,
     IProductsService productsService)
 {
     this.shoppingCartService = shoppingCartService;
     this.usersService        = usersService;
     this.productsService     = productsService;
 }
 public ShoppingCartsController(IShoppingCartsService cartsService,
                                IShopProductsService shopProductsService,
                                IDeletableEntityRepository <FamilyKitchenUser> userRepository,
                                IMapper mapper)
 {
     this.cartsService        = cartsService;
     this.shopProductsService = shopProductsService;
     this.userRepository      = userRepository;
     this.mapper = mapper;
 }
 public LoginModel(SignInManager <FamilyKitchenUser> signInManager,
                   ILogger <LoginModel> logger,
                   UserManager <FamilyKitchenUser> userManager,
                   IShoppingCartsService shoppingCartsService)
 {
     this.userManager          = userManager;
     this.signInManager        = signInManager;
     this.logger               = logger;
     this.shoppingCartsService = shoppingCartsService;
 }
 public FamiliesService(IDeletableEntityRepository <Family> familiesRepository,
                        IDeletableEntityRepository <FamilyKitchenUser> usersRepository,
                        IShoppingCartsService shoppingCartsService,
                        UserManager <FamilyKitchenUser> userManager)
 {
     this.familiesRepository   = familiesRepository;
     this.usersRepository      = usersRepository;
     this.shoppingCartsService = shoppingCartsService;
     this.userManager          = userManager;
 }
예제 #16
0
 public OrdersController(ISuppliersService suppliersService,
                         IAddressesService addressesService, IShoppingCartsService shoppingCartsService
                         , IUniShopUsersService uniShopUsersService, IOrderService orderService)
 {
     this.suppliersService     = suppliersService;
     this.addressesService     = addressesService;
     this.shoppingCartsService = shoppingCartsService;
     this.uniShopUsersService  = uniShopUsersService;
     this.orderService         = orderService;
 }
예제 #17
0
 public OrdersController(
     IOrdersService ordersService,
     IUsersService usersService,
     IAddressesService addressesService,
     IShoppingCartsService shoppingCartsService)
 {
     this.ordersService        = ordersService;
     this.usersService         = usersService;
     this.addressesService     = addressesService;
     this.shoppingCartsService = shoppingCartsService;
 }
예제 #18
0
        public async Task InvokeAsync(
            HttpContext context,
            UserManager <UnravelTravelUser> userManager,
            RoleManager <ApplicationRole> roleManager,
            UnravelTravelDbContext dbContext,
            IShoppingCartsService shoppingCartsService)
        {
            await SeedUserInRoles(userManager, shoppingCartsService);

            await this.next(context);
        }
예제 #19
0
 public ExternalLoginModel(
     SignInManager <UnravelTravelUser> signInManager,
     UserManager <UnravelTravelUser> userManager,
     ILogger <ExternalLoginModel> logger,
     IShoppingCartsService shoppingCartsService)
 {
     this.signInManager        = signInManager;
     this.userManager          = userManager;
     this.logger               = logger;
     this.shoppingCartsService = shoppingCartsService;
 }
예제 #20
0
        public CartPresenter(ICartView view,
                             IShoppingCartsService shoppingCartsService) : base(view)
        {
            if (shoppingCartsService == null)
            {
                throw new ArgumentNullException("Shopping carts service cannot be null.");
            }

            this.shoppingCartsService   = shoppingCartsService;
            this.View.Initial          += OnInitial;
            this.View.RemovingFromCart += OnRemovingFromCart;
        }
        public ShoppingCartsServiceTests()
        {
            this.InitializeMapper();
            this.InitializeDatabaseAndRepositories();
            this.InitializeFields();

            this.shoppingCartsService = new ShoppingCartsService(
                this.usersRepository,
                this.productsRepository,
                this.shoppingCartProductsRepository,
                this.shoppingCartsRepository);
        }
예제 #22
0
 public OrderProductsService(
     IDeletableEntityRepository <OrderProduct> orderProductsRepository,
     IDeletableEntityRepository <PhotoPavilionUser> usersRepository,
     IDeletableEntityRepository <Product> productsRepository,
     IShoppingCartsService shoppingCartsService,
     IEmailSender emailSender)
 {
     this.orderProductsRepository = orderProductsRepository;
     this.usersRepository         = usersRepository;
     this.productsRepository      = productsRepository;
     this.shoppingCartsService    = shoppingCartsService;
     this.emailSender             = emailSender;
 }
예제 #23
0
 public OrdersController(
     IUsersService usersService,
     IOrdersService orderService,
     IShoppingCartsService shoppingCartService,
     IMapper mapper,
     IErrorsService errorService)
 {
     this.usersService        = usersService;
     this.orderService        = orderService;
     this.shoppingCartService = shoppingCartService;
     this.mapper       = mapper;
     this.errorService = errorService;
 }
예제 #24
0
 public OrdersController(IAdressesService adressesService, IUsersService usersService,
                         IOrdersService orderService, IShoppingCartsService shoppingCartService,
                         ISuppliersService suppliersService, IMapper mapper, IEmailSender emailSender, IViewRender viewRender)
 {
     this.usersService        = usersService;
     this.adressesService     = adressesService;
     this.orderService        = orderService;
     this.shoppingCartService = shoppingCartService;
     this.suppliersService    = suppliersService;
     this.mapper      = mapper;
     this.emailSender = emailSender;
     this.viewRender  = viewRender;
 }
예제 #25
0
 public TicketsService(
     IRepository <Ticket> ticketsRepository,
     IRepository <UnravelTravelUser> usersRepository,
     IRepository <Activity> activitiesRepository,
     IShoppingCartsService shoppingCartsService,
     IEmailSender emailSender)
 {
     this.ticketsRepository    = ticketsRepository;
     this.usersRepository      = usersRepository;
     this.activitiesRepository = activitiesRepository;
     this.shoppingCartsService = shoppingCartsService;
     this.emailSender          = emailSender;
 }
예제 #26
0
 public ExternalLoginModel(
     SignInManager <PhotoPavilionUser> signInManager,
     UserManager <PhotoPavilionUser> userManager,
     ILogger <ExternalLoginModel> logger,
     IEmailSender emailSender,
     IShoppingCartsService shoppingCartsService)
 {
     this.signInManager        = signInManager;
     this.userManager          = userManager;
     this.logger               = logger;
     this.emailSender          = emailSender;
     this.shoppingCartsService = shoppingCartsService;
 }
예제 #27
0
 public RegisterModel(
     UserManager <PhotoPavilionUser> userManager,
     SignInManager <PhotoPavilionUser> signInManager,
     ILogger <RegisterModel> logger,
     IEmailSender emailSender,
     IShoppingCartsService shoppingCartsService)
 {
     this.userManager          = userManager;
     this.signInManager        = signInManager;
     this.logger               = logger;
     this.emailSender          = emailSender;
     this.shoppingCartsService = shoppingCartsService;
 }
예제 #28
0
 public ExternalLoginModel(
     SignInManager <ApplicationUser> signInManager,
     UserManager <ApplicationUser> userManager,
     ILogger <ExternalLoginModel> logger,
     ApplicationDbContext dbContext,
     IShoppingCartsService shoppingCartsService)
 {
     this.signInManager        = signInManager;
     this.userManager          = userManager;
     this.logger               = logger;
     this.dbContext            = dbContext;
     this.shoppingCartsService = shoppingCartsService;
 }
 public OrdersService(IDeletableEntityRepository <Order> ordersRepository,
                      IDeletableEntityRepository <FamilyKitchenUser> usersRepository,
                      IRepository <ShoppingCartShopProduct> cartProductRepository,
                      IDeletableEntityRepository <ClientCard> clientCardRepository,
                      IShoppingCartsService shoppingCartsService,
                      IMapper mapper
                      )
 {
     this.ordersRepository      = ordersRepository;
     this.usersRepository       = usersRepository;
     this.cartProductRepository = cartProductRepository;
     this.clientCardRepository  = clientCardRepository;
     this.shoppingCartsService  = shoppingCartsService;
     this.mapper = mapper;
 }
예제 #30
0
 public RegisterModel(
     UserManager <XeonUser> userManager,
     SignInManager <XeonUser> signInManager,
     ILogger <RegisterModel> logger,
     IEmailSender emailSender,
     IUsersService userService,
     IShoppingCartsService shoppingCartService)
 {
     _userManager         = userManager;
     _signInManager       = signInManager;
     _logger              = logger;
     _emailSender         = emailSender;
     _userService         = userService;
     _shoppingCartService = shoppingCartService;
 }