public void Login_Login_Validated() { // arrange ILoginViewModel loginViewModel = this.CreateSubject(); // act loginViewModel.ShowDialog(); loginViewModel.UserName = ""; loginViewModel.LoginCommand.Execute(null); // assert Assert.IsTrue(((IErrorContainer)loginViewModel).HasErrors); }
protected override void OnStartup(StartupEventArgs e) { IAppViewModelFactory viewModelFactory = this.ConfigureContainer(); ILoginViewModel loginViewModel = viewModelFactory.ResolveViewModel <ILoginViewModel>(); loginViewModel.ShowDialog(); if (loginViewModel.DialogResult != null) { IMainViewModel mainViewModel = viewModelFactory.ResolveViewModel <IMainViewModel>(); mainViewModel.Closed += (s, ea) => this.Shutdown(); mainViewModel.Show(); } else { this.Shutdown(); } }
public void Login_Login_Failed() { // arrange var loggedInUser = new UserModel(); loggedInUser.AddError("invalid username or password"); this._contactService.Setup(x => x.Login(It.IsAny <string>(), It.IsAny <string>())).Returns(Task.FromResult <UserModel>(loggedInUser)); ILoginViewModel loginViewModel = this.CreateSubject(); // act loginViewModel.ShowDialog(); loginViewModel.UserName = "******"; loginViewModel.Password = "******"; loginViewModel.LoginCommand.Execute(null); // assert Assert.IsNull(loginViewModel.DialogResult); this._contactService.Verify(x => x.Login(It.IsAny <string>(), It.IsAny <string>()), Times.Once); }
public void Login_Login_Success() { // arrange var loggedInUser = new UserModel { Id = 1, Name = "name", UserName = "******", Password = "******" }; this._contactService.Setup(x => x.Login(It.IsAny <string>(), It.IsAny <string>())).Returns(Task.FromResult <UserModel>(loggedInUser)); ILoginViewModel loginViewModel = this.CreateSubject(); // act loginViewModel.ShowDialog(); loginViewModel.UserName = "******"; loginViewModel.Password = "******"; loginViewModel.LoginCommand.Execute(null); // assert this._contactService.Verify(x => x.Login(It.IsAny <string>(), It.IsAny <string>()), Times.Once); Assert.IsNotNull(loginViewModel.DialogResult); Assert.AreEqual("username", loginViewModel.DialogResult.UserName); Assert.AreEqual("1", loginViewModel.DialogResult.Password); }