public void LoginCommandExecuted_CollectorDoesUserExistReturnsFalse_MessageServiceShowErrorCalled() { _collector.DoesUserExist("", "").ReturnsForAnyArgs(false); _sut.UserName = "******"; _sut.Password = "******"; _sut.LoginCommand.Execute(null); _messageService.Received().ShowError("Wrong username or password"); }
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"); }
/// <summary> /// Uses the userCollector to perform a login /// Id successfull login gets all userinfo with <see cref="GetUserInfo"/> /// </summary> /// <param name="username">Username to perform login with</param> /// <param name="password">Password to perform login with</param> /// <returns>True if logged in /// False if not</returns> public async Task <bool> Login(string username, string password) { bool successLogin = await _collector.DoesUserExist(username, password); if (successLogin) { Username = username; GetUserInfo(username); return(true); } Log.File.Warning("User: "******" attempted and failed to login."); return(false); }
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 _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() { _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() { _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 Login_CollectorDoesUserExistReturnsTrue_UutUsernameIsSet() { _collector.DoesUserExist("", "").ReturnsForAnyArgs(true); _uut.Login("Bent", "Secret"); Assert.That(_uut.Username, Is.EqualTo("Bent")); }