public void LoginDialog_RememberMeSelectedLogout_RememberEmailOnlyOnStartup()
        {
            var ribbon = AddinRibbonController.Initialize(_app);

            //Login and select Remember Me
            var loginDlg = AddinTestUtility.OpenLoginDialog(ribbon);

            loginDlg.Email      = AddinTestUtility.LoginEmail;
            loginDlg.Password   = AddinTestUtility.LoginPsw;
            loginDlg.RememberMe = true;
            loginDlg.SelectOkVerifySuccess();

            //Logout
            ribbon.InvokeButton(AddinRibbonButton.Logout);
            ribbon.ValidateSingleButtonState(AddinRibbonButton.Logout, RibbonButtonState.NonVisible);

            //Close excel
            _wb.Dispose();
            _app.Dispose();

            //Re-open excel
            _app = ExcelAutoUtility.OpenAndInstallAddin("TheAddIn", out _facade);
            _wb  = new ExcelWorkbookWrapper(_app.App.Workbooks.Add());

            ribbon = AddinRibbonController.Initialize(_app);

            //Validate not auto-logged-in, but email addr remembered
            loginDlg = AddinTestUtility.OpenLoginDialog(ribbon);

            Assert.AreEqual(AddinTestUtility.LoginEmail, loginDlg.Email);
            Assert.AreEqual(string.Empty, loginDlg.Password);

            //Close dialog
            loginDlg.SelectCancelVerifySuccess();
        }
        public void LoginDialog_RememberMeDeselected_NotLoggedInOnStartup()
        {
            var ribbon = AddinRibbonController.Initialize(_app);

            //Login and select Remember Me
            var loginDlg = AddinTestUtility.OpenLoginDialog(ribbon);

            loginDlg.Email      = AddinTestUtility.LoginEmail;
            loginDlg.Password   = AddinTestUtility.LoginPsw;
            loginDlg.RememberMe = false;
            loginDlg.SelectOkVerifySuccess();

            //Close excel
            _wb.Dispose();
            _app.Dispose();

            //Re-open excel
            _app = ExcelAutoUtility.OpenAndInstallAddin("TheAddIn", out _facade);
            _wb  = new ExcelWorkbookWrapper(_app.App.Workbooks.Add());

            //Validate not auto-logged-in
            ribbon = AddinRibbonController.Initialize(_app);

            Assert.AreEqual(RibbonButtonState.Enabled, ribbon.GetButtonState(AddinRibbonButton.Login));
        }
        public void Initialize()
        {
            if (!Debugger.IsAttached) //use excel-per-instance only when running from VS - blows up running automated from console
            {
                _app = ExcelAutoUtility.OpenAndInstallAddin("TheAddIn", out _facade);
            }
            _wb = new ExcelWorkbookWrapper(_app.App.Workbooks.Add());

            //Ensure logged out at start
            _facade.Logout();
        }
        public void LoginDialog_RememberMeSelected_LoggedInOnStartup()
        {
            var ribbon = AddinRibbonController.Initialize(_app);

            //Login and select Remember Me
            var loginDlg = AddinTestUtility.OpenLoginDialog(ribbon);

            loginDlg.Email      = AddinTestUtility.LoginEmail;
            loginDlg.Password   = AddinTestUtility.LoginPsw;
            loginDlg.RememberMe = true;
            loginDlg.SelectOkVerifySuccess();

            //Close excel
            _wb.Dispose();
            _app.Dispose();

            //Re-open excel
            _app = ExcelAutoUtility.OpenAndInstallAddin("TheAddIn", out _facade);
            _wb  = new ExcelWorkbookWrapper(_app.App.Workbooks.Add());

            //Validate auto-logged-in
            ribbon = AddinRibbonController.Initialize(_app,
                                                      true); //disableWaitForRibbonReady

            ribbon.PostInitializeSpecialCaseAutologgedIn();

            ribbon.ValidateSingleButtonState(AddinRibbonButton.Logout, RibbonButtonState.Enabled, AddinTestUtility.AuthenticationTimeout);

            //Leave test in a logged-out / non-remember-me state
            ribbon.InvokeButton(AddinRibbonButton.Logout);
            ribbon.ValidateSingleButtonState(AddinRibbonButton.Logout, RibbonButtonState.NonVisible);

            loginDlg            = AddinTestUtility.OpenLoginDialog(ribbon);
            loginDlg.Email      = AddinTestUtility.LoginEmail;
            loginDlg.Password   = AddinTestUtility.LoginPsw;
            loginDlg.RememberMe = false;
            loginDlg.SelectOkVerifySuccess();

            ribbon.InvokeButton(AddinRibbonButton.Logout);
            ribbon.ValidateSingleButtonState(AddinRibbonButton.Logout, RibbonButtonState.NonVisible);
        }