void Ex01() { When("to click the Logout button", () => AvaloniaController.EventHandlersOf(Controller) .GetBy("LogoutButton") .Raise(nameof(Button.Click)) ); Then("the content should be navigated to the LoginContent", () => { Navigator.Received(1).NavigateTo(Arg.Any <LoginContent>()); }); }
void Ex01() { When("to attach the SimpleLoginDemoContent to the logical tree", () => AvaloniaController.EventHandlersOf(Controller) .GetBy(null) .Raise(nameof(StyledElement.AttachedToLogicalTree)) ); Then("the content should be navigated to the LoginContent", () => { Navigator.Received(1).NavigateTo(Arg.Any <LoginContent>()); }); }
void Ex04() { When("the invalid user id and password are set", () => { LoginContent.UserId.Value = null; LoginContent.Password.Value = null; }); 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 message of the login content should be empty", () => LoginContent.Message.Value == string.Empty); }
void Ex03() { Given("a controller to which the IUserAuthentication is not specified", () => { Controller = new LoginContentController(Navigator, null); AvaloniaController.SetDataContext(LoginContent, Controller); }); 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 LoginNotAvailable message should be set", () => LoginContent.Message.Value == Resources.LoginNotAvailable); }
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); }
public SimpleLoginDemoContentControllerSpec() { Controller = new SimpleLoginDemoContentController(Navigator); AvaloniaController.SetDataContext(Content, Controller); }
public LoginContentControllerSpec() { Controller = new LoginContentController(Navigator, UserAuthentication); AvaloniaController.SetDataContext(LoginContent, Controller); }