Example #1
0
        public void SetUp()
        {
            //Setup mocks
            _foodplanCollector = Substitute.For <IFoodplanCollector>();
            _recipeCollector   = Substitute.For <IRecipeCollector>();
            _msgService        = Substitute.For <IMessageBoxService>();
            _itemCollector     = Substitute.For <IItemCollector>();
            _userCollector     = Substitute.For <IUserCollector>();

            //Setup reals
            _scheduler         = new TimerScheduler(2);
            _loginModel        = new LoginModel(_userCollector);
            _recipeListModel   = new RecipeListModel(_recipeCollector);
            _shoppingListModel = new ScheduledShoppingListModel(_itemCollector, _scheduler, _loginModel);
            _foodplanModel     = new FoodplanModel(_foodplanCollector, _shoppingListModel, _recipeListModel, _loginModel, _msgService);
            _sut = new FoodplanViewModel(_foodplanModel)
            {
                Foodplan = new ObservableCollection <Recipe>()
            };
            _foodplanModel.Foodplan.RecipeList = new List <Tuple <Recipe, DateTime> >();

            //Login with Henrik
            _userCollector.DoesUserExist("", "").ReturnsForAnyArgs(true);
            _loginModel.Login("Henrik", "secret");
        }
        public void Constructor_CollectorReturns4Items_SutHolds4Items()
        {
            _itemCollector.GetAll("Henrik").Returns(new List<Item>() { new Item(), new Item(), new Item(), new Item() });
            _shoppingListModel = new ScheduledShoppingListModel(_itemCollector, _scheduler, _loginModel);
            _sut = new ShoppingListViewModel(_shoppingListModel);

            Assert.That(_sut.ShoppingList.Count, Is.EqualTo(4));
        }
 public void SetUp()
 {
     _recipeSizeWidth = 220;
     _model           = Substitute.For <IRecipeListModel>();
     _foodplan        = Substitute.For <IFoodplanModel>();
     _shoppingList    = Substitute.For <IShoppingListModel>();
     _uut             = new RecipeListViewModel(_model, _recipeSizeWidth, _foodplan, _shoppingList);
 }
Example #4
0
 public void SetUp()
 {
     _shoppingListModel = Substitute.For <IShoppingListModel>();
     _shoppingListModel.ShoppingList.Returns(new List <Item>()
     {
         new Item()
     });
     _uut = new ShoppingListViewModel(_shoppingListModel);
 }
 public void SetUp()
 {
     _recipeSizeWidth = 220;
     _model = Substitute.For<IRecipeListModel>();
     _foodplan = Substitute.For<IFoodplanModel>();
     _shoppingList = Substitute.For<IShoppingListModel>();
     _msgBoxService = Substitute.For<IMessageBoxService>();
     _uut = new RecipeListViewModel(_model, _recipeSizeWidth, _foodplan, _msgBoxService);
 }
        /// <summary>
        /// Sets up the foodplan model with constructorinjection of all its properties
        /// </summary>
        /// <param name="foodplanCollector"></param>
        /// <param name="shoppingListModel"></param>
        /// <param name="recipeListModel"></param>
        /// <param name="loginModel"></param>
        /// <param name="msgBoxService"></param>
        public FoodplanModel(IFoodplanCollector foodplanCollector, IShoppingListModel shoppingListModel,
		IRecipeListModel recipeListModel, ILoginModel loginModel, IMessageBoxService msgBoxService)
        {
            _foodplanCollector = foodplanCollector;
            _shoppingListModel = shoppingListModel;
            _recipeListModel = recipeListModel;
			_loginModel = loginModel;
            _msgBoxService = msgBoxService;
            _foodPlan = new Foodplan();
		}
 /// <summary>
 /// Sets up the foodplan model with constructorinjection of all its properties
 /// </summary>
 /// <param name="foodplanCollector"></param>
 /// <param name="shoppingListModel"></param>
 /// <param name="recipeListModel"></param>
 /// <param name="loginModel"></param>
 /// <param name="msgBoxService"></param>
 public FoodplanModel(IFoodplanCollector foodplanCollector, IShoppingListModel shoppingListModel,
                      IRecipeListModel recipeListModel, ILoginModel loginModel, IMessageBoxService msgBoxService)
 {
     _foodplanCollector = foodplanCollector;
     _shoppingListModel = shoppingListModel;
     _recipeListModel   = recipeListModel;
     _loginModel        = loginModel;
     _msgBoxService     = msgBoxService;
     _foodPlan          = new Foodplan();
 }
 /// <summary>
 /// Sets up the ShoppingListViewModel using constructor injection
 /// </summary>
 /// <param name="SLM"></param>
 public ShoppingListViewModel(IShoppingListModel SLM)
 {
     if (SLM == null) throw new ArgumentNullException();
     _shoppingListModel = SLM;
     _shoppingListModel.ListUpdatedEvent += new EventHandler(Sort);
     _shoppingListModel.LoadingListEvent += HandleLoadingListEvent;
     _showBoughtItems = false;
     ChangeShowBtnText = "Show Bought Items";
     Sort();
 }
        public void Constructor_CollectorReturns4Items_SutHolds4Items()
        {
            _itemCollector.GetAll("Henrik").Returns(new List <Item>()
            {
                new Item(), new Item(), new Item(), new Item()
            });
            _shoppingListModel = new ScheduledShoppingListModel(_itemCollector, _scheduler, _loginModel);
            _sut = new ShoppingListViewModel(_shoppingListModel);

            Assert.That(_sut.ShoppingList.Count, Is.EqualTo(4));
        }
Example #10
0
 /// <summary>
 /// Sets up the ShoppingListViewModel using constructor injection
 /// </summary>
 /// <param name="SLM"></param>
 public ShoppingListViewModel(IShoppingListModel SLM)
 {
     if (SLM == null)
     {
         throw new ArgumentNullException();
     }
     _shoppingListModel = SLM;
     _shoppingListModel.ListUpdatedEvent += new EventHandler(Sort);
     _shoppingListModel.LoadingListEvent += HandleLoadingListEvent;
     _showBoughtItems  = false;
     ChangeShowBtnText = "Show Bought Items";
     Sort();
 }
        public void Setup()
        {
            _foodplanCollector = Substitute.For <IFoodplanCollector>();
            _shoppingListModel = Substitute.For <IShoppingListModel>();
            _recipeListModel   = Substitute.For <IRecipeListModel>();
            _loginModel        = Substitute.For <ILoginModel>();
            _msgBoxService     = Substitute.For <IMessageBoxService>();

            _uut          = new FoodplanModel(_foodplanCollector, _shoppingListModel, _recipeListModel, _loginModel, _msgBoxService);
            _uut.Foodplan = new Foodplan()
            {
                RecipeList = new List <Tuple <Recipe, DateTime> >()
            };
        }
        public void SetUp()
        {
            //Setup mocks
            _userCollector = Substitute.For<IUserCollector>();
            _userCollector.GetShoppinglistId("").ReturnsForAnyArgs(5);
            _itemCollector = Substitute.For<IItemCollector>();

            //Setup reals
            _scheduler = new TimerScheduler(2);
            _loginModel = new LoginModel(_userCollector);
            _shoppingListModel = new ScheduledShoppingListModel(_itemCollector, _scheduler, _loginModel);
            _sut = new ShoppingListViewModel(_shoppingListModel);

            //Login with Henrik
            _userCollector.DoesUserExist("", "").ReturnsForAnyArgs(true);
            _loginModel.Login("Henrik", "secret");
        }
 /// <summary>
 /// Sets upp all the ViewModels and Models
 /// </summary>
 public ViewModelLocator()
 {
     _messageBoxService = new MessageBoxService();
     _loginModel        = new LoginModel(new UserHttpCollector(5));
     _foodplanCollector = new FoodplanHttpCollector();
     _loginViewModel    = new LoginViewModel(_loginModel, _messageBoxService, new WindowOpeningService());
     _recipeListModel   = new RecipeListModel(new RecipeHTTPCollector());
     _shoppingListModel = new ScheduledShoppingListModel
                              (new ItemHttpCollector(), new TimerScheduler(60), _loginModel);
     _shoppingListViewModel = new ShoppingListViewModel(_shoppingListModel);
     _foodplanModel         = new FoodplanModel
                                  (_foodplanCollector, _shoppingListModel, _recipeListModel, _loginModel, _messageBoxService);
     _recipeViewModel          = new RecipeListViewModel(_recipeListModel, 300, _foodplanModel, _messageBoxService);
     _addRecipeWindowViewModel = new AddRecipeWindowViewModel(_recipeListModel, new DialogImageChooser());
     _foodplanViewModel        = new FoodplanViewModel(_foodplanModel);
     _mwmvvm = new MainWindowViewModel();
 }
        public void SetUp()
        {
            //Setup mocks
            _userCollector = Substitute.For <IUserCollector>();
            _userCollector.GetShoppinglistId("").ReturnsForAnyArgs(5);
            _itemCollector = Substitute.For <IItemCollector>();

            //Setup reals
            _scheduler         = new TimerScheduler(2);
            _loginModel        = new LoginModel(_userCollector);
            _shoppingListModel = new ScheduledShoppingListModel(_itemCollector, _scheduler, _loginModel);
            _sut = new ShoppingListViewModel(_shoppingListModel);

            //Login with Henrik
            _userCollector.DoesUserExist("", "").ReturnsForAnyArgs(true);
            _loginModel.Login("Henrik", "secret");
        }
        public void Setup()
        {
            //Setup mocks
            _foodplanCollector = Substitute.For <IFoodplanCollector>();
            _itemCollector     = Substitute.For <IItemCollector>();
            _userCollector     = Substitute.For <IUserCollector>();
            _recipeCollector   = Substitute.For <IRecipeCollector>();

            //Setup reals
            _loginModel        = new LoginModel(_userCollector);
            _shoppingListModel = new ScheduledShoppingListModel
                                     (_itemCollector, new TimerScheduler(60), _loginModel);
            _recipeListModel = new RecipeListModel(_recipeCollector);

            // Uut
            _uut          = new FoodplanModel(_foodplanCollector, _shoppingListModel, _recipeListModel, _loginModel);
            _uut.Foodplan = new Foodplan()
            {
                RecipeList = new List <Tuple <Recipe, DateTime> >()
            };
        }
        public void SetUp()
        {
            _recipeSizeWidth = 220;
            //Setup mocks
            _foodplanCollector = Substitute.For<IFoodplanCollector>();
            _recipeCollector = Substitute.For<IRecipeCollector>();
            _msgService = Substitute.For<IMessageBoxService>();
            _itemCollector = Substitute.For<IItemCollector>();
            _userCollector = Substitute.For<IUserCollector>();
            _shoppingListModel = Substitute.For<IShoppingListModel>();

            //Setup reals
            _loginModel = new LoginModel(_userCollector);
            _recipeListModel = new RecipeListModel(_recipeCollector);
            _foodplanModel = new FoodplanModel(_foodplanCollector, _shoppingListModel, _recipeListModel, _loginModel, _msgService);
            _foodplanModel.Foodplan.RecipeList = new List<Tuple<Recipe, DateTime>>();
            _sut = new RecipeListViewModel(_recipeListModel, _recipeSizeWidth, _foodplanModel, _msgService);

            //Login with Henrik
            _userCollector.DoesUserExist("", "").ReturnsForAnyArgs(true);
            _loginModel.Login("Henrik", "secret");
        }
        public void SetUp()
        {
            //Setup mocks
            _foodplanCollector = Substitute.For<IFoodplanCollector>();
            _recipeCollector = Substitute.For<IRecipeCollector>();
            _msgService = Substitute.For<IMessageBoxService>();
            _itemCollector = Substitute.For<IItemCollector>();
            _userCollector = Substitute.For<IUserCollector>();

            //Setup reals
            _scheduler = new TimerScheduler(2);
            _loginModel = new LoginModel(_userCollector);
            _recipeListModel = new RecipeListModel(_recipeCollector);
            _shoppingListModel = new ScheduledShoppingListModel(_itemCollector, _scheduler, _loginModel);
            _foodplanModel = new FoodplanModel (_foodplanCollector, _shoppingListModel, _recipeListModel, _loginModel, _msgService);
            _sut = new FoodplanViewModel(_foodplanModel) { Foodplan = new ObservableCollection<Recipe>() };
            _foodplanModel.Foodplan.RecipeList = new List<Tuple<Recipe, DateTime>>();

            //Login with Henrik
            _userCollector.DoesUserExist("", "").ReturnsForAnyArgs(true);
            _loginModel.Login("Henrik", "secret");
        }
        public void SetUp()
        {
            _recipeSizeWidth = 220;
            //Setup mocks
            _foodplanCollector = Substitute.For <IFoodplanCollector>();
            _recipeCollector   = Substitute.For <IRecipeCollector>();
            _msgService        = Substitute.For <IMessageBoxService>();
            _itemCollector     = Substitute.For <IItemCollector>();
            _userCollector     = Substitute.For <IUserCollector>();
            _shoppingListModel = Substitute.For <IShoppingListModel>();

            //Setup reals
            _loginModel      = new LoginModel(_userCollector);
            _recipeListModel = new RecipeListModel(_recipeCollector);
            _foodplanModel   = new FoodplanModel(_foodplanCollector, _shoppingListModel, _recipeListModel, _loginModel, _msgService);
            _foodplanModel.Foodplan.RecipeList = new List <Tuple <Recipe, DateTime> >();
            _sut = new RecipeListViewModel(_recipeListModel, _recipeSizeWidth, _foodplanModel, _msgService);

            //Login with Henrik
            _userCollector.DoesUserExist("", "").ReturnsForAnyArgs(true);
            _loginModel.Login("Henrik", "secret");
        }
 public void Constructor_LoginModelUsernameIsHenrik_ItemCollectorGetAllIsCalled()
 {
     _shoppingListModel = new ScheduledShoppingListModel(_itemCollector, _scheduler, _loginModel);
     _sut = new ShoppingListViewModel(_shoppingListModel);
     _itemCollector.Received().GetAll("Henrik");
 }
 public void SetUp()
 {
     _shoppingListModel = Substitute.For<IShoppingListModel>();
     _shoppingListModel.ShoppingList.Returns(new List<Item>() {new Item()});
     _uut = new ShoppingListViewModel(_shoppingListModel);
 }
 public void Constructor_LoginModelUsernameIsHenrik_ItemCollectorGetAllIsCalled()
 {
     _shoppingListModel = new ScheduledShoppingListModel(_itemCollector, _scheduler, _loginModel);
     _sut = new ShoppingListViewModel(_shoppingListModel);
     _itemCollector.Received().GetAll("Henrik");
 }