Пример #1
0
 /// <summary>
 /// Sets up the RecipeListViewModel using constructor injection
 /// </summary>
 /// <param name="recipeListModel"></param>
 /// <param name="recipeWidthSize"></param>
 /// <param name="foodplan"></param>
 /// <param name="msgBoxService"></param>
 public RecipeListViewModel(IRecipeListModel recipeListModel, int recipeWidthSize,
                            IFoodplanModel foodplan, IMessageBoxService msgBoxService)
 {
     _fac             = new SubWindowFactory();
     _recipeWidthSize = recipeWidthSize;
     _recipeListModel = recipeListModel;
     _foodplan        = foodplan;
     _msgBoxService   = msgBoxService;
     SizeChanged(FrameworkElement.ActualWidthProperty.GlobalIndex);
     _recipeList = new ObservableCollection <Recipe>();
     _fac        = new SubWindowFactory();
     _recipeListModel.RecipeListUpdatedEvent += RecipeListUpdatedEventHandler;
 }
 /// <summary>
 /// Sets up the RecipeListViewModel using constructor injection
 /// </summary>
 /// <param name="recipeListModel"></param>
 /// <param name="recipeWidthSize"></param>
 /// <param name="foodplan"></param>
 /// <param name="msgBoxService"></param>
 public RecipeListViewModel(IRecipeListModel recipeListModel, int recipeWidthSize,
     IFoodplanModel foodplan, IMessageBoxService msgBoxService)
 {
     _fac = new SubWindowFactory();
     _recipeWidthSize = recipeWidthSize;
     _recipeListModel = recipeListModel;
     _foodplan = foodplan;
     _msgBoxService = msgBoxService;
     SizeChanged(FrameworkElement.ActualWidthProperty.GlobalIndex);
     _recipeList = new ObservableCollection<Recipe>();
     _fac = new SubWindowFactory();
     _recipeListModel.RecipeListUpdatedEvent += RecipeListUpdatedEventHandler;
 }
Пример #3
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);
        }
Пример #4
0
        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>()));
        }
Пример #5
0
        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);
        }
Пример #6
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);
        }
Пример #7
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>()));
        }
Пример #8
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>());
        }
Пример #9
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>());
        }
Пример #10
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>());
        }
Пример #11
0
 /// <summary>
 /// Sets the SubWindowFactory using property injection
 /// </summary>
 /// <param name="fac"></param>
 public void SetWindowFactory(ISubWindowFactory fac)
 {
     _fac = fac;
 }
 /// <summary>
 /// Sets the SubWindowFactory using property injection
 /// </summary>
 /// <param name="fac"></param>
 public void SetWindowFactory(ISubWindowFactory fac)
 {
     _fac = fac;
 }