public activitySignInValidate ( string idPrefix, int dwccardnum, int rowcount ) : bool | ||
idPrefix | string | |
dwccardnum | int | |
rowcount | int | |
Результат | bool |
public void SeActivity_Create_ManySignins() { //Arrange int rowcount = 1; Random rand = new Random(); if (frb.ToFactory().Workers.Select(q => q.dwccardnum).Distinct().Count() <= 10) { frb.AddWorker(); } // // IEnumerable <int> list = frb.ToFactory().Workers.Select(q => q.dwccardnum).Distinct().ToList(); var count = list.Count(); int numberOfSignins = rand.Next(count / 10) + 1; //+1 will never lead to zero here int numberSignedIn = numberOfSignins; IEnumerable <int> list1 = list.Take <int>(numberOfSignins); var _act = (Web.ViewModel.Activity)ViewModelRecords.activity.Clone(); //Act ui.activityCreate(_act); var idPrefix = "asi" + _act.ID + "-"; for (var i = 0; i < numberOfSignins; i++) { int cardNum = list1.ElementAt(i); ui.activitySignIn(idPrefix, cardNum); Thread.Sleep(1000);//prevent race condition if (ui.activitySignInIsSanctioned()) { --numberSignedIn; continue; } //Assert Thread.Sleep(1000);//prevent race condition Assert.IsTrue(ui.activitySignInValidate(idPrefix, cardNum, rowcount), "Sign in for worker " + i + " with cardNum " + cardNum + " failed!"); //This line ensures the test doesn't break if we try to sign in an ID that has multiple workers attached to it. //rowcount increments by the number of records found in the database matching that cardNum rowcount += frb.ToFactory().Workers.Where(q => q.dwccardnum == cardNum).Count(); } ui.WaitThenClickElement(By.Id("activityListTab")); //ui.SelectOption(By.XPath("//*[@id='activityTable_length']/label/select"), "100"); //Assert // Chaim 4/2/2014 // This isn't working because I disabled auto-reload. It was making // the table appear strangely when I disabled pagination. I did that // because pagination was unpopular with users. // Todo: Either make auto-reload work or find another way of reloading // the page. //Locate record within activitylist datatable and compare the count (column 4) with numberSignedIn Assert.AreEqual(numberSignedIn.ToString(), ui.WaitForElement(By.XPath("//table[@id='activityTable']/tbody/tr[@recordid='" + _act.ID + "']/td[4]")).Text); //walk through pagination to search for recordid //var activityRecordCount = "what"; //bool tableRecordMatch = false; //while (tableRecordMatch == false) { // if (ui.WaitForElementExists(By.XPath("//table[@id='activityTable']/tbody/tr[@recordid='" + _act.ID + "']"))) { // tableRecordMatch = true; // activityRecordCount = ui.WaitForElement(By.XPath("//table[@id='activityTable']/tbody/tr[@recordid='" + _act.ID + "']/td[4]")).Text; // } else { //check for #activityTable_next.paginate_disabled_next //Assert.IsTrue(ui.WaitThenClickElement(By.CssSelector("#activityTable_next.paginate_enabled_next")), "Could not locate record in table pagination"); //} //} //Assert.AreEqual(numberSignedIn.ToString(), activityRecordCount); }