Пример #1
0
        public void TestFindRecipe(TestFindRecipeTestCase testCase)
        {
            var service = new WebSeekerService(_logger);
            var results = service.FindRecipes(new Uri(testCase.Url));

            Assert.That(results, Has.Count.EqualTo(testCase.Expected.Recipes.Count));
            for (var i = 0; i < testCase.Expected.Recipes.Count; i++)
            {
                var expectedRecipe = testCase.Expected.Recipes[i];
                var actualRecipe   = results[i];

                Assert.That(actualRecipe.Servings, Is.EqualTo(expectedRecipe.Servings));

                Assert.That(actualRecipe.Dish, Is.Not.Null);
                Assert.That(actualRecipe.Dish.Candidates, Has.Count.EqualTo(expectedRecipe.Dish.Candidates.Count()));
                for (var j = 0; j < expectedRecipe.Dish.Candidates.Count(); j++)
                {
                    var expectedDishCandidate = expectedRecipe.Dish.Candidates.ElementAt(j);
                    var actualDishCandidate   = actualRecipe.Dish.Candidates.ElementAt(j);

                    Assert.That(actualDishCandidate.Name, Is.EqualTo(expectedDishCandidate.Name));
                }

                Assert.That(actualRecipe.Ingredients, Has.Count.EqualTo(expectedRecipe.Ingredients.Count()));
                for (var j = 0; j < expectedRecipe.Ingredients.Count(); j++)
                {
                    var expectedIngredient_ = expectedRecipe.Ingredients.ElementAt(i);
                    var actualIngredient_   = actualRecipe.Ingredients.ElementAt(i);

                    Assert.That(actualIngredient_.Candidates, Has.Count.EqualTo(expectedIngredient_.Candidates.Count()));
                    for (var k = 0; k < expectedIngredient_.Candidates.Count(); k++)
                    {
                        var expectedIngredientCandidate = expectedIngredient_.Candidates.ElementAt(k);
                        var actualIngredientCandidate   = actualIngredient_.Candidates.ElementAt(k);
                        Assert.That(actualIngredientCandidate.Name, Is.EqualTo(expectedIngredientCandidate.Name));
                        Assert.That(actualIngredientCandidate.Amount, Is.EqualTo(expectedIngredientCandidate.Amount));
                        Assert.That(actualIngredientCandidate.Unit, Is.EqualTo(expectedIngredientCandidate.Unit));
                        Assert.That(actualIngredientCandidate.Note, Is.EqualTo(expectedIngredientCandidate.Note));
                    }

                    var expectedSection = expectedIngredient_.Section;
                    var actualSection   = actualIngredient_.Section;

                    Assert.That(actualSection.Id, Is.EqualTo(expectedSection.Id));
                    Assert.That(actualSection.Candidates?.Count(), Is.EqualTo(expectedSection.Candidates.Count()));
                }
            }
        }
 public void RegenerateTestCaseCode(TestFindRecipeTestCase testCase)
 {
     GenerateTestCaseCodeOfTestFindRecipe(testCase.Url);
 }