void Ex01() { When("the valid user id and password are set", () => { LoginContent.UserId.Value = "user"; LoginContent.Password.Value = "password"; UserAuthentication.Authenticate(LoginContent.UserId.Value, LoginContent.Password.Value) .Returns(UserAuthenticationResult.Succeeded()); }); When("to click the login button", () => AvaloniaController.EventHandlersOf(Controller) .GetBy("LoginButton") .Raise(nameof(Button.Click)) ); Then("the content should be navigated to the UserContent", () => { Navigator.Received(1).NavigateTo(Arg.Is <UserContent>(content => content.Id == LoginContent.UserId.Value)); }); }
void Ex05() { When("the no authenticated user id and password are set", () => { LoginContent.UserId.Value = "user"; LoginContent.Password.Value = "password"; UserAuthentication.Authenticate(LoginContent.UserId.Value, LoginContent.Password.Value) .Returns(UserAuthenticationResult.Failed()); }); When("to click the login button", () => AvaloniaController.EventHandlersOf(Controller) .GetBy("LoginButton") .Raise(nameof(Button.Click)) ); Then("the content should not be navigated to any contents", () => { Navigator.DidNotReceive().NavigateTo(Arg.Any <object>()); }); Then("the LoginFailureMessage message should be set", () => LoginContent.Message.Value == Resources.LoginFailureMessage); }