コード例 #1
0
 public PurchaseController(IngredientProcessor ingredientProcessor, RecipeProcessor recipeProcessor,
                           SessionManager <Purchase> sessionManager)
 {
     this.recipeProcessor     = recipeProcessor;
     this.sessionManager      = sessionManager;
     this.ingredientProcessor = ingredientProcessor;
 }
コード例 #2
0
 public CompoundModelBuilder(RecipeProcessor recipeProcessor, IngredientProcessor ingredientProcessor,
                             CuisineProcessor cuisineProcessor, CategoryProcessor categoryProcessor)
 {
     this.cuisineProcessor    = cuisineProcessor;
     this.recipeProcessor     = recipeProcessor;
     this.ingredientProcessor = ingredientProcessor;
     this.categoryProcessor   = categoryProcessor;
 }
コード例 #3
0
 public RecipeController(RecipeProcessor recipeProcessor, IMapper mapper,
                         SessionManager <ItemInfo> sessionManager, CompoundModelBuilder compoundModelBuilder)
 {
     this.compoundModelBuilder = compoundModelBuilder;
     this.mapper          = mapper;
     this.recipeProcessor = recipeProcessor;
     this.sessionManager  = sessionManager;
 }
コード例 #4
0
ファイル: Merge.cs プロジェクト: Preta-Crowz/TerraTweaker
        public static IVariable Process(string name, MLArray args)
        {
            switch (name)
            {
            case "recipe": return(RecipeProcessor.Work(args));

            case "remove": return(RemoveProcessor.Work(args));
            }
            return(new MLRaw("dummy"));
        }
コード例 #5
0
        public async void ShouldReturnSteps()
        {
            var handlerMock = new Mock <HttpMessageHandler>();
            var response    = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent("[ { \"name\": \"\", \"steps\": [ { \"equipment\": [ { \"id\": 404784, \"image\": \"oven.jpg\", \"name\": \"oven\", \"temperature\": { \"number\": 200.0, \"unit\": \"Fahrenheit\" } } ], \"ingredients\": [], \"number\": 1,  \"step\": \"Preheat the oven to 200 degrees F.\" }, { \"equipment\": [ { \"id\": 404661, \"image\": \"whisk.png\", \"name\": \"whisk\" }, { \"id\": 404783, \"image\": \"bowl.jpg\",\"name\": \"bowl\" } ], \"ingredients\": [ { \"id\": 19334, \"image\": \"light-brown-sugar.jpg\", \"name\": \"light brown sugar\" }, { \"id\": 19335, \"image\": \"sugar-in-bowl.png\", \"name\": \"granulated sugar\" }, { \"id\": 18371, \"image\": \"white-powder.jpg\", \"name\": \"baking powder\" }, { \"id\": 18372, \"image\": \"white-powder.jpg\", \"name\": \"baking soda\" }, { \"id\": 12142, \"image\": \"pecans.jpg\", \"name\": \"pecans\" }, { \"id\": 20081, \"image\": \"flour.png\", \"name\": \"all purpose flour\"  }, { \"id\": 2047, \"image\": \"salt.jpg\", \"name\": \"salt\" } ], \"number\": 2, \"step\": \"Whisk together the flour, pecans, granulated sugar, light brown sugar, baking powder, baking soda, and salt in a medium bowl.\" } ] }]"),
            };

            handlerMock
            .Protected()
            .Setup <Task <HttpResponseMessage> >(
                "SendAsync",
                ItExpr.IsAny <HttpRequestMessage>(),
                ItExpr.IsAny <CancellationToken>())
            .ReturnsAsync(response);
            var httpClient = new HttpClient(handlerMock.Object);

            RecipeProcessor processor = new RecipeProcessor(httpClient);
            var             results   = await processor.LoadSteps(324694);

            Steps       testSteps     = new Steps();
            List <Step> testStepsList = new List <Step>();
            Step        testFirstStep = new Step();

            testFirstStep.number = 1;
            testFirstStep.step   = "Preheat the oven to 200 degrees F.";
            Step testSecodStep = new Step();

            testSecodStep.number = 2;
            testSecodStep.step   = "Whisk together the flour, pecans, granulated sugar, light brown sugar, baking powder, baking soda, and salt in a medium bowl.";
            testStepsList.Add(testFirstStep);
            testStepsList.Add(testSecodStep);
            testSteps.steps = testStepsList;



            var testStepsResults = JsonConvert.SerializeObject(testSteps);
            var retrievedResults = JsonConvert.SerializeObject(results);

            Assert.Equal(testStepsResults, retrievedResults);
            handlerMock.Protected().Verify(
                "SendAsync",
                Times.Exactly(1),
                ItExpr.Is <HttpRequestMessage>(req => req.Method == HttpMethod.Get),
                ItExpr.IsAny <CancellationToken>());
        }
コード例 #6
0
        public async void ShouldReturnRecipes()
        {
            var handlerMock = new Mock <HttpMessageHandler>();
            var response    = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent("{ \"offset\": 0, \"number\": 2, \"results\": [{\"id\": 716429, \"calories\": 584, \"carbs\": \"84g\", \"fat\": \"20g\", \"image\": \"https://spoonacular.com/recipeImages/716429-312x231.jpg\", \"imageType\": \"jpg\", \"protein\": \"19g\", \"title\": \"Pasta with Garlic, Scallions, Cauliflower & Breadcrumbs\" }, { \"id\": 715538, \"calories\": 521, \"carbs\": \"69g\", \"fat\": \"10g\", \"image\": \"https://spoonacular.com/recipeImages/715538-312x231.jpg\", \"imageType\": \"jpg\", \"protein\": \"35g\", \"title\": \"What to make for dinner tonight?? Bruschetta Style Pork & Pasta\" }], \"totalResults\": 86}"),
            };

            handlerMock
            .Protected()
            .Setup <Task <HttpResponseMessage> >(
                "SendAsync",
                ItExpr.IsAny <HttpRequestMessage>(),
                ItExpr.IsAny <CancellationToken>())
            .ReturnsAsync(response);
            var httpClient = new HttpClient(handlerMock.Object);

            RecipeProcessor processor = new RecipeProcessor(httpClient);
            var             results   = await processor.LoadRecipes("tomato,cheese", "keto");


            Recipe        pastaRecipe = new Recipe(716429, "Pasta with Garlic, Scallions, Cauliflower & Breadcrumbs", 584, "https://spoonacular.com/recipeImages/716429-312x231.jpg");
            Recipe        porkRecipe  = new Recipe(715538, "What to make for dinner tonight?? Bruschetta Style Pork & Pasta", 521, "https://spoonacular.com/recipeImages/715538-312x231.jpg");
            Recipes       recipes     = new Recipes();
            List <Recipe> testRecipes = new List <Recipe>();

            testRecipes.Add(pastaRecipe);
            testRecipes.Add(porkRecipe);
            recipes.results = testRecipes;

            var testResults      = JsonConvert.SerializeObject(recipes);
            var retrievedRecipes = JsonConvert.SerializeObject(results);

            Assert.Equal(testResults, retrievedRecipes);
            handlerMock.Protected().Verify(
                "SendAsync",
                Times.Exactly(1),
                ItExpr.Is <HttpRequestMessage>(req => req.Method == HttpMethod.Get),
                ItExpr.IsAny <CancellationToken>());
        }
コード例 #7
0
        public async void ShouldReturnSummary()
        {
            var handlerMock = new Mock <HttpMessageHandler>();
            var response    = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent("{    \"id\": 4632,    \"summary\": \"The recipe Soy-and-Ginger-Glazed Salmon with Udon Noodles can be made  <b>in approximately 1 hour and 35 minutes </b>. One portion of this dish contains about  <b>48g of protein </b>,  <b>17g of fat </b>, and a total of  <b>552 calories </b>. This recipe serves 4. For  <b>$5.91 per serving </b>, this recipe  <b>covers 47% </b> of your daily requirements of vitamins and minerals. It works well as a main course. 1 person has tried and liked this recipe. It is brought to you by Food and Wine. If you have fresh ginger, udon noodles, salmon fillets, and a few other ingredients on hand, you can make it. It is a good option if you're following a  <b>dairy free and pescatarian </b> diet. All things considered, we decided this recipe  <b>deserves a spoonacular score of 92% </b>. This score is great. If you like this recipe, take a look at these similar recipes: Salmon With Soy-ginger Noodles, Ginger-Soy Salmon With Soba Noodles, and Soy & ginger salmon with soba noodles.\",    \"title\": \"Soy-and-Ginger-Glazed Salmon with Udon Noodles\"}"),
            };

            handlerMock
            .Protected()
            .Setup <Task <HttpResponseMessage> >(
                "SendAsync",
                ItExpr.IsAny <HttpRequestMessage>(),
                ItExpr.IsAny <CancellationToken>())
            .ReturnsAsync(response);
            var httpClient = new HttpClient(handlerMock.Object);

            RecipeProcessor processor = new RecipeProcessor(httpClient);
            var             results   = await processor.LoadSummary(4632);

            Summary testSummary = new Summary();

            testSummary.id      = 4632;
            testSummary.title   = "Soy-and-Ginger-Glazed Salmon with Udon Noodles";
            testSummary.summary = "The recipe Soy-and-Ginger-Glazed Salmon with Udon Noodles can be made  <b>in approximately 1 hour and 35 minutes </b>. One portion of this dish contains about  <b>48g of protein </b>,  <b>17g of fat </b>, and a total of  <b>552 calories </b>. This recipe serves 4. For  <b>$5.91 per serving </b>, this recipe  <b>covers 47% </b> of your daily requirements of vitamins and minerals. It works well as a main course. 1 person has tried and liked this recipe. It is brought to you by Food and Wine. If you have fresh ginger, udon noodles, salmon fillets, and a few other ingredients on hand, you can make it. It is a good option if you're following a  <b>dairy free and pescatarian </b> diet. All things considered, we decided this recipe  <b>deserves a spoonacular score of 92% </b>. This score is great. If you like this recipe, take a look at these similar recipes: Salmon With Soy-ginger Noodles, Ginger-Soy Salmon With Soba Noodles, and Soy & ginger salmon with soba noodles.";

            var testSummaryResults = JsonConvert.SerializeObject(testSummary);
            var retrievedResults   = JsonConvert.SerializeObject(results);

            Assert.Equal(testSummaryResults, retrievedResults);
            handlerMock.Protected().Verify(
                "SendAsync",
                Times.Exactly(1),
                ItExpr.Is <HttpRequestMessage>(req => req.Method == HttpMethod.Get),
                ItExpr.IsAny <CancellationToken>());
        }
コード例 #8
0
 public async Task <RecipeModel> getInfo(string search)
 {
     return(await RecipeProcessor.LoadRecipe(search));
 }
コード例 #9
0
 public CuisineSelectionViewComponent(RecipeProcessor recipeProcessor)
 {
     this.recipeProcessor = recipeProcessor;
 }
コード例 #10
0
        public FoodData()
        {
            HttpClient httpClient = RecipeProcessor.InitializeClient();

            processor = new RecipeProcessor(httpClient);
        }