Пример #1
0
        public void ShowRecipeCommand_UserClickCancel_ItemCollectorAddNotCalled()
        {
            //Setup
            ISubWindowFactory fac = Substitute.For <ISubWindowFactory>();

            _sut.SetWindowFactory(fac);
            IRecipeInformationWindowDialog dia = Substitute.For <IRecipeInformationWindowDialog>();

            fac.GetRecipeInformationWindow(Arg.Any <Recipe>(), Arg.Any <Window>(), Arg.Any <string>()).Returns(dia);
            dia.ShowDialog().Returns(false);

            Recipe r = new Recipe();

            _sut.ShowRecipeCommand.Execute(r);
            _itemCollector.DidNotReceiveWithAnyArgs().Add(null, 0);
        }
Пример #2
0
        public void ShowRecipeCommand_IngredientsIsNull_ItemCollectorIsNotCalled()
        {
            //Setup
            ISubWindowFactory fac = Substitute.For <ISubWindowFactory>();

            _sut.SetWindowFactory(fac);
            IRecipeInformationWindowDialog dia = Substitute.For <IRecipeInformationWindowDialog>();

            fac.GetRecipeInformationWindow(Arg.Any <Recipe>(), Arg.Any <Window>(), Arg.Any <string>()).Returns(dia);
            dia.ShowDialog().Returns(true);

            Recipe r = new Recipe();

            _sut.ShowRecipeCommand.Execute(r);
            _itemCollector.DidNotReceive().Add(Arg.Any <Item>(), _loginModel.ShoppinglistId);
        }
Пример #3
0
        public void ShowRecipeCommand_UserClickAdd_FoodplanColelctorReceivesAddRecipeTupleToFoodplan()
        {
            //Setup
            ISubWindowFactory fac = Substitute.For <ISubWindowFactory>();

            _sut.SetWindowFactory(fac);
            IRecipeInformationWindowDialog dia = Substitute.For <IRecipeInformationWindowDialog>();

            fac.GetRecipeInformationWindow(Arg.Any <Recipe>(), Arg.Any <Window>(), Arg.Any <string>()).Returns(dia);
            dia.ShowDialog().Returns(true);

            Recipe r = new Recipe();

            _sut.ShowRecipeCommand.Execute(r);
            _foodplanCollector.Received().AddRecipeTupleToFoodplan(_loginModel.FoodplanId, new Tuple <Recipe, DateTime>(r, Arg.Any <DateTime>()));
        }
Пример #4
0
        public void ShowRecipeCommand_UserClickCancel_ShoppingListIsNotCalled()
        {
            //Setup
            ISubWindowFactory fac = Substitute.For <ISubWindowFactory>();

            _uut.SetWindowFactory(fac);
            IRecipeInformationWindowDialog dia = Substitute.For <IRecipeInformationWindowDialog>();

            fac.GetRecipeInformationWindow(Arg.Any <Recipe>(), Arg.Any <Window>(), Arg.Any <string>()).Returns(dia);
            dia.ShowDialog().Returns(false);

            Recipe r = new Recipe();

            _uut.ShowRecipeCommand.Execute(r);
            _shoppingList.DidNotReceive().AddItem(Arg.Any <Item>());
        }
Пример #5
0
        public void ShowRecipeCommand_UserClickAdd_RecipeIsAddedToFoodplan()
        {
            //Setup
            ISubWindowFactory fac = Substitute.For <ISubWindowFactory>();

            _uut.SetWindowFactory(fac);
            IRecipeInformationWindowDialog dia = Substitute.For <IRecipeInformationWindowDialog>();

            fac.GetRecipeInformationWindow(Arg.Any <Recipe>(), Arg.Any <Window>(), Arg.Any <string>()).Returns(dia);
            dia.ShowDialog().Returns(true);

            Recipe r = new Recipe();

            _uut.ShowRecipeCommand.Execute(r);
            _foodplan.Received().Add(r, Arg.Any <DateTime>());
        }
Пример #6
0
        private void ShowRecipe(Recipe recipeToShow)
        {
            Window _win;

            if (Application.ResourceAssembly == null)
            {
                _win = null;
            }
            else
            {
                _win = Application.Current.MainWindow;
            }


            var SRC = _fac.GetRecipeInformationWindow(recipeToShow,
                                                      _win, "");

            if (SRC.ShowDialog())
            {
                _foodplan.Add(recipeToShow, SRC.GetDate());
            }
        }