public void AddRecipe_UserClickOK_FoodplanCollectorIsCalled()
        {
            //Setup
            ISubWindowFactory fac = Substitute.For <ISubWindowFactory>();

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

            fac.GetCalenderDialog(Arg.Any <Window>()).Returns(dia);
            dia.ShowDialog().Returns(true);

            Recipe r = new Recipe();

            _sut.AddRecipeCommand.Execute(r);
            _foodplanCollector.Received().AddRecipeTupleToFoodplan(_loginModel.FoodplanId, new Tuple <Recipe, DateTime>(r, Arg.Any <DateTime>()));
        }
Example #2
0
        public void AddRecipe_UserClickCancel_FoodplanIsNotCalled()
        {
            //Setup
            ISubWindowFactory fac = Substitute.For <ISubWindowFactory>();

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

            fac.GetCalenderDialog(Arg.Any <Window>()).Returns(dia);
            dia.ShowDialog().Returns(false);

            Recipe r = new Recipe();

            _uut.AddRecipeCommand.Execute(r);
            _foodplan.DidNotReceive().Add(r, Arg.Any <DateTime>());
        }
        public void AddRecipe_UserClickCancel_ItemCollectorAddIsNotCalled()
        {
            //Setup
            ISubWindowFactory fac = Substitute.For <ISubWindowFactory>();

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

            fac.GetCalenderDialog(Arg.Any <Window>()).Returns(dia);
            dia.ShowDialog().Returns(false);

            Recipe r = new Recipe();

            _sut.AddRecipeCommand.Execute(r);
            _itemCollector.DidNotReceive().Add(Arg.Any <Item>(), _loginModel.ShoppinglistId);
        }
Example #4
0
        /// <summary>
        /// Adds a recipe to foodplan
        /// </summary>
        /// <param name="recipeToAdd"></param>
        private void AddRecipe(Recipe recipeToAdd)
        {
            Window _win;

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

            var CalenderDialog = _fac.GetCalenderDialog(_win);

            if (CalenderDialog.ShowDialog())
            {
                _foodplan.Add(recipeToAdd, CalenderDialog.GetDate());
            }
        }