public LoginPageController BuildController(LoginPageControllerMocks mocks, IMainPage mainPage) { return(new LoginPageController ( mainPage, mocks.JwtTokenManager.Object, mocks.CreateLoginPage.Object, mocks.LrpNavigation.Object )); }
public async Task MainPage_OnAppearingAsync() { var mocks = new LoginPageControllerMocks(); MockForms.Init(); var mainPage = new MainPage(); var loginPage = new LoginPage(); var sequence = new MockSequence(); mocks.CreateLoginPage.InSequence(sequence).Setup(c => c()).Returns(loginPage); mocks.LrpNavigation.InSequence(sequence).Setup(n => n.PushModalAsync(loginPage)).Returns(Task.CompletedTask); BuildController(mocks, mainPage); await mainPage.OnAppearingAsync(); }
public async Task LoginPage_OnLoginClickedAsync_Cancelled() { var mocks = new LoginPageControllerMocks(); MockForms.Init(); var mainPage = new MainPage(); var loginPage = new LoginPage(); var sequence = new MockSequence(); mocks.CreateLoginPage.InSequence(sequence).Setup(c => c()).Returns(loginPage); mocks.LrpNavigation.InSequence(sequence).Setup(n => n.PushModalAsync(loginPage)).Returns(Task.CompletedTask); var cancelledException = new MsalException(LrpConstants.AuthenticationCanceledErrorCode); mocks.JwtTokenManager.InSequence(sequence).Setup(j => j.RequestLoginAsync()).Throws(cancelledException); BuildController(mocks, mainPage); await mainPage.OnAppearingAsync(); await loginPage.OnLoginClickedAsync(); }
public async Task LoginPage_OnLoginClickedAsync_LoginResult_False_Throws() { var mocks = new LoginPageControllerMocks(); MockForms.Init(); var mainPage = new MainPage(); var loginPage = new LoginPage(); var sequence = new MockSequence(); mocks.CreateLoginPage.InSequence(sequence).Setup(c => c()).Returns(loginPage); mocks.LrpNavigation.InSequence(sequence).Setup(n => n.PushModalAsync(loginPage)).Returns(Task.CompletedTask); mocks.JwtTokenManager.InSequence(sequence).Setup(j => j.RequestLoginAsync()).ReturnsAsync(false); BuildController(mocks, mainPage); await mainPage.OnAppearingAsync(); await loginPage.OnLoginClickedAsync(); // would expect to see a modal warning popped here and then return to login page }
public async Task LoginPage_OnAppearingAsync_AfterLogin() { var mocks = new LoginPageControllerMocks(); MockForms.Init(); var mainPage = new MainPage(); var loginPage = new LoginPage(); var sequence = new MockSequence(); mocks.CreateLoginPage.InSequence(sequence).Setup(c => c()).Returns(loginPage); mocks.LrpNavigation.InSequence(sequence).Setup(n => n.PushModalAsync(loginPage)).Returns(Task.CompletedTask); mocks.JwtTokenManager.InSequence(sequence).Setup(j => j.RequestLoginAsync()).ReturnsAsync(true); mocks.LrpNavigation.InSequence(sequence).Setup(n => n.PopModalAsync()).ReturnsAsync(loginPage); BuildController(mocks, mainPage); await mainPage.OnAppearingAsync(); await loginPage.OnLoginClickedAsync(); await mainPage.OnAppearingAsync(); }
public async Task LoginPage_OnLoginClickedAsync_PasswordReset() { var mocks = new LoginPageControllerMocks(); MockForms.Init(); var mainPage = new MainPage(); var loginPage = new LoginPage(); var sequence = new MockSequence(); mocks.CreateLoginPage.InSequence(sequence).Setup(c => c()).Returns(loginPage); mocks.LrpNavigation.InSequence(sequence).Setup(n => n.PushModalAsync(loginPage)).Returns(Task.CompletedTask); var passwordResetException = new Exception($"{LrpConstants.PasswordResetMessageContents}"); mocks.JwtTokenManager.InSequence(sequence).Setup(j => j.RequestLoginAsync()).Throws(passwordResetException); mocks.JwtTokenManager.InSequence(sequence).Setup(j => j.ResetPasswordAsync()).ReturnsAsync(true); mocks.JwtTokenManager.InSequence(sequence).Setup(j => j.RequestLoginAsync()).ReturnsAsync(true); mocks.LrpNavigation.InSequence(sequence).Setup(n => n.PopModalAsync()).ReturnsAsync(loginPage); BuildController(mocks, mainPage); await mainPage.OnAppearingAsync(); await loginPage.OnLoginClickedAsync(); }