public void ATC6790_TenancyRequestRoomingAccomodation()
        {
            #region Start Up Excel
            MyBook = MyApp.Workbooks.Open(DatasourceDir + @"\TenancyRequests.xlsx", 0, false, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
            MySheet = (Excel.Worksheet)MyBook.Sheets[Properties.Settings.Default.ENVIRONMENT.ToString()];
            MyRange = MySheet.UsedRange;
            //Get specific row for the data
            int testDataRows = MyRange.Rows.Count;
            int MyRow = 0;
            for (int i = 2; i <= testDataRows; i++)
            {
                if (MyRange.Cells[i, 1].Value.ToString() == "6790")
                {
                    MyRow = i;
                    break;
                }
            }
            #endregion

            string initialRequestParty = MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("INITIAL_REQUEST_PARTY")].Value.ToString();
            string initialContribution = MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("INITIAL_CONTRIBUTION")].Value.ToString();

            //Login as RBS user
            User user = this.environment.GetUser(SecurityRole.RBSOfficer);
            new LoginDialog().Login(user.Id, user.Password);

            //Navigate to: Rental Bond Services > Tenancy Requests
            HomePage homePage = new HomePage(driver);
            homePage.HoverCRMRibbonTab();
            homePage.ClickRBSRibbonButton();
            homePage.HoverRBSRibbonTab();
            homePage.ClickRtaTenancyRequestRibbonButton();

            TenancyRequestsSearchPage tenancyRequestSearchPage = new TenancyRequestsSearchPage(driver);
            tenancyRequestSearchPage.SetPageFilterList("All Tenancy Requests");
            Table table = new Table(tenancyRequestSearchPage.GetHeaderSearchResultTable());
            table.ClickTableColumnHeader("Created On");
            table.ClickTableColumnHeader("Created On");

            Table searchTable = new Table(tenancyRequestSearchPage.GetSearchResultTable());
            string lastCreatedTenancyReqNo = searchTable.GetCellContainsValue("Name", "TR-BL", "Name");

            //(Template) - Create new Tenancy Request (Bond Lodgement)
            tenancyRequestSearchPage.ClickNewTenancyRequestButton();

            TenancyRequestPage tenancyRequestPage = new TenancyRequestPage(driver);
            tenancyRequestPage.ClickPageTitle();

            //Set {Type} field to Bond Lodgement.
            tenancyRequestPage.SetRequestTypeListValue("Bond Lodgement");
            tenancyRequestPage.SetTenancyTypeListValue("Rooming Accommodation");

            //Check Dwelling Type field	1. Lookup list filtered to only: [ Boarding House | Supported Accommodation | Student Accommodation off Campus |Studio]
            Assert.IsTrue(tenancyRequestPage.GetDwellingTypeText("Boarding House"));
            tenancyRequestPage.ClickPageTitle();
            Assert.IsTrue(tenancyRequestPage.GetDwellingTypeText("Supported Accommodation"));
            tenancyRequestPage.ClickPageTitle();
            Assert.IsTrue(tenancyRequestPage.GetDwellingTypeText("Student Accommodation off Campus"));
            tenancyRequestPage.ClickPageTitle();
            Assert.IsTrue(tenancyRequestPage.GetDwellingTypeText("Studio"));

            //Set Dwelling Type to Boarding House.Number of Bedrooms defaults to 1 and shows as read only
            tenancyRequestPage.SetDwellingTypeListValue("Boarding House");
            tenancyRequestPage.ClickPageTitle();
            StringAssert.Contains(tenancyRequestPage.GetNumberOfBedrooms(), "1");
            StringAssert.Contains(tenancyRequestPage.GetNumberOfBedroomsProperty("data-controlmode"), "locked");

            //Set Dwelling Type to Supported Accommodation.Number of Bedrooms defaults to 1 and shows as read only
            tenancyRequestPage.SetDwellingTypeListValue("Supported Accommodation");
            tenancyRequestPage.ClickPageTitle();
            StringAssert.Contains(tenancyRequestPage.GetNumberOfBedrooms(), "1");
            StringAssert.Contains(tenancyRequestPage.GetNumberOfBedroomsProperty("data-controlmode"), "locked");

            //Set Dwelling Type to Studio	Number of Bedrooms defaults to 1 and shows as read only
            tenancyRequestPage.SetDwellingTypeListValue("Studio");
            tenancyRequestPage.ClickPageTitle();
            StringAssert.Contains(tenancyRequestPage.GetNumberOfBedrooms(), "1");
            StringAssert.Contains(tenancyRequestPage.GetNumberOfBedroomsProperty("data-controlmode"), "locked");

            //Set Dwelling Type to Student Accommodation off Campus.Number of Bedrooms defaults to 1 and shows as read only
            tenancyRequestPage.SetDwellingTypeListValue("Student Accommodation off Campus");
            tenancyRequestPage.ClickPageTitle();
            StringAssert.Contains(tenancyRequestPage.GetNumberOfBedrooms(), "1");
            StringAssert.Contains(tenancyRequestPage.GetNumberOfBedroomsProperty("data-controlmode"), "locked");

            //Check Management Type field. Lookup list filtered to only: [ Owner (or can be Lessor/Owner) | Real Estate Agent | Manager/provider | Other ]
            Assert.IsTrue(tenancyRequestPage.GetTenancyManagementTypeListValue("Lessor/Owner"));
            Assert.IsTrue(tenancyRequestPage.GetTenancyManagementTypeListValue("Real Estate Agent"));
            Assert.IsTrue(tenancyRequestPage.GetTenancyManagementTypeListValue("Manager/provider"));
            Assert.IsTrue(tenancyRequestPage.GetTenancyManagementTypeListValue("Other"));

            //Set Rental Premise to an address with the following details: [Type, "Australian Physical" | Locality populated | Room/Site Number NOT populated]
            //Example:"33 SHORE ST, EAST BRISBANE, QLD, 4169"
            string roadnumber = "33";
            string roadname = "SHORE ST";
            string locality = "EAST BRISBANE, QLD, 4169";

            tenancyRequestPage.CreateNewAddress(roadnumber,roadname,locality);
            tenancyRequestPage = new TenancyRequestPage(driver);

            //Populate mandatory fields. Save record.
            tenancyRequestPage.SetManagingPartyListValue(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("MANAGING_PARTY")].Value.ToString());
            tenancyRequestPage.SetTenancyManagementTypeListValue(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("MANAGEMENT_TYPE")].Value.ToString());
            tenancyRequestPage.SetInitialRequestPartyWithSearch(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("INITIAL_REQUEST_PARTY")].Value.ToString());
            tenancyRequestPage.SetInitialConrtibution(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("INITIAL_CONTRIBUTION")].Value.ToString());
            tenancyRequestPage.SetAmountPaidWithLodgement(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("AMOUNT_PAID_LODGEMENT")].Value.ToString());
            tenancyRequestPage.SetLodgementTypeListValue(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("LODGEMENT_TYPE")].Value.ToString());

            tenancyRequestPage.ClickSaveButton();

            //Record saves. Soft warning (Missing room number): DISPLAYED
            StringAssert.Contains(tenancyRequestPage.GetWarningMessage(), "The selected address does not have a Room/Site number.");

            /*The Name field for the Tenancy Request will be populated with 'TR-BL-' and concatenated with the Reference Number field that will be populated
            with increments of 1 from the most recent Tenancy request record. Example: Given the most recent Tenancy Request name is 'TR-BL-20000016' then this record will be 'TR-BL-20000017'*/
            string tenancyRequest = tenancyRequestPage.GetRequestNumber();
            StringAssert.Contains(tenancyRequest, "TR-BL", "Validating the newly created tenancy request has TR-BL format");
            int oldTRNo = Int32.Parse(lastCreatedTenancyReqNo.Split('-')[2]);
            int newTRNo = Int32.Parse(tenancyRequest.Split('-')[2]);
            Assert.AreEqual(oldTRNo + 1, newTRNo, "Validating the TR No is incremented by 1 from the last created TR");

            tenancyRequestPage.ClickSaveCloseButton();

            tenancyRequestSearchPage = new TenancyRequestsSearchPage(driver);
            tenancyRequestSearchPage.SetTenancyRequestSearchText(tenancyRequest);

            searchTable = new Table(tenancyRequestSearchPage.GetSearchResultTable());
            //Check record in record grid. As updated/entered
            StringAssert.Contains(searchTable.GetCellContainsValue("Name",tenancyRequest,"Tenancy Type"), "Rooming Accommodation");
            StringAssert.Contains(searchTable.GetCellContainsValue("Name",tenancyRequest,"Managing Party"),MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("MANAGING_PARTY")].Value.ToString());
            StringAssert.Contains(searchTable.GetCellContainsValue("Name",tenancyRequest,"Rental Premises"),MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("RENTAL_PREMISES")].Value.ToString());
            StringAssert.Contains(searchTable.GetCellContainsValue("Name", tenancyRequest, "Dwelling Type"), "Student Accommodation off Campus");
            StringAssert.Contains(searchTable.GetCellContainsValue("Name", tenancyRequest, "Amount Bond Paid with Lodgement").Replace(",",""), MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("AMOUNT_PAID_LODGEMENT")].Value.ToString());

            searchTable.ClickCellContainsValue("Name", tenancyRequest, "Name");

            //Remove Rental Premise address. Save record.	Record not saved as field is mandatory.
            tenancyRequestPage = new TenancyRequestPage(driver);
            tenancyRequestPage.ClickPageTitle();

            tenancyRequestPage.ClearRentalPremisesValue();

            tenancyRequestPage.ClickSaveButton();
            StringAssert.Contains(tenancyRequestPage.GetRentalPremiseAddressErrorText(), "You must provide a value for Rental Premises.");
            tenancyRequestPage.ClickPageTitle();

            //Set Rental Premise to an address with the following details: [Type, "Australian Physical" | Locality populated | Room/Site Number populated]
            //Example: "RM 4, 33 SHORE ST, EAST BRISBANE, QLD, 4101"	Record saves. Soft warning (Missing room number): NOT DISPLAYED
            string roomtype = "Room";
            string roomno = "4";
            tenancyRequestPage.CreateNewAddress(roadnumber, roadname, locality, roomtype, roomno);
            tenancyRequestPage = new TenancyRequestPage(driver);
            tenancyRequestPage.ClickSaveButton();

            Assert.IsFalse(tenancyRequestPage.GetWarningMessage().Contains("The selected address does not have a Room/Site number."));
            tenancyRequestPage.ClickSaveCloseButton();

            //Check record in record grid	As updated/entered
            tenancyRequestSearchPage = new TenancyRequestsSearchPage(driver);
            tenancyRequestSearchPage.SetTenancyRequestSearchText(tenancyRequest);
            searchTable = new Table(tenancyRequestSearchPage.GetSearchResultTable());
            StringAssert.Contains(searchTable.GetCellContainsValue("Name", tenancyRequest, "Rental Premises"), "RM 4, 33 SHORE ST, EAST BRISBANE, QLD, 4169");

            #region Shut down Excel
            MyBook.Save();
            MyBook.Close();
            MyApp.Quit();
            #endregion
        }
        public void ATC6904a_CRMTopupExcessBondValidation()
        {
            #region Start Up Excel
            MyBook = MyApp.Workbooks.Open(DatasourceDir + @"\TenancyRequests.xlsx", 0, false, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
            MySheet = (Excel.Worksheet)MyBook.Sheets[Properties.Settings.Default.ENVIRONMENT.ToString()];
            MyRange = MySheet.UsedRange;

            //Get specific row for the data
            int testDataRows = MyRange.Rows.Count;
            int MyRow = 0;
            for (int i = 2; i <= testDataRows; i++)
            {
                if (MyRange.Cells[i, 1].Value.ToString() == "Topup_6904")
                {
                    MyRow = i;
                    break;
                }
            }
            #endregion

            //Data preparation step-Tenancy with bond balance of 100

            //Creating a tenancy request for the data prep
            string managepingParty = MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("MANAGING_PARTY")].Value.ToString();

            User user = this.environment.GetUser(SecurityRole.RBSOfficer);
            new LoginDialog().Login(user.Id, user.Password);

            HomePage homePage = new HomePage(driver);
            homePage.HoverCRMRibbonTab();
            homePage.ClickRBSRibbonButton();
            homePage.HoverRBSRibbonTab();
            homePage.ClickRtaTenancyRequestRibbonButton();

            TenancyRequestsSearchPage tenancyRequestsSearchPage = new TenancyRequestsSearchPage(driver);
            tenancyRequestsSearchPage.ClickNewTenancyRequestButton();

            TenancyRequestPage tenancyRequestPage = new TenancyRequestPage(driver);
            tenancyRequestPage.ClickPageTitle();

            tenancyRequestPage.SetRequestTypeListValue(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("REQUEST_TYPE")].Value.ToString());
            string rentalPremises = MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("RENTAL_PREMISES")].Value.ToString();

            string[] address = rentalPremises.Split(',');

            string roadno = address[0].Split(' ')[0];
            string roadname = address[0].Split(' ')[1];
            string locality = address[1].Split(' ')[1] + "," + address[2] + "," + address[3];

            tenancyRequestPage.CreateNewAddress(roadno,roadname,locality,"Room");
            tenancyRequestPage = new TenancyRequestPage(driver);

            tenancyRequestPage.SetManagingPartyListValue(managepingParty);
            tenancyRequestPage.SetTenancyTypeListValue(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("TENANCY_TYPE")].Value.ToString());
            tenancyRequestPage.SetTenancyManagementTypeListValue(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("MANAGEMENT_TYPE")].Value.ToString());
            tenancyRequestPage.SetInitialRequestPartyWithSearch(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("INITIAL_REQUEST_PARTY")].Value.ToString());
            tenancyRequestPage.SetInitialConrtibution(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("INITIAL_CONTRIBUTION")].Value.ToString());
            tenancyRequestPage.SetAmountPaidWithLodgement(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("AMOUNT_PAID_LODGEMENT")].Value.ToString());
            tenancyRequestPage.SetLodgementTypeListValue(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("LODGEMENT_TYPE")].Value.ToString());

            tenancyRequestPage.SetWeeklyRent(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("WEEKLY_RENT")].Value.ToString());
            tenancyRequestPage.SetTenancyStartDate(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("TENANCY_START")].Value.ToString());
            tenancyRequestPage.SetAnticipatedEndDate(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("ANTICIPATED_END")].Value.ToString());
            tenancyRequestPage.SetPaymentType(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("PAYMENT_TYPE")].Value.ToString());

            tenancyRequestPage.SetDwellingTypeListValue(MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("DWELLING_TYPE")].Value.ToString());

            tenancyRequestPage.ClickSaveButton();

            string tenancyrequest = tenancyRequestPage.GetRequestNumber();
            MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("TR_NUMBER")].Value = tenancyrequest;
            string amount = MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("INITIAL_CONTRIBUTION")].Value.ToString();
            tenancyRequestPage.SetStatusReason("Ready for validation");
            tenancyRequestPage.ClickSaveButton();
            StringAssert.Contains(tenancyRequestPage.GetValidationStatusReason(), "Validation successful");
            tenancyRequestPage.ClickSaveCloseButton();

            tenancyRequestsSearchPage = new TenancyRequestsSearchPage(driver);
            tenancyRequestsSearchPage.SetTenancyRequestSearchText(tenancyrequest);
            Assert.IsTrue(tenancyRequestsSearchPage.GetPaymentRefernceRefreshTable(tenancyrequest));

            Table table = new Table(tenancyRequestsSearchPage.GetSearchResultTable());
            table.ClickCellValue("Name", tenancyrequest, "Name");

            tenancyRequestPage = new TenancyRequestPage(driver);
            table = new Table(tenancyRequestPage.GetPaymentSummaryResultTable());

            string referencenumber = table.GetCellValue("Tenancy Request", tenancyrequest, "Reference Number");
            MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("PAY_REF_NUMBER")].Value = referencenumber;
            StringAssert.Contains(tenancyRequestPage.GetStatusReason(), "Pending Financials");
            StringAssert.Contains(tenancyRequestPage.GetFundedStatus(), "Payment pending");

            //Create BPay file with new reference number
            string dateValue = DateTime.Today.ToString("yyyyMMdd");
            string fileLocation = Utils.BPayFileCreator.bPayFileCreator(referencenumber, dateValue, tenancyrequest, MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("INITIAL_CONTRIBUTION")].Value.ToString() + "00");
            MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("OUTFILE")].Value = fileLocation;

            #region Shut down Excel
            MyBook.Save();
            MyBook.Close();
            MyApp.Quit();
            #endregion
        }
        public void ATC6738_RaiseExceptionInvalidKeyword()
        {
            #region Start Up Excel
            MyBook = MyApp.Workbooks.Open(DatasourceDir + @"\TenancyRequests.xlsx", 0, false, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
            MySheet = (Excel.Worksheet)MyBook.Sheets[Properties.Settings.Default.ENVIRONMENT.ToString()];
            MyRange = MySheet.UsedRange;

            //Get specific row for the data
            int testDataRows = MyRange.Rows.Count;
            int MyRow = 0;
            for (int i = 2; i <= testDataRows; i++)
            {
                if (MyRange.Cells[i, 1].Value.ToString() == "6362")
                {
                    MyRow = i;
                    break;
                }
            }
            #endregion

            string initialRequestParty = MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("INITIAL_REQUEST_PARTY")].Value.ToString();
            string initialContribution = MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("INITIAL_CONTRIBUTION")].Value.ToString();
            string rentalPremises = MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("RENTAL_PREMISES")].Value.ToString();

            //Login as RBS user
            User user = this.environment.GetUser(SecurityRole.RBSOfficer);
            new LoginDialog().Login(user.Id, user.Password);

            //Navigate to: Rental Bond Services > Tenancy Requests
            HomePage homePage = new HomePage(driver);
            homePage.HoverCRMRibbonTab();
            homePage.ClickRBSRibbonButton();
            homePage.HoverRBSRibbonTab();
            homePage.ClickRtaTenancyRequestRibbonButton();

            TenancyRequestsSearchPage tenancyRequestSearchPage = new TenancyRequestsSearchPage(driver);

            //(Template) - Create new Tenancy Request (Bond Lodgement)
            tenancyRequestSearchPage.ClickNewTenancyRequestButton();

            TenancyRequestPage tenancyRequestPage = new TenancyRequestPage(driver);
            tenancyRequestPage.ClickPageTitle();

            //Set {Type} field to Bond Lodgement.
            tenancyRequestPage.SetRequestTypeListValue("Bond Lodgement");

            /*Select 'Australian Physical' as the Type.Enter an address into the fields on the Address Detail record. As part of the address that you enter, Type in the word 'Garage' into the 'Complex Unit Number' field
            Click on the Save & Close button*/
            string[] address = rentalPremises.Split(',');
            string complexunitno = address[0];
            string roadno = address[1].Split(' ')[1];
            string roadname = address[1].Split(' ')[2];
            string locality = address[2].Split(' ')[1] + "," + address[3] + "," + address[4];

            tenancyRequestPage.CreateNewAddress(roadno,roadname,locality,"","",complexunitno);
            tenancyRequestPage = new TenancyRequestPage(driver);

            //Select the mandatory fields for the Tenancy Request.Add a new Request Party whose contribution amount is the same as the Amount Paid with Lodgement
            tenancyRequestPage.PopulateTenancyRequestWithoutRentalPremisesFromAddressDetailAssociatedView(
              MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("REQUEST_TYPE")].Value.ToString(),
              MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("MANAGING_PARTY")].Value.ToString(),
              MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("TENANCY_TYPE")].Value.ToString(),
              MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("MANAGEMENT_TYPE")].Value.ToString(),
              MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("NO_ROOMS")].Value.ToString(),
              initialRequestParty,
              MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("WEEKLY_RENT")].Value.ToString(),
              initialContribution,
              MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("AMOUNT_PAID_LODGEMENT")].Value.ToString(),
              MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("LODGEMENT_TYPE")].Value.ToString(),
              MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("TENANCY_START")].Value.ToString(),
              MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("ANTICIPATED_END")].Value.ToString(),
              MyRange.Cells[MyRow, TenancyRequestSchema.GetColumnIndex("PAYMENT_TYPE")].Value.ToString());

            tenancyRequestPage.SetDwellingTypeListValue("House");
            //Save the Tenancy Request
            tenancyRequestPage.ClickSaveButton();

            string tenancyrequest = tenancyRequestPage.GetRequestNumber();

            //Set the status of the Tenancy Request to be 'Ready for Validation'	Validation process for the Tenancy Request is started
            tenancyRequestPage.SetStatusReason("Ready for validation");
            tenancyRequestPage.ClickSaveButton();
            Thread.Sleep(3000);

            //The status of the Tenancy Request should be set to Validation failed
            StringAssert.Contains(tenancyRequestPage.GetStatusReason(), "Validation failed");

            //Check the Queue Reasons of the Tenancy Request.There should be a queue reason that exists which is for 'Invalid address: Invalid key word detected'
            //tenancyRequestPage.ClickQueueReasons();
            Table queueReasonTable = new Table(tenancyRequestPage.GetQueueReasonTable());
            StringAssert.Contains(queueReasonTable.GetCellContainsValue("Reason", "Invalid address : Invalid keyword detected", "Status Reason"), "To be resolved");

            #region Shut down Excel
            MyBook.Save();
            MyBook.Close();
            MyApp.Quit();
            #endregion
        }