public activitySignIn ( string idPrefix, int dwccardnum ) : bool | ||
idPrefix | string | |
dwccardnum | int | |
Résultat | bool |
public void SePerson_signin_sanctioned_worker_fails() { //Arrange var _per = (Web.ViewModel.Person)ViewModelRecords.person.Clone(); var _wkr = (Web.ViewModel.Worker)ViewModelRecords.worker.Clone(); _wkr.memberexpirationdate = DateTime.Now.AddYears(1); _wkr.dwccardnum = sharedUI.nextAvailableDwccardnum(frb.ToFactory().Get()); var _san = (Web.ViewModel.Event)ViewModelRecords.event1.Clone(); _san.Person = _per; _san.eventTypeID = MacheteLookup.cache.First(x => x.category == "eventtype" && x.text_EN == "Sanction").ID; var _act = (Web.ViewModel.Activity)ViewModelRecords.activity.Clone(); //Act ui.personCreate(_per); _wkr.ID = _per.ID; ui.workerCreate(_wkr, testimagefile); // ui.workerSanction(_wkr); // _san.PersonID = _per.ID; ui.eventCreate(_san); ui.activityCreate(_act); // refactored other test to identify idPrefix-dwccardnum ui.activitySignIn(_act.idChild, _wkr.dwccardnum); //Assert Assert.IsTrue(ui.activitySignInIsSanctioned()); }
public void SeActivity_unauth_worker_signin() { // example from ActivityTests.cs -- SeActivity_Create_signin_simple() // Arrange // creates one activity within the hour frb.AddActivity(startTime: DateTime.Now, endTime: DateTime.Now.AddHours(1)); Random rand = new Random(); int rowcount = 1; var workers = frb.ToFactory().Workers; Activity _act = (Activity)Records.activity.Clone(); ActivitySignin _asi = (ActivitySignin)Records.activitysignin.Clone(); IEnumerable <int> cardlist = frb.ToFactory().Workers.Select(q => q.dwccardnum).Distinct(); int firstCardNum = workers.First().dwccardnum; // Act //ui.activityCreate(_act); ui.activityMenuLink(); //Find Activity menu link and click var activityRecord = ui.WaitForElement(By.XPath("//table[@id='activityTable']/tbody/tr[1]")); var activityRecordID = Convert.ToInt32(activityRecord.GetAttribute("recordid")); var idPrefix = "asi" + activityRecordID + "-"; ui.WaitAndDoubleClick(By.XPath("//table[@id='activityTable']/tbody/tr[1]")); // ui.activitySignIn("asi" + activityRecordID + "-dwccardnum", firstCardNum); ui.activitySignIn(idPrefix, firstCardNum); // Assert // borrowed from sharedUI.cs -- activitySignInValidate() Assert.IsNotNull(ui.WaitForElementValue(By.XPath("//table[@id='asi" + activityRecordID + "-asiTable']/tbody/tr[" + rowcount + "]/td[2]"), firstCardNum.ToString()), "Did not find added record number in signin table"); }
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); }