public void LoginCommandExecuted_ModelLoginReturnsFalse_MessageServiceShowErrorCalled()
        {
            _model.Login("", "").ReturnsForAnyArgs(false);
            _uut.LoginCommand.Execute(null);

            _messageService.Received().ShowError("Wrong username or password");
        }
Ejemplo n.º 2
0
        public void LoginCommandExecuted_CollectorDoesUserExistReturnsFalse_WosShowMainWindowNotCalled()
        {
            _model.Login("", "").ReturnsForAnyArgs(false);
            _sut.LoginCommand.Execute(null);

            _wos.DidNotReceiveWithAnyArgs().OpenMainWindow();
        }
Ejemplo n.º 3
0
        private async void TryLogin()
        {
            try
            {
                bool loggedIn = await _model.Login(UserName, Password);

                if (loggedIn)
                {
                    _wos.OpenMainWindow();
                }
                else
                {
                    _messageService.ShowError("Wrong username or password");
                }
            }
            catch (TaskCanceledException e)
            {
                Log.File.Exception(e);
                _messageService.ShowError("No connection to server.");
            }
            catch (HttpRequestException e)
            {
                Log.File.Exception(e);
                _messageService.ShowError("You are not connected to the grand internet. please fix!");
            }
        }
Ejemplo n.º 4
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 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");
        }
Ejemplo n.º 6
0
        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");
        }
Ejemplo n.º 7
0
        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");
        }
Ejemplo n.º 8
0
        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");
        }
Ejemplo n.º 9
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");
        }
Ejemplo n.º 10
0
 public void Login_UsernameIsBent_CollectorDoesUserExistReceivesBent()
 {
     _uut.Login("Bent", "");
     _collector.Received().DoesUserExist("Bent", Arg.Any <string>());
 }