private async Task AddProductToDiet(Product product) { if (!await ProductExistInDiet(product, diet)) { product.DietId = diet.DietId; NutrientsManagement.AddNutrients(product, diet); await unitOfWork.SaveChanges(); } }
protected override async Task DeleteData(Product entity) { if (await ProductExistInDiet(entity, diet)) { NutrientsManagement.SubtractNutrients(entity, diet); } await base.DeleteData(entity); }
public void AddNutrients_Success() { //Act NutrientsManagement.AddNutrients(product, diet); //Arrange Assert.Equal(200, diet.TotalCalories); Assert.Equal(200, diet.TotalCarbohydrates); Assert.Equal(200, diet.TotalFats); Assert.Equal(200, diet.TotalProteins); }