Пример #1
0
            public void WithFullFridgeIncorrectMealPrepareMeal()
            {
                Fridge currentFridge = new Fridge();

                currentFridge.AddIngredientToFridge("Sausage", 5);
                currentFridge.AddIngredientToFridge("Cream", 7.5);
                currentFridge.AddIngredientToFridge("Tomato puree", 22);

                KitchenService currentKitchen = new KitchenService(currentFridge);

                Recipe newRecipe = new Recipe
                {
                    Name      = "SausageStroganoff",
                    Available = true
                };

                newRecipe.IngredientInfos.Add(new IngredientInfo {
                    Name = "Sausage", Quantity = 1
                });
                newRecipe.IngredientInfos.Add(new IngredientInfo {
                    Name = "Cream", Quantity = 2.5
                });
                newRecipe.IngredientInfos.Add(new IngredientInfo {
                    Name = "Tomato puree", Quantity = 2
                });
                currentKitchen.AddRecipe(newRecipe);

                Assert.AreEqual(false, currentKitchen.PrepareMeal("Squirrel", 1));
            }
Пример #2
0
            public void WithNotEnoughFullFridgeGetPossibleMeals()
            {
                Fridge currentFridge = new Fridge();

                currentFridge.AddIngredientToFridge("VeggieSausage", 5);
                currentFridge.AddIngredientToFridge("Cream", 2);
                currentFridge.AddIngredientToFridge("Tomato puree", 22);

                KitchenService currentKitchen = new KitchenService(currentFridge);

                Recipe newRecipe = new Recipe
                {
                    Name      = "SausageStroganoffVeggie",
                    Available = true
                };

                newRecipe.IngredientInfos.Add(new IngredientInfo {
                    Name = "VeggieSausage", Quantity = 1
                });
                newRecipe.IngredientInfos.Add(new IngredientInfo {
                    Name = "Cream", Quantity = 2.5
                });
                newRecipe.IngredientInfos.Add(new IngredientInfo {
                    Name = "Tomato puree", Quantity = 2
                });
                currentKitchen.AddRecipe(newRecipe);

                List <string> result = currentKitchen.PossibleMeals();

                Assert.AreEqual(true, result != null);
                Assert.AreEqual(0, result.Count);
            }
Пример #3
0
            public void WithFullFridgePrepareTwoMeals()
            {
                Fridge currentFridge = new Fridge();

                currentFridge.AddIngredientToFridge("Sausage", 5);
                currentFridge.AddIngredientToFridge("Cream", 7.5);
                currentFridge.AddIngredientToFridge("Tomato puree", 22);

                KitchenService currentKitchen = new KitchenService(currentFridge);

                Recipe newRecipe = new Recipe
                {
                    Name      = "SausageStroganoff",
                    Available = true
                };

                newRecipe.IngredientInfos.Add(new IngredientInfo {
                    Name = "Sausage", Quantity = 1
                });
                newRecipe.IngredientInfos.Add(new IngredientInfo {
                    Name = "Cream", Quantity = 2.5
                });
                newRecipe.IngredientInfos.Add(new IngredientInfo {
                    Name = "Tomato puree", Quantity = 2
                });
                currentKitchen.AddRecipe(newRecipe);

                Boolean result = currentKitchen.PrepareMeal("SausageStroganoff", 2);

                Assert.AreEqual(true, result);
                Assert.AreEqual(3, currentFridge.GetInventoryItem("Sausage").Quantity);
                Assert.AreEqual(2.5, currentFridge.GetInventoryItem("Cream").Quantity);
                Assert.AreEqual(18, currentFridge.GetInventoryItem("Tomato puree").Quantity);
            }
 public KitchenService SaveAsync(KitchenService cls)
 {
     try
     {
         var headers = Request.Headers?.ToList();
         if (headers == null || headers.Count <= 0)
         {
             return(null);
         }
         var guid = Request.Headers.GetValues("cusGuid").FirstOrDefault();
         if (string.IsNullOrEmpty(guid))
         {
             return(null);
         }
         var cusGuid = Guid.Parse(guid);
         if (!Assistence.CheckCustomer(cusGuid))
         {
             return(null);
         }
         db.KitchenServices.AddOrUpdate(cls);
         db.SaveChanges();
         Assistence.SaveLog(cusGuid, cls.Guid, EnTemp.KitchenService);
         return(cls);
     }
     catch (Exception ex)
     {
         WebErrorLog.ErrorInstence.StartErrorLog(ex);
         return(null);
     }
 }
Пример #5
0
            public void WithoutRecipesGetPossibleMeals()
            {
                KitchenService currentKitchen = new KitchenService();
                List <string>  result         = currentKitchen.PossibleMeals();

                Assert.AreEqual(true, result != null);
                Assert.AreEqual(0, result.Count);
            }
Пример #6
0
            public void AddRecipeWithoutIngredientInfos()
            {
                KitchenService currentKitchen = new KitchenService();
                Recipe         newRecipe      = new Recipe {
                    Name = "PyttIPanna"
                };

                Assert.AreEqual(false, currentKitchen.AddRecipe(newRecipe));
            }
Пример #7
0
            public void AddRecipeWithoutName()
            {
                KitchenService currentKitchen = new KitchenService();
                Recipe         newRecipe      = new Recipe();

                newRecipe.IngredientInfos.Add(new IngredientInfo {
                    Name = "Sausage", Quantity = 1
                });
                Assert.AreEqual(false, currentKitchen.AddRecipe(newRecipe));
            }
 public KitchenServiceUnitTest()
 {
     _testUser = new PantryPlannerUser()
     {
         Id       = "Constructor123",
         UserName = "******",
         Email    = "*****@*****.**"
     };
     _context        = InMemoryDataGenerator.CreateAndInitializeInMemoryDatabaseContext(Guid.NewGuid().ToString(), _testUser, insertIngredientData: false);
     _kitchenService = new KitchenService(_context);
 }
Пример #9
0
        DeliveryService(EventLog eventLog, DeliveryOrderRepository deliveryOrderRepository, OrderingService orderingService, KitchenService kitchenService)
        {
            this.eventLog = eventLog;
            this.deliveryOrderRepository = deliveryOrderRepository;
            this.orderingService         = orderingService;
            this.kitchenService          = kitchenService;

            this.eventLog.subscribe(new Topic("kitchen_orders"), e->{
                KitchenOrderAssemblyFinishedEvent kitchenOrderAssemblyFinishedEvent = (KitchenOrderAssemblyFinishedEvent)e;
                addDeliveryOrderToRepository(kitchenOrderAssemblyFinishedEvent);
            });
Пример #10
0
        private KitchenViewModel CreateKitchen()
        {
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddDbContext <KitchenKanbanDB>(options => options.UseInMemoryDatabase("KitchenKanbanDB"), ServiceLifetime.Transient);
            ServiceProvider serviceProvider = serviceCollection.BuildServiceProvider();
            IUserInfo       userInfo        = new UserInfo()
            {
                UserId   = "95632324-a9f8-44ba-9b3d-4c90dd5d9650",
                UserType = Models.Enums.UserEnum.UserType.Administrator
            };
            IKitchenService kitchenService = new KitchenService(serviceProvider, userInfo);
            var             input          = new KitchenViewModel()
            {
                CounterNumber = "My Counter 1"
            };
            var kitchen = kitchenService.Create(input);

            return(kitchen);
        }
Пример #11
0
            public void PrepareMeal()
            {
                KitchenService currentKitchen = new KitchenService();

                Recipe newRecipe = new Recipe
                {
                    Name      = "SausageStroganoff",
                    Available = false
                };

                newRecipe.IngredientInfos.Add(new IngredientInfo {
                    Name = "Sausage", Quantity = 1
                });
                newRecipe.IngredientInfos.Add(new IngredientInfo {
                    Name = "Cream", Quantity = 2.5
                });
                newRecipe.IngredientInfos.Add(new IngredientInfo {
                    Name = "Tomato puree", Quantity = 2
                });
                currentKitchen.AddRecipe(newRecipe);

                Assert.AreEqual(false, currentKitchen.PrepareMeal("SausageStroganoff", 1));
            }
Пример #12
0
            public void GetRecipeSimilarName()
            {
                KitchenService currentKitchen = new KitchenService();

                Recipe newRecipe = new Recipe {
                    Name = "SausageStroganoffVeggie"
                };

                newRecipe.IngredientInfos.Add(new IngredientInfo {
                    Name = "VeggieSausage", Quantity = 1
                });
                newRecipe.IngredientInfos.Add(new IngredientInfo {
                    Name = "Cream", Quantity = 2.5
                });
                newRecipe.IngredientInfos.Add(new IngredientInfo {
                    Name = "Tomato puree", Quantity = 2
                });
                currentKitchen.AddRecipe(newRecipe);

                newRecipe = new Recipe {
                    Name = "SausageStroganoff"
                };
                newRecipe.IngredientInfos.Add(new IngredientInfo {
                    Name = "Sausage", Quantity = 1
                });
                newRecipe.IngredientInfos.Add(new IngredientInfo {
                    Name = "Cream", Quantity = 2.5
                });
                newRecipe.IngredientInfos.Add(new IngredientInfo {
                    Name = "Tomato puree", Quantity = 2
                });
                currentKitchen.AddRecipe(newRecipe);

                Recipe result = currentKitchen.GetRecipe("SausageStroganoff");

                Assert.AreEqual(newRecipe.Name, result.Name);
            }
Пример #13
0
            public void WithRecipeGetPossibleMeals()
            {
                KitchenService currentKitchen = new KitchenService();

                Recipe newRecipe = new Recipe {
                    Name = "SausageStroganoffVeggie"
                };

                newRecipe.IngredientInfos.Add(new IngredientInfo {
                    Name = "VeggieSausage", Quantity = 1
                });
                newRecipe.IngredientInfos.Add(new IngredientInfo {
                    Name = "Cream", Quantity = 2.5
                });
                newRecipe.IngredientInfos.Add(new IngredientInfo {
                    Name = "Tomato puree", Quantity = 2
                });
                currentKitchen.AddRecipe(newRecipe);

                List <string> result = currentKitchen.PossibleMeals();

                Assert.AreEqual(true, result != null);
                Assert.AreEqual(0, result.Count);
            }
Пример #14
0
 public KitchenController(PantryPlannerContext context, UserManager <PantryPlannerUser> userManager)
 {
     _service     = new KitchenService(context);
     _userManager = userManager;
 }