Пример #1
0
        public CartManagerTest()
        {
            request           = new CartRequest();
            request.UserId    = USER_ID;
            request.ProductId = PRODUCT_ID;
            userRepository    = new StubUserRepository();
            productRepository = new StubProductRepository();
            string PRODUCT_DESC    = "IPad";
            double PRODUCT_PRICE   = 230.50;
            string PRODUCT_FACTORY = "Apple";
            string PRODUCT_NAME    = "Tablet";

            product = new Product(PRODUCT_ID, PRODUCT_NAME, PRODUCT_DESC, PRODUCT_PRICE, PRODUCT_FACTORY);
            product.AvailableStock = 100;
            string USER_NAME      = "Cliente";
            string USER_LAST_NAME = "Compra";
            string USER_PASSWORD  = "******";

            string USER_MAIL = "*****@*****.**";

            user = new User(USER_ID, USER_NAME, USER_LAST_NAME, USER_PASSWORD, USER_ADDRESS, USER_MAIL, USER_PHONE);
            userRepository.AddEntity(user);
            productRepository.AddEntity(product);
            cartRepository     = new StubCartRepository();
            cartItemRepository = new StubCartItemRepository();
            IPointSystemConfigurationRepository configurationRepository = new StubPointSystemConfigurationRepository();

            configurationRepository.AddEntity(new PointSystemConfiguration()
            {
                PropertyName = ESportUtils.LOYALTY_PROPERTY_NAME, PropertyValue = 100
            });
            cartManager = new CartManager(cartRepository, cartItemRepository, productRepository, userRepository, configurationRepository);
        }
        private ICartManager GetCartManager(IProductRepository productRepository, IUserRepository userRepository)
        {
            ICartRepository     cartRepository     = new StubCartRepository();
            ICartItemRepository cartItemRepository = new StubCartItemRepository();
            IPointSystemConfigurationRepository configurationRepository = new StubPointSystemConfigurationRepository();

            configurationRepository.AddEntity(new PointSystemConfiguration()
            {
                PropertyName = ESportUtils.LOYALTY_PROPERTY_NAME, PropertyValue = 100
            });
            ICartManager cartManager = new CartManager(cartRepository, cartItemRepository, productRepository, userRepository, configurationRepository);
            CartRequest  cartRequest = GetCartRequest();
            Cart         currentCart = cartManager.AddProduct(cartRequest);

            itemTest = currentCart.Items.Where(item => item.Product.ProductId.Equals(cartRequest.ProductId)).First();
            cartManager.ConfirmCart(cartRequest);
            return(cartManager);
        }
Пример #3
0
        public LoginServiceTest()
        {
            IUserRepository userRepository = new StubUserRepository();
            IRoleRepository roleRepository = GetRoleRepository();
            UserRequest     request        = GetUserRequest();
            IUserManager    userManager    = new UserManager(userRepository, roleRepository);

            userManager.AddUser(request);
            ICartRepository cartRepository = new StubCartRepository();
            IPointSystemConfigurationRepository configurationRepository = new StubPointSystemConfigurationRepository();
            ILoggerManager loggerManager = new LoggerManager(new StubLoggerRepository());

            configurationRepository.AddEntity(new PointSystemConfiguration()
            {
                PropertyName = ESportUtils.LOYALTY_PROPERTY_NAME, PropertyValue = 100
            });
            cartManager  = new CartManager(cartRepository, new StubCartItemRepository(), GetProductRepository(), userRepository, configurationRepository);
            loginService = new LoginService(userManager, cartManager, new PendingReviewDTOBuilder(), new SimpleCartDTOBuilder(new SimpleCartItemDTOBuilder()), new UserDTOBuilder(), loggerManager);
        }
Пример #4
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());
        }