public void ATC3340_CRMInvestigationAllegedOffenseStatusChangesToBelief()
        {
            User user = this.environment.GetUser(SecurityRole.InvestigationsOfficer);
            new LoginDialog().Login(user.Id, user.Password);

            HomePage homePage = new HomePage(driver);
            string HomeWindow = driver.CurrentWindowHandle;
            homePage.HoverCRMRibbonTab();
            homePage.ClickInvestigationsRibbonButton();
            homePage.HoverInvestigationsRibbonTab();
            homePage.ClickInvestigationsCasesRibbonButton();

            InvestigationCaseSearchPage investigationsCaseSearchPage = new InvestigationCaseSearchPage(driver);
            investigationsCaseSearchPage.ClickNewInvestigationCaseButton();

            // Create new case and validate Status and Substatus fields
            InvestigationCasePage investigationCasePage = new InvestigationCasePage(driver);
            investigationCasePage.ClickSaveButton();
            String investigationID = investigationCasePage.GetInvestigationCaseNumber();
            investigationCasePage.ClickSaveCloseButton();

            driver = driver.SwitchTo().Window(HomeWindow);
            homePage.HoverInvestigationsRibbonTab();
            homePage.ClickRightScrollRibbonButton();
            homePage.ClickAllegedOffencesButton();

            AllegendOffensesSearchPage allegedOffencesSearchPage = new AllegendOffensesSearchPage(driver);

            allegedOffencesSearchPage.ClickNewAllegedOffenceButton();

            AllegedOffencePage allegedOffencesPage = new AllegedOffencePage(driver);
            allegedOffencesPage.SetInvestigationCaseValue(investigationID);
            allegedOffencesPage.SetProvisionValue("RTRA 116(1)");
            allegedOffencesPage.ClickSaveButton();
            StringAssert.Contains(allegedOffencesPage.GetStatusReason(), "Suspicion");

            string OffenceDate = DateTime.Now.AddYears(-1).ToString("d/MM/yyyy");
            allegedOffencesPage.SetOffenceDateValue(OffenceDate);
            string todaysDate = DateTime.Now.ToString("d/MM/yyyy");
            allegedOffencesPage.SetBeliefFormedDateValue(todaysDate);
            allegedOffencesPage.ClickSaveButton();

            StringAssert.Contains(allegedOffencesPage.GetStatusReason(), "Belief");
            string StatutoryDate = allegedOffencesPage.GetStatutoryLimitationValue();
            string allegedoffenceId = allegedOffencesPage.GetReferenceNumber();
            allegedOffencesPage.ClickSaveCloseButton();

            allegedOffencesSearchPage = new AllegendOffensesSearchPage(driver);
            allegedOffencesSearchPage.SetInvestigationSearchText(investigationID);
            Table table = new Table(allegedOffencesSearchPage.GetSearchResultTable());
            table.SelectTableRow("Status Reason", "Belief");

            allegedOffencesPage = new AllegedOffencePage(driver);
            StringAssert.Contains(allegedOffencesPage.GetStatusReason(), "Belief");
            StringAssert.Contains(allegedOffencesPage.GetStatutoryLimitationValue(), StatutoryDate);
            StringAssert.Contains(allegedOffencesPage.GetBefliefFormedDateValue(), todaysDate);
        }
        public void ATC3284_CRMEntityAllegedOffenceBeliefDateblankedStatusReasonreverts()
        {
            string allegedoffenceId;
            string todayDate = DateTime.Now.ToString("d/MM/yyyy");
            string investigationID;

            //Login in as role
            User user = this.environment.GetUser(SecurityRole.Investigations);
            new LoginDialog().Login(user.Id, user.Password);

            HomePage homePageInvestigation = new HomePage(driver);
            homePageInvestigation.HoverCRMRibbonTab();
            homePageInvestigation.ClickInvestigationsRibbonButton();
            homePageInvestigation.HoverInvestigationsRibbonTab();
            homePageInvestigation.ClickInvestigationsCasesRibbonButton();

            InvestigationCaseSearchPage investigationCaseSearchPage = new InvestigationCaseSearchPage(driver);
            investigationCaseSearchPage.ClickNewInvestigationCaseButton();

            InvestigationCasePage investigationCasePage = new InvestigationCasePage(driver);
            investigationCasePage.ClickSaveButton();
            investigationID = investigationCasePage.GetInvestigationCaseNumber();
            investigationCasePage.ClickSaveCloseButton();

            homePageInvestigation.HoverCRMRibbonTab();
            homePageInvestigation.ClickInvestigationsRibbonButton();
            homePageInvestigation.HoverInvestigationsRibbonTab();
            homePageInvestigation.ClickRightScrollRibbonButton();
            homePageInvestigation.ClickAllegedOffencesButton();

            AllegendOffensesSearchPage allegedOffencesSearchPage = new AllegendOffensesSearchPage(driver);

            allegedOffencesSearchPage.ClickNewAllegedOffenceButton();

            AllegedOffencePage allegedOffencesPage = new AllegedOffencePage(driver);
            allegedOffencesPage.SetInvestigationCaseValue(investigationID);
            allegedOffencesPage.SetProvisionValue("RTRA 116(1)");
            allegedOffencesPage.SetOffenceDateValue("1/01/2015");
            allegedOffencesPage.SetBeliefFormedDateValue(todayDate);
            allegedOffencesPage.ClickSaveButton();
            allegedoffenceId = allegedOffencesPage.GetReferenceNumber();
            allegedOffencesPage.ClickSaveCloseButton();

            allegedOffencesSearchPage = new AllegendOffensesSearchPage(driver);
            allegedOffencesSearchPage.SetInvestigationSearchText(investigationID);
            Table table = new Table(allegedOffencesSearchPage.GetSearchResultTable());
            table.SelectTableRow("Status Reason", "Belief");

            allegedOffencesPage = new AllegedOffencePage(driver);
            allegedOffencesPage.SetOffenceDateValue("");
            StringAssert.Contains(allegedOffencesPage.GetOffenceDateValue(),"--");
            allegedOffencesPage.SetBeliefFormedDateValue("");
            StringAssert.Contains(allegedOffencesPage.GetStatusReason(), "Suspicion");

            allegedoffenceId = allegedOffencesPage.GetReferenceNumber();
            allegedOffencesPage.ClickSaveCloseButton();

            allegedOffencesSearchPage = new AllegendOffensesSearchPage(driver);
            allegedOffencesSearchPage.SetInvestigationSearchText(allegedoffenceId);
            table = new Table(allegedOffencesSearchPage.GetSearchResultTable());
            table.SelectContainsTableRow("Investigation Case", investigationID);

            allegedOffencesPage = new AllegedOffencePage(driver);
            StringAssert.Contains(allegedOffencesPage.GetStatusReason(), "Suspicion");
            StringAssert.Contains(allegedOffencesPage.GetOffenceDateValue(), "--");
            StringAssert.Contains(allegedOffencesPage.GetStatutoryLimitationValue(), "--");

            allegedOffencesPage.SetOffenceDateValue("01/01/2015");
            allegedOffencesPage.ClickSaveButton();

            StringAssert.Contains(allegedOffencesPage.GetStatutoryLimitationValue(), "1/01/2016");

            StringAssert.Contains(allegedOffencesPage.GetBefliefFormedDateValue(),"");
        }
        public void ATC3326_CRMInvestigationUserAccessToRecordOutcomeOfAllegedOffence()
        {
            string[] allowedUserName = { "Investig ationsOfficer", "Investigations",
                                           "InvestigationsManager", "InvestigationsBusinessAdmin",
                                           "InvestigationsOfficer", "ESOForPES", "ExecutiveManagerForPES" };
            string[] notAllowedUserName = { "GeneralStaff", "RBSOfficer","IMSBusinessSupportStaff" ,"ResearchOfficers","RecordKeepingOfficers"};
            bool LastIteration = false;

            // CAN
            User user = this.environment.GetUser(SecurityRole.InvestigationOfficer);
            for (int i = 0; i < allowedUserName.Length; i++)
            {

                //Login in as role
                switch (i)
                {
                    case 0:
                        user = this.environment.GetUser(SecurityRole.InvestigationOfficer);
                        break;
                    case 1:
                        user = this.environment.GetUser(SecurityRole.Investigations);
                        break;
                    case 2:
                        user = this.environment.GetUser(SecurityRole.InvestigationsManager);
                        break;
                    case 3:
                        user = this.environment.GetUser(SecurityRole.InvestigationsBusinessAdmin);
                        break;
                    case 4:
                        user = this.environment.GetUser(SecurityRole.InvestigationsOfficer);
                        break;
                    case 5:
                        user = this.environment.GetUser(SecurityRole.ESOForPES);
                        break;
                    case 6:
                        user = this.environment.GetUser(SecurityRole.ExecutiveManagerForPES);
                        LastIteration = true;
                        break;
                }
                new LoginDialog().Login(user.Id, user.Password);

                HomePage homePage = new HomePage(driver);
                String HomeWindow = driver.CurrentWindowHandle;
                homePage.HoverCRMRibbonTab();

                homePage.ClickInvestigationsRibbonButton();
                homePage.HoverInvestigationsRibbonTab();
                homePage.ClickInvestigationsCasesRibbonButton();

                // Select the 'All Investigation Cases' view from the table
                InvestigationCaseSearchPage investigationCaseSearchPage = new InvestigationCaseSearchPage(driver);
                investigationCaseSearchPage.ClickNewInvestigationCaseButton();

                InvestigationCasePage investigationCasePage = new InvestigationCasePage(driver);
                investigationCasePage.ClickSaveButton();
                string investigationID = investigationCasePage.GetInvestigationCaseNumber();
                investigationCasePage.ClickSaveCloseButton();

                driver = driver.SwitchTo().Window(HomeWindow);
                homePage.HoverCRMRibbonTab();
                homePage.ClickInvestigationsRibbonButton();
                homePage.HoverInvestigationsRibbonTab();
                homePage.ClickRightScrollRibbonButton();
                homePage.ClickAllegedOffencesButton();

                AllegendOffensesSearchPage allegedOffencesSearchPage = new AllegendOffensesSearchPage(driver);

                allegedOffencesSearchPage.ClickNewAllegedOffenceButton();

                AllegedOffencePage allegedOffencesPage = new AllegedOffencePage(driver);
                allegedOffencesPage.SetInvestigationCaseValue(investigationID);
                allegedOffencesPage.SetProvisionValue("RTRA 116(1)");
                allegedOffencesPage.ClickSaveButton();
                string allegedoffenceId = allegedOffencesPage.GetReferenceNumber();
                allegedOffencesPage.ClickSaveCloseButton();

                allegedOffencesSearchPage = new AllegendOffensesSearchPage(driver);
                allegedOffencesSearchPage.SetInvestigationSearchText(allegedoffenceId);
                Table table = new Table(allegedOffencesSearchPage.GetSearchResultTable());
                Assert.AreEqual(1, table.GetRowCount(), "Allegend Offense creation failed!!!!!");

                if (LastIteration == false)
                {
                    driver.Quit();
                    driver = null;
                    this.TestSetup();
                }
                // CAN end
            }

            // CAN NOT -1
            LastIteration = false;

            for (int i = 0; i <= 2; i++)
            {
                //Login in as role
                switch (i)
                {
                    case 0:
                        user = this.environment.GetUser(SecurityRole.GeneralStaff);
                        break;
                    case 1:
                        user = this.environment.GetUser(SecurityRole.RBSOfficer);
                        break;
                    case 2:
                        user = this.environment.GetUser(SecurityRole.IMSBusinessSupportStaff);
                        LastIteration = true;
                        break;
                }
                new LoginDialog().Login(user.Id, user.Password);

                HomePage homePage = new HomePage(driver);
                String HomeWindow = driver.CurrentWindowHandle;
                homePage.HoverCRMRibbonTab();
                Assert.IsFalse(homePage.VerifyInvestigationsRibbonButtonPresent(),String.Format("Investigation Ribbon Button is seen for {0}",user.Id));

                if (LastIteration == false)
                {
                    driver.Quit();
                    driver = null;
                    this.TestSetup();
                }
            }

            // CAN NOT -2
            LastIteration = false;
            for (int i = 3; i == 4; i++)
            {
                //Login in as role
                switch (i)
                {
                    case 3:
                        user = this.environment.GetUser(SecurityRole.ResearchOfficers);
                        break;
                    case 4:
                        user = this.environment.GetUser(SecurityRole.RecordKeepingOfficers);
                        LastIteration = true;
                        break;
                }
                new LoginDialog().Login(user.Id, user.Password);

                HomePage homePage = new HomePage(driver);
                String HomeWindow = driver.CurrentWindowHandle;
                homePage.HoverCRMRibbonTab();
                homePage.ClickInvestigationsRibbonButton();
                homePage.HoverInvestigationsRibbonTab();
                homePage.ClickInvestigationsCasesRibbonButton();

                // Select the 'All Investigation Cases' view from the table
                InvestigationCaseSearchPage investigationCaseSearchPage = new InvestigationCaseSearchPage(driver);

                Assert.IsFalse(investigationCaseSearchPage.VerifyNewInvestigationCaseButtonPresent(), String.Format("New Investigation Case Button is seen for {0}", user.Id));

                if (LastIteration == false)
                {
                    driver.Quit();
                    driver = null;
                    this.TestSetup();
                }
            }
        }