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); }