public async Task CreateNewProductTest()
        {
            ProductDTO productDTO = _mapper.Map <ProductDTO>(MockModels.MockProductModel());
            int        productId  = await product.CreateProductAsync(productDTO);

            Assert.AreEqual(productId, MockProductId);
        }
        public async Task ApplyCouponDiscountTest()
        {
            CouponDTO couponDTO      = _mapper.Map <CouponDTO>(MockModels.MockCouponModel());
            double    discountAmount = await cart.ApplyCouponDiscountAsync(_cartDTO, couponDTO);

            Assert.Positive(discountAmount);
        }
        public async Task CreateNewCategoryTest()
        {
            CategoryDTO categoryDTO = _mapper.Map <CategoryDTO>(MockModels.MockCategoryModel());
            int         categoryId  = await category.CreateNewCategoryAsync(categoryDTO);

            Assert.AreEqual(categoryId, MockCategoryId);
        }
        public async Task AddItemTest()
        {
            ProductDTO productDTO = _mapper.Map <ProductDTO>(MockModels.MockProductModel());
            int        cartItemId = await cart.AddItemAsync(_cartDTO.CartId, productDTO, 4);

            Assert.IsTrue(cartItemId > 0);
        }
        public void Setup()
        {
            var mapperConfig = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new MapperProfile());
            });

            _mapper = mapperConfig.CreateMapper();

            cartEFServiceMock     = new Mock <ICartEFService>();
            productEFServiceMock  = new Mock <IProductEFService>();
            categoryEFServiceMock = new Mock <ICategoryEFService>();

            //Mock Setups
            cartEFServiceMock.Setup(c => c.GetCartAsync(It.IsAny <int>())).Returns(Task.FromResult(MockModels.MockCartModel()));
            cartEFServiceMock.Setup(c => c.AddCartAsync(It.IsAny <CartModel>())).Returns(Task.FromResult(CartId));
            cartEFServiceMock.Setup(c => c.AddCartDetailAsync(It.IsAny <CartDetailModel>())).Returns(Task.FromResult(CartDetailId));
            cartEFServiceMock.Setup(c => c.SaveCartCampaignAsync(It.IsAny <CartCampaignModel>(), It.IsAny <int>()));
            cartEFServiceMock.Setup(c => c.SaveCartCouponAsync(It.IsAny <CartCouponModel>(), It.IsAny <int>()));
            cartEFServiceMock.Setup(c => c.GetCartCampaignAsync(It.IsAny <int>())).Returns(Task.FromResult(MockModels.MockListCartCampaignModel()));
            cartEFServiceMock.Setup(c => c.GetCartCouponAsync(It.IsAny <int>())).Returns(Task.FromResult(MockModels.MockCartCouponModel()));
            cartEFServiceMock.Setup(c => c.GetCartDeliveriesAsync(It.IsAny <int>())).Returns(Task.FromResult(MockModels.MockCartDeliveries()));
            cartEFServiceMock.Setup(c => c.GetCartDetailsAsync(It.IsAny <int>())).Returns(Task.FromResult(MockModels.MockListCartDetailModel()));

            productEFServiceMock.Setup(p => p.GetProductAsync(It.IsAny <int>())).Returns(Task.FromResult(MockModels.MockProductModel()));

            categoryEFServiceMock.Setup(c => c.GetCategoryAsync(It.IsAny <int>())).Returns(Task.FromResult(MockModels.MockCategoryModel()));

            _cartDTO = _mapper.Map <CartDTO>(MockModels.MockCartModel());

            cart = new Cart(cartEFServiceMock.Object, _mapper, productEFServiceMock.Object, categoryEFServiceMock.Object);
        }
        public async Task ApplyCampaignDiscountTest()
        {
            List <CampaignDTO> campaignList = new List <CampaignDTO>()
            {
                _mapper.Map <CampaignDTO>(MockModels.MockCampaignModel()), _mapper.Map <CampaignDTO>(MockModels.MockCampaignModel())
            };
            double discountAmount = await cart.ApplyCampaignDiscountAsync(_cartDTO, campaignList);

            Assert.Positive(discountAmount);
        }
Beispiel #7
0
        public async Task CalculateForTest()
        {
            double deliveryCost = await delivery.GetDeliveryCostAsync(_mapper.Map <CartDTO>(MockModels.MockCartModel()));

            Assert.IsTrue(deliveryCost > 0);
        }
Beispiel #8
0
        public void Setup()
        {
            deliveryEFServiceMock = new Mock <IDeliveryEFService>();
            deliveryEFServiceMock.Setup(d => d.AddDeliveryAsync(It.IsAny <DeliveryModel>())).Returns(Task.FromResult(DeliveryModelId));
            deliveryEFServiceMock.Setup(d => d.GetDeliveriesAsync(It.IsAny <int>())).Returns(Task.FromResult(MockModels.MockCartDeliveries()));

            cartEFServiceMock = new Mock <ICartEFService>();
            cartEFServiceMock.Setup(cef => cef.GetCartAsync(It.IsAny <int>())).Returns(Task.FromResult(MockModels.MockCartModel()));

            productEFServiceMock = new Mock <IProductEFService>();
            productEFServiceMock.Setup(p => p.GetProductAsync(It.IsAny <int>())).Returns(Task.FromResult(MockModels.MockProductModel()));

            categoryEFServiceMock = new Mock <ICategoryEFService>();
            categoryEFServiceMock.Setup(c => c.GetCategoryAsync(It.IsAny <int>())).Returns(Task.FromResult(MockModels.MockCategoryModel()));

            var mapperConfig = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new MapperProfile());
            });

            _mapper = mapperConfig.CreateMapper();

            delivery = new Delivery(deliveryEFServiceMock.Object, cartEFServiceMock.Object, productEFServiceMock.Object, categoryEFServiceMock.Object, _mapper);
        }
Beispiel #9
0
        public async Task CreateCampaignTest()
        {
            int campaignID = await campaign.CreateCampaignAsync(_mapper.Map <CampaignDTO>(MockModels.MockCampaignModel()));

            Assert.AreEqual(campaignID, MockModels.MockCampaignModel().CampaignId);
        }
Beispiel #10
0
        public void Setup()
        {
            campaignEFServiceMock = new Mock <ICampaignEFService>();
            campaignEFServiceMock.Setup(c => c.AddCampaignAsync(It.IsAny <CampaignModel>())).Returns(Task.FromResult(MockModels.MockCampaignModel().CampaignId));

            var mapperConfig = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new MapperProfile());
            });

            _mapper = mapperConfig.CreateMapper();

            campaign = new Campaign(_mapper, campaignEFServiceMock.Object);
        }
        public void Setup()
        {
            var mapperConfig = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new MapperProfile());
            });

            _mapper = mapperConfig.CreateMapper();

            categoryEFServiceMock = new Mock <ICategoryEFService>();
            categoryEFServiceMock.Setup(cef => cef.AddCategoryAsync(It.IsAny <CategoryModel>())).Returns(Task.FromResult(MockCategoryId));
            categoryEFServiceMock.Setup(cef => cef.GetCategoryAsync(It.IsAny <int>())).Returns(Task.FromResult(MockModels.MockCategoryModel()));

            category = new Category(_mapper, categoryEFServiceMock.Object);
        }
        public async Task CreateCartTest()
        {
            int cartId = await cart.CreateCartAsync(_mapper.Map <CartDTO>(MockModels.MockCartModel()));

            Assert.AreEqual(cartId, CartId);
        }