public void ObjectProcessor_GoalIsSatisfied() { // Create order processor: OrderProcessor orderProcessor = new OrderProcessor(); // Create a wish list, where 1 nut free meal should be still ordered OrderWishList orderWishList = new OrderWishList(); orderWishList.MealsToOrder = new Dictionary <RestaurantMeal.MealType, int> { { RestaurantMeal.MealType.Vegetarian, 0 }, { RestaurantMeal.MealType.GlutenFree, 0 }, { RestaurantMeal.MealType.NutFree, 1 }, { RestaurantMeal.MealType.FishFree, 0 }, { RestaurantMeal.MealType.Other, 0 }, }; // Add a wish list to order processor orderProcessor.OrderWishList = orderWishList; // Check that order processor detects that something should be still ordered: Assert.IsFalse(orderProcessor.GoalIsSatisfied()); }
public void OrderWishList_Constructor() { // Total number of meals is 15: // vegetarian - 5 // gluten free - 4 // nut free - 3 // fish free - 2 // other = 15 - 5 - 4 - 3 - 2 = 1 OrderWishList orderWishList = new OrderWishList(5, 4, 3, 2, 15); // Expected dictionary of meals to order Dictionary <RestaurantMeal.MealType, int> expectedMealsToOrder = new Dictionary <RestaurantMeal.MealType, int> { { RestaurantMeal.MealType.Vegetarian, 5 }, { RestaurantMeal.MealType.GlutenFree, 4 }, { RestaurantMeal.MealType.NutFree, 3 }, { RestaurantMeal.MealType.FishFree, 2 }, { RestaurantMeal.MealType.Other, 1 } }; // Check to see if expected is the same as actual: Assert.IsTrue(Verifier.DictionariesAreEq(orderWishList.MealsToOrder, expectedMealsToOrder)); }
public void Case_ReversedRestaurants() { //Team needs: total 50 meals including 5 vegetarians and 7 gluten free. // Please note, that restaurant B is created first, restaurant A is created next OrderWishList order = new OrderWishList(5, 7, 0, 0, 50); RestaurantsFactory factory = new RestaurantsFactory(); factory.CreateRestaurant("B", 3, 20, 20, 0, 0, 100); factory.CreateRestaurant("A", 5, 4, 0, 0, 0, 40); OrderProcessor processor = new OrderProcessor(order, factory); List <MealsReadyForDelivery> totalOrders = processor.TotalOrders; // Expected first element at index 0 // Restaurant A has a rating of 5/5 and can serve 4 vegetarians, 36 other. RestaurantSignature expectS0 = new RestaurantSignature("A", 5); Dictionary <RestaurantMeal.MealType, int> expectD0 = new Dictionary <RestaurantMeal.MealType, int> { { RestaurantMeal.MealType.Vegetarian, 4 }, { RestaurantMeal.MealType.Other, 36 }, }; MealsReadyForDelivery readyForDelivery0 = new MealsReadyForDelivery(expectS0, expectD0); // Expected second element at index 1 // Restaurant B has a rating of 3 / 5 and can serve 20 vegetarians, and 20 gluten free, 60 other. RestaurantSignature expectS1 = new RestaurantSignature("B", 3); Dictionary <RestaurantMeal.MealType, int> expectD1 = new Dictionary <RestaurantMeal.MealType, int> { { RestaurantMeal.MealType.Vegetarian, 1 }, { RestaurantMeal.MealType.GlutenFree, 7 }, { RestaurantMeal.MealType.Other, 2 }, }; MealsReadyForDelivery readyForDelivery1 = new MealsReadyForDelivery(expectS1, expectD1); // Check to see that expected meal orders results are the same, as actual Assert.AreEqual(totalOrders.Count, 2); Assert.IsTrue(Verifier.MealsReayForDeliveryAreEq(totalOrders[0], readyForDelivery0)); Assert.IsTrue(Verifier.MealsReayForDeliveryAreEq(totalOrders[1], readyForDelivery1)); }
public void Case_OrderMoreThanAvailable() { //Team needs: total 50 meals including 5 vegetarians and 7 gluten free. OrderWishList order = new OrderWishList(5, 7, 0, 0, 50); // Create Restaurants RestaurantsFactory factory = new RestaurantsFactory(); factory.CreateRestaurant("B", 1, 1, 1, 0, 0, 2); factory.CreateRestaurant("A", 2, 1, 1, 0, 0, 2); OrderProcessor processor = new OrderProcessor(order, factory); List <MealsReadyForDelivery> totalOrders = processor.TotalOrders; // Expected first element at index 0 // Restaurant A has a rating of 2/5 and can serve 1 vegetarian and 1 gluten free, total: 2 RestaurantSignature expectS0 = new RestaurantSignature("A", 2); Dictionary <RestaurantMeal.MealType, int> expectD0 = new Dictionary <RestaurantMeal.MealType, int> { { RestaurantMeal.MealType.Vegetarian, 1 }, { RestaurantMeal.MealType.GlutenFree, 1 }, }; MealsReadyForDelivery readyForDelivery0 = new MealsReadyForDelivery(expectS0, expectD0); // Expected second element at index 1 // Restaurant B has a rating of 1 / 5 and can serve 1 vegetarian and 1 gluten free, total: 2 RestaurantSignature expectS1 = new RestaurantSignature("B", 1); Dictionary <RestaurantMeal.MealType, int> expectD1 = new Dictionary <RestaurantMeal.MealType, int> { { RestaurantMeal.MealType.Vegetarian, 1 }, { RestaurantMeal.MealType.GlutenFree, 1 }, }; MealsReadyForDelivery readyForDelivery1 = new MealsReadyForDelivery(expectS1, expectD1); // Check to see that expected meal orders results are the same, as actual Assert.AreEqual(totalOrders.Count, 2); Assert.IsTrue(Verifier.MealsReayForDeliveryAreEq(totalOrders[0], readyForDelivery0)); Assert.IsTrue(Verifier.MealsReayForDeliveryAreEq(totalOrders[1], readyForDelivery1)); }
public void ObjectProcessor_ProcessOrder() { // Create order processor: OrderProcessor orderProcessor = new OrderProcessor(); // Create a wish list, where 3 nut free meal should be still ordered OrderWishList orderWishList = new OrderWishList(); orderWishList.MealsToOrder = new Dictionary <RestaurantMeal.MealType, int> { { RestaurantMeal.MealType.Vegetarian, 0 }, { RestaurantMeal.MealType.GlutenFree, 0 }, { RestaurantMeal.MealType.NutFree, 3 }, { RestaurantMeal.MealType.FishFree, 0 }, { RestaurantMeal.MealType.Other, 0 }, }; // Add a wish list to order processor orderProcessor.OrderWishList = orderWishList; // Add a restaurant to order processor, which has 4 nut free meals orderProcessor.ListOfRestaurants.Add(new Restaurant("A", 5, 0, 0, 4, 0, 4)); // Process order orderProcessor.ProcessOrder(); // Check that order processor has processed the order properly // It is supposed that 3 nut free meals were ordered from the restaurant A MealsReadyForDelivery mealsReadyForDelivery = orderProcessor.TotalOrders[0]; // Expected: RestaurantSignature expectSignature = new RestaurantSignature("A", 5); Dictionary <RestaurantMeal.MealType, int> expectReadyMeals = new Dictionary <RestaurantMeal.MealType, int> { { RestaurantMeal.MealType.NutFree, 3 } }; // Check that actual is the same as expected: Assert.IsTrue(mealsReadyForDelivery.Signature.Equals(expectSignature)); Assert.IsTrue(Verifier.DictionariesAreEq(mealsReadyForDelivery.ReadyMeals, expectReadyMeals)); }
public void Case_RestaurantsHas0Meals() { //Team needs: total of 100 meals (50 vegetarian + 50 gluten-free) OrderWishList order = new OrderWishList(50, 50, 0, 0, 100); // Create restaurants, which has 0 meals RestaurantsFactory factory = new RestaurantsFactory(); factory.CreateRestaurant("A", 5, 0, 0, 0, 0, 0); factory.CreateRestaurant("B", 3, 0, 0, 0, 0, 0); // Process order OrderProcessor processor = new OrderProcessor(order, factory); List <MealsReadyForDelivery> totalOrders = processor.TotalOrders; // Check to see that nothing was ordered Assert.IsTrue((totalOrders.Count == 0)); }
public void Case_WrongRestaurant() { //Team needs: total 5 meals including 5 vegetarians OrderWishList order = new OrderWishList(5, 0, 0, 0, 5); // Create Restaurants that do not have vegetarian meals RestaurantsFactory factory = new RestaurantsFactory(); factory.CreateRestaurant("B", 1, 0, 0, 0, 0, 50); factory.CreateRestaurant("A", 2, 0, 0, 100, 0, 100); // Process order: OrderProcessor processor = new OrderProcessor(order, factory); List <MealsReadyForDelivery> totalOrders = processor.TotalOrders; // Check to see that total list of meals ordered is empty Assert.AreEqual(totalOrders.Count, 0); }
public void Case_Order0Meals() { //Team needs: total 0 meals OrderWishList order = new OrderWishList(0, 0, 0, 0, 0); // Create restaurants RestaurantsFactory factory = new RestaurantsFactory(); factory.CreateRestaurant("A", 5, 4, 0, 0, 0, 40); factory.CreateRestaurant("B", 3, 20, 20, 0, 0, 100); // Process order OrderProcessor processor = new OrderProcessor(order, factory); List <MealsReadyForDelivery> totalOrders = processor.TotalOrders; // Check to see that nothing was ordered Assert.IsTrue((totalOrders.Count == 0)); }