コード例 #1
0
 public LoginPageController BuildController(LoginPageControllerMocks mocks, IMainPage mainPage)
 {
     return(new LoginPageController
            (
                mainPage,
                mocks.JwtTokenManager.Object,
                mocks.CreateLoginPage.Object,
                mocks.LrpNavigation.Object
            ));
 }
コード例 #2
0
        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();
        }
コード例 #3
0
        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();
        }
コード例 #4
0
        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
        }
コード例 #5
0
        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();
        }
コード例 #6
0
        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();
        }