Ejemplo n.º 1
0
        public void Should_Create_Your_Composition_With_The_Abstraction_For_The_MealEstimated()
        {
            var element = NSubstitute.Substitute.For <ITables>();

            var mealAllowed = NSubstitute.Substitute.For <IMealAllowed>();

            mealAllowed.ObtainTheMealAllowed().Returns(new MealAllowed(mealAllowedContent));

            var listReturned = new List <Table>();

            var mealAllowedRepository = new MealAllowedRepository(mealAllowed);

            listReturned.Add(Table.Of("Table-1", "Durant", "Damien", "Meat", mealAllowedRepository.ObtainMealAllowed()));
            listReturned.Add(Table.Of("Table-2", "Lamier", "Lola", "Meat", mealAllowedRepository.ObtainMealAllowed()));
            listReturned.Add(Table.Of("Table-1", "Durant", "Laurent", "Fish", mealAllowedRepository.ObtainMealAllowed()));

            var tableNumberFoodEstimated   = new List <TableMealsNumbers>();
            var mealDicoEstimatedForTable1 = new Dictionary <string, int>();

            mealDicoEstimatedForTable1.Add("Meat", 1);
            mealDicoEstimatedForTable1.Add("Fish", 1);
            tableNumberFoodEstimated.Add(new TableMealsNumbers("Table-1", mealDicoEstimatedForTable1));

            var mealDicoEstimatedForTable2 = new Dictionary <string, int>();

            mealDicoEstimatedForTable2.Add("Meat", 1);
            mealDicoEstimatedForTable2.Add("Fish", 0);
            tableNumberFoodEstimated.Add(new TableMealsNumbers("Table-2", mealDicoEstimatedForTable2));


            element.ObtainsTheTables().Returns(listReturned);
            var                      tableRepository   = new TableRepository(element);
            List <Table>             tableInformations = tableRepository.ObtainTableList();
            var                      tableInformation  = new TableInformation(tableInformations);
            List <TableMealsNumbers> tableNumberFood   = tableInformation.ObtainMealNumberForAllTheTables(dictionaryMealAllowed);

            Check.That(tableNumberFood.SequenceEqual(tableNumberFoodEstimated) && tableNumberFoodEstimated.SequenceEqual(tableNumberFood)).IsTrue();
        }