public async Task CreateNewProductTest() { ProductDTO productDTO = _mapper.Map <ProductDTO>(MockModels.MockProductModel()); int productId = await product.CreateProductAsync(productDTO); Assert.AreEqual(productId, MockProductId); }
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() { 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(); 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); }