public async Task AddProductToUserCartTests() { //Arrange var mapperConfig = new MapperConfiguration(x => x.AddProfile(new MappingProfile())); var mapper = mapperConfig.CreateMapper(); var cartService = new CartService(this.context, mapper); var product = new Mock <Product>().Object; product.Id = "Test-id"; var productBindingModel = new BuyProductBindingModel { Id = product.Id, Quant = 3, }; var user = new Mock <User>().Object; //Act Assert.Equal(0, context.CartProducts.Count()); await cartService.AddProductToUserCart(productBindingModel, user); //Assert Assert.Equal(1, context.CartProducts.Count()); }