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

            Assert.AreEqual(categoryId, MockCategoryId);
        }
Beispiel #2
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);
        }
        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 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);
        }