示例#1
0
        public void CallFoodCategoriesServiceMethod_AddIngredientQuantityToFoodCategory()
        {
            //Arrange
            var dataMock = new Mock <IHomeMadeFoodData>();
            var foodCategoriesServiceMock            = new Mock <IFoodCategoriesService>();
            IngredientsService ingredientsService    = new IngredientsService(dataMock.Object, foodCategoriesServiceMock.Object);
            string             ingredientName        = "Name of the ingredient";
            decimal            pricePerMeasuringUnit = 1.19m;
            Guid   foodCategoryId           = Guid.NewGuid();
            Guid   recipeId                 = Guid.NewGuid();
            double quantityPerMeasuringUnit = 0.250;

            //Act
            var ingredient = ingredientsService.CreateIngredient(ingredientName, foodCategoryId, pricePerMeasuringUnit, quantityPerMeasuringUnit);

            //Assert
            foodCategoriesServiceMock.Verify(x => x.AddIngredientQuantityToFoodCategory(ingredient), Times.Once);
        }
示例#2
0
        public void ReturnIngredient()
        {
            //Arrange
            var dataMock = new Mock <IHomeMadeFoodData>();
            var foodCategoriesServiceMock            = new Mock <IFoodCategoriesService>();
            IngredientsService ingredientsService    = new IngredientsService(dataMock.Object, foodCategoriesServiceMock.Object);
            string             ingredientName        = "Name of the ingredient";
            decimal            pricePerMeasuringUnit = 1.19m;
            Guid   foodCategoryId           = Guid.NewGuid();
            Guid   recipeId                 = Guid.NewGuid();
            double quantityPerMeasuringUnit = 0.250;

            //Act
            var ingredient = ingredientsService.CreateIngredient(ingredientName, foodCategoryId, pricePerMeasuringUnit, quantityPerMeasuringUnit);

            //Assert
            Assert.IsInstanceOf <Ingredient>(ingredient);
        }