protected void Session_End(object sender, EventArgs e) { var db = new CAIRSDataContext(); List<RequestLock> locks = db.RequestLocks.Where( l => l.StartTime.AddMinutes(30) > DateTime.Now).ToList(); db.RequestLocks.DeleteAllOnSubmit(locks); db.SubmitChanges(); }
public void TestValidateDropdown() { // Add the Region to the Database directly var cdc = new CAIRSDataContext(); var random = new Random(); String codeVal = random.Next(1000000).ToString(CultureInfo.InvariantCulture); String valVal = "AdmDDInt-" + random.Next(100000000) .ToString(CultureInfo.InvariantCulture); var r = new Region { Code = codeVal, Value = valVal, Active = false }; cdc.Regions.InsertOnSubmit(r); cdc.SubmitChanges(); // Navigate to the right page _driver.Navigate().GoToUrl(CommonTestingMethods.getURL()); _ctm.findAndClick(Constants.UIString.ItemIDs.ADMIN, "/Admin/User/List"); _driver.FindElement(By.Id("nav-dropdown")).Click(); // Go to Region List _driver.FindElement(By.CssSelector("[data-dropdown='Region']")) .Click(); // Find and Click on Appropriate Region _driver.FindElement( By.XPath("//td[contains(.,'" + valVal + "')]")).Click(); // Invalidate the Region _driver.FindElement(By.Id("dk_container_active")).Click(); Thread.Sleep(500); _driver.FindElement(By.CssSelector("[data-dk-dropdown-value=true]")) .Click(); // Try to Submit the Form + Verify that we're back to admin page _ctm.findAndClick(Constants.UIString.ItemIDs.SUBMIT_BUTTON, "/Admin/Dropdown/List?success=True"); // Verify Region Shows up in Create Request Page _ctm.findAndClick(Constants.UIString.ItemIDs.CREATE_REQUEST, "/Request/Create"); _driver.FindElement(By.Id("regionID")).FindElement( By.CssSelector("[value='" + r.RegionID + "']")); // Clean up the DB var cdc2 = new CAIRSDataContext(); Region reg = cdc2.Regions.FirstOrDefault(region => region.Code == codeVal); if (reg != null) { cdc2.Regions.DeleteOnSubmit(reg); cdc2.SubmitChanges(); } else { Assert.Fail("Region has disappeared!"); } // Ensure Cleaned Up r = cdc2.Regions.FirstOrDefault(region => region.Code == codeVal); Assert.IsTrue(r == null, "Region wasn't cleaned up successfully!"); }
public void CreateDropDownSuccess() { var random = new Random(); String codeVal = random.Next(1000000).ToString(CultureInfo.InvariantCulture); String valVal = "AdmDDInt-" + random.Next(100000000) .ToString(CultureInfo.InvariantCulture); // Navigate to the right page _driver.Navigate().GoToUrl(CommonTestingMethods.getURL()); _ctm.findAndClick(Constants.UIString.ItemIDs.ADMIN, "/Admin/User/List"); _driver.FindElement(By.Id("nav-dropdown")).Click(); // Go to Region List _driver.FindElement(By.CssSelector("[data-dropdown='Region']")) .Click(); // Go to Create Region _ctm.findAndClick("button-Region", "/Admin/Dropdown/Create/Region"); // Enter Already Existing Data _driver.FindElement(By.Id("code")).SendKeys(codeVal); _driver.FindElement(By.Id("value")).SendKeys(valVal); // Try to Submit the Form + Verify that we're back to admin page _ctm.findAndClick(Constants.UIString.ItemIDs.SUBMIT_BUTTON, "/Admin/Dropdown/List?success=True"); // Verify Region Shows up in Create Request Page var cdc = new CAIRSDataContext(); Region r = cdc.Regions.FirstOrDefault(region => region.Code == codeVal); if (r == null) { Assert.Fail("Region wasn't actually created successfully!"); } _ctm.findAndClick(Constants.UIString.ItemIDs.CREATE_REQUEST, "/Request/Create"); _driver.FindElement(By.Id("regionID")).FindElement( By.CssSelector("[value='" + r.RegionID + "']")); // Clean up the DB cdc.Regions.DeleteOnSubmit(r); cdc.SubmitChanges(); // Ensure Cleaned Up r = cdc.Regions.FirstOrDefault(region => region.Code == codeVal); Assert.IsTrue(r == null, "Region wasn't cleaned up successfully!"); }
public void TestQuickSearchRequestID() { var rc = new RequestContent { patientFName = "SInt-" + _random.Next() .ToString(CultureInfo.InvariantCulture), }; // Create the RequestContent var rmc = new RequestManagementController(); long rid = rmc.create(rc); _driver.Navigate().GoToUrl(CommonTestingMethods.getURL()); _driver.FindElement(By.Id(Constants.UIString.ItemIDs.SEARCH_DIV)) .SendKeys(rid.ToString(CultureInfo.InvariantCulture)); _ctm.findAndClick(Constants.UIString.ItemIDs.SEARCH_BUTTON, "/Request/Details/" + rid.ToString(CultureInfo.InvariantCulture)); //======================================== // All done! Cleanup time! //======================================== var cdc2 = new CAIRSDataContext(); // Cleanup the AuditLog IQueryable<AuditLog> logs = cdc2.AuditLogs.Where(al => al.RequestID == rid); cdc2.AuditLogs.DeleteAllOnSubmit(logs); cdc2.SubmitChanges(); // Cleanup Request Request req = cdc2.Requests.FirstOrDefault(r => r.RequestID == rid); if (req == null) { Assert.Fail("Request can't be found for Teardown!"); } cdc2.Requests.DeleteOnSubmit(req); cdc2.SubmitChanges(); }
public void TestQuickSearchKeywords() { var kw = new Keyword { KeywordValue = "SInt-" + _random.Next() .ToString(CultureInfo.InvariantCulture) }; _cdc.Keywords.InsertOnSubmit(kw); _cdc.SubmitChanges(); // Setup the request var qrc = new QuestionResponseContent { keywords = new List<string> {kw.KeywordValue} }; var rc = new RequestContent { patientFName = "SInt-" + _random.Next() .ToString(CultureInfo.InvariantCulture), }; rc.addQuestionResponse(qrc); // Create the RequestContent var rmc = new RequestManagementController(); long rid = rmc.create(rc); //======================================== // And we're ready to go! //======================================== _driver.Navigate().GoToUrl(CommonTestingMethods.getURL()); _driver.FindElement(By.Id(Constants.UIString.ItemIDs.SEARCH_DIV)) .SendKeys(kw.KeywordValue); _ctm.findAndClick(Constants.UIString.ItemIDs.SEARCH_BUTTON, "/Search/Search"); // Check Results ReadOnlyCollection<IWebElement> row1 = _driver.FindElements(By.CssSelector("[data-id='" + rid + "']")); Assert.IsTrue(row1.Count > 0, "Request 1 not in results!"); //======================================== // All done! Cleanup time! //======================================== // Cleanup KeywordQuestion var cdc2 = new CAIRSDataContext(); KeywordQuestion keyq = cdc2.KeywordQuestions.FirstOrDefault(kq => kq.RequestID == rid); if (keyq == null) { Assert.Fail("KeywordQuestion can't be found for Teardown!"); } cdc2.KeywordQuestions.DeleteOnSubmit(keyq); cdc2.SubmitChanges(); // Cleanup Keyword Keyword kwDel = cdc2.Keywords.FirstOrDefault(k => k.KeywordID == kw.KeywordID); if (kwDel == null) { Assert.Fail("KeywordQuestion can't be found for Teardown!"); } cdc2.Keywords.DeleteOnSubmit(kwDel); cdc2.SubmitChanges(); // Cleanup QuestionResponse QuestionResponse qresp = cdc2.QuestionResponses.FirstOrDefault(qr => qr.RequestID == rid); if (qresp == null) { Assert.Fail("QuestionResponse can't be found for Teardown!"); } cdc2.QuestionResponses.DeleteOnSubmit(qresp); cdc2.SubmitChanges(); // Cleanup Request Request req = cdc2.Requests.FirstOrDefault(r => r.RequestID == rid); if (req == null) { Assert.Fail("Request can't be found for Teardown!"); } cdc2.Requests.DeleteOnSubmit(req); cdc2.SubmitChanges(); }
public void TestAdvancedSearchNone() { var kw1 = new Keyword { KeywordValue = "SInt-" + _random.Next() .ToString(CultureInfo.InvariantCulture) }; var kw2 = new Keyword { KeywordValue = "SInt-" + _random.Next() .ToString(CultureInfo.InvariantCulture) }; _cdc.Keywords.InsertAllOnSubmit(new List<Keyword> {kw1, kw2}); _cdc.SubmitChanges(); // Setup the request var qrc1 = new QuestionResponseContent { keywords = new List<string> {kw1.KeywordValue} }; var rc1 = new RequestContent { patientFName = "SInt-" + _random.Next() .ToString(CultureInfo.InvariantCulture), requestStatus = Constants.RequestStatus.Open }; rc1.addQuestionResponse(qrc1); var qrc2 = new QuestionResponseContent { keywords = new List<string> {kw2.KeywordValue} }; var rc2 = new RequestContent { patientFName = "SInt-" + _random.Next() .ToString(CultureInfo.InvariantCulture) }; rc2.addQuestionResponse(qrc2); // Create the RequestContents var rmc = new RequestManagementController(); long rid1 = rmc.create(rc1); long rid2 = rmc.create(rc2); //======================================================== // The 2:08 train for Bug-Free Ville is now Departing //======================================================== _driver.Navigate().GoToUrl(CommonTestingMethods.getURL()); _ctm.findAndClick(Constants.UIString.ItemIDs.ADVANCED_SEARCH, "/Search/Advanced"); _driver.FindElement(By.Id("noneKeywords")) .SendKeys(kw1.KeywordValue + ", "); _ctm.findAndClick(Constants.UIString.ItemIDs.SUBMIT_BUTTON, "/Search/Results"); // Check Results ReadOnlyCollection<IWebElement> row1 = _driver.FindElements(By.CssSelector("[data-id='" + rid1 + "']")); ReadOnlyCollection<IWebElement> row2 = _driver.FindElements(By.CssSelector("[data-id='" + rid2 + "']")); Assert.IsTrue(row1.Count == 0, "Request 1 in results!"); Assert.IsTrue(row2.Count > 0, "Request 2 not in results!"); //===================================================== // Oh no! The train crashed! :( Away goes the data! //===================================================== // Cleanup KeywordQuestion var cdc2 = new CAIRSDataContext(); IQueryable<KeywordQuestion> keyq1 = cdc2.KeywordQuestions.Where( kq => kq.KeywordID == kw1.KeywordID); IQueryable<KeywordQuestion> keyq2 = cdc2.KeywordQuestions.Where( kq => kq.KeywordID == kw2.KeywordID); if (keyq1 == null || keyq2 == null) { Assert.Fail("KeywordQuestion can't be found for Teardown!"); } cdc2.KeywordQuestions.DeleteAllOnSubmit(keyq1); cdc2.KeywordQuestions.DeleteAllOnSubmit(keyq2); cdc2.SubmitChanges(); // Cleanup Keyword Keyword kwDel1 = cdc2.Keywords.FirstOrDefault(k => k.KeywordID == kw1.KeywordID); Keyword kwDel2 = cdc2.Keywords.FirstOrDefault(k => k.KeywordID == kw2.KeywordID); if (kwDel1 == null || kwDel2 == null) { Assert.Fail("KeywordQuestion can't be found for Teardown!"); } cdc2.Keywords.DeleteAllOnSubmit(new List<Keyword> {kwDel1, kwDel2}); cdc2.SubmitChanges(); // Cleanup QuestionResponse QuestionResponse qresp1 = cdc2.QuestionResponses.FirstOrDefault(qr => qr.RequestID == rid1); QuestionResponse qresp2 = cdc2.QuestionResponses.FirstOrDefault(qr => qr.RequestID == rid2); if (qresp1 == null || qresp2 == null) { Assert.Fail("QuestionResponse can't be found for Teardown!"); } cdc2.QuestionResponses.DeleteAllOnSubmit( new List<QuestionResponse> {qresp1, qresp2}); cdc2.SubmitChanges(); // Cleanup Request Request req1 = cdc2.Requests.FirstOrDefault(r => r.RequestID == rid1); Request req2 = cdc2.Requests.FirstOrDefault(r => r.RequestID == rid2); if (req1 == null || req2 == null) { Assert.Fail("Request can't be found for Teardown!"); } cdc2.Requests.DeleteAllOnSubmit(new List<Request> {req1, req2}); cdc2.SubmitChanges(); }
public void TestAdvancedSearchAny() { var kw1 = new Keyword { KeywordValue = "SInt-" + _random.Next() .ToString(CultureInfo.InvariantCulture) }; var kw2 = new Keyword { KeywordValue = "SInt-" + _random.Next() .ToString(CultureInfo.InvariantCulture) }; _cdc.Keywords.InsertAllOnSubmit(new List<Keyword> {kw1, kw2}); _cdc.SubmitChanges(); // Setup the request var qrc1 = new QuestionResponseContent { keywords = new List<string> {kw1.KeywordValue} }; var rc1 = new RequestContent { patientFName = "SInt-" + _random.Next() .ToString(CultureInfo.InvariantCulture), requestStatus = Constants.RequestStatus.Open }; rc1.addQuestionResponse(qrc1); TumourGroup tg = _cdc.TumourGroups.FirstOrDefault(t => t.Active); if (tg == null) { Assert.Fail("No active TumourGroups in the system!"); } var qrc2 = new QuestionResponseContent { keywords = new List<string> {kw2.KeywordValue}, tumourGroupID = tg.TumourGroupID }; var rc2 = new RequestContent { patientFName = "SInt-" + _random.Next() .ToString(CultureInfo.InvariantCulture), requestStatus = Constants.RequestStatus.Completed }; rc2.addQuestionResponse(qrc2); QuestionType qt = _cdc.QuestionTypes.FirstOrDefault(q => q.Active); if (qt == null) { Assert.Fail("No active QuestionTypes in the system!"); } var qrc3 = new QuestionResponseContent { keywords = new List<string> {kw2.KeywordValue}, questionTypeID = qt.QuestionTypeID }; var rc3 = new RequestContent { patientFName = "SInt-" + _random.Next() .ToString(CultureInfo.InvariantCulture), requestStatus = Constants.RequestStatus.Invalid }; rc3.addQuestionResponse(qrc3); // Create the RequestContents var rmc = new RequestManagementController(); long rid1 = rmc.create(rc1); long rid2 = rmc.create(rc2); long rid3 = rmc.create(rc3); //======================================== // Vroom! Vroom! //======================================== _driver.Navigate().GoToUrl(CommonTestingMethods.getURL()); _ctm.findAndClick(Constants.UIString.ItemIDs.ADVANCED_SEARCH, "/Search/Advanced"); _driver.FindElement(By.Id("keywordString")) .SendKeys(kw1.KeywordValue + ", " + kw2.KeywordValue + ", "); _ctm.findAndClick(Constants.UIString.ItemIDs.SUBMIT_BUTTON, "/Search/Results"); // Check Results ReadOnlyCollection<IWebElement> row1 = _driver.FindElements(By.CssSelector("[data-id='" + rid1 + "']")); ReadOnlyCollection<IWebElement> row2 = _driver.FindElements(By.CssSelector("[data-id='" + rid2 + "']")); ReadOnlyCollection<IWebElement> row3 = _driver.FindElements(By.CssSelector("[data-id='" + rid3 + "']")); Assert.IsTrue(row1.Count > 0, "Request 1 not in results!"); Assert.IsTrue(row2.Count > 0, "Request 2 not in results!"); Assert.IsTrue(row3.Count > 0, "Request 3 not in results!"); // Modify the Search _ctm.findAndClick(Constants.UIString.ItemIDs.MODIFY_SEARCH, "/Search/Modify"); _driver.FindElement(By.Id(Constants.RequestStatus.Open.ToString())) .FindElement(By.ClassName("icon")).Click(); _ctm.findAndClick(Constants.UIString.ItemIDs.SUBMIT_BUTTON, "/Search/Results"); // Check Results row1 = _driver.FindElements(By.CssSelector("[data-id='" + rid1 + "']")); row2 = _driver.FindElements(By.CssSelector("[data-id='" + rid2 + "']")); row3 = _driver.FindElements(By.CssSelector("[data-id='" + rid3 + "']")); Assert.IsTrue(row1.Count > 0, "Request 1 not in results!"); Assert.IsTrue(row2.Count == 0, "Request 2 in results!"); Assert.IsTrue(row3.Count == 0, "Request 3 in results!"); // Modify the Search _ctm.findAndClick(Constants.UIString.ItemIDs.MODIFY_SEARCH, "/Search/Modify"); // Change the Status from Open to Completed _driver.FindElement(By.Id(Constants.RequestStatus.Open.ToString())) .FindElement(By.ClassName("icon")).Click(); _driver.FindElement( By.Id(Constants.RequestStatus.Completed.ToString())) .FindElement(By.ClassName("icon")).Click(); // Add a Tumour Group Search _driver.FindElement(By.Id("tumour-group")) .FindElement( By.Id( tg.TumourGroupID.ToString( CultureInfo.InvariantCulture))) .FindElement(By.ClassName("icon")) .Click(); _ctm.findAndClick(Constants.UIString.ItemIDs.SUBMIT_BUTTON, "/Search/Results"); // Check Results row1 = _driver.FindElements(By.CssSelector("[data-id='" + rid1 + "']")); row2 = _driver.FindElements(By.CssSelector("[data-id='" + rid2 + "']")); row3 = _driver.FindElements(By.CssSelector("[data-id='" + rid3 + "']")); Assert.IsTrue(row1.Count == 0, "Request 1 in results!"); Assert.IsTrue(row2.Count > 0, "Request 2 not in results!"); Assert.IsTrue(row3.Count == 0, "Request 3 in results!"); // Modify the Search _ctm.findAndClick(Constants.UIString.ItemIDs.MODIFY_SEARCH, "/Search/Modify"); // Change the Status from Completed to Invalid _driver.FindElement( By.Id(Constants.RequestStatus.Completed.ToString())) .FindElement(By.ClassName("icon")).Click(); _driver.FindElement(By.Id(Constants.RequestStatus.Invalid.ToString())) .FindElement(By.ClassName("icon")).Click(); // Remove the Tumour Group Search _driver.FindElement(By.Id("tumour-group")) .FindElement( By.Id( tg.TumourGroupID.ToString( CultureInfo.InvariantCulture))) .FindElement(By.ClassName("icon")) .Click(); // Add a Question Type Search _driver.FindElement(By.Id("question-type")) .FindElement( By.Id( qt.QuestionTypeID.ToString( CultureInfo.InvariantCulture))) .FindElement(By.ClassName("icon")) .Click(); _ctm.findAndClick(Constants.UIString.ItemIDs.SUBMIT_BUTTON, "/Search/Results"); // Check Results row1 = _driver.FindElements(By.CssSelector("[data-id='" + rid1 + "']")); row2 = _driver.FindElements(By.CssSelector("[data-id='" + rid2 + "']")); row3 = _driver.FindElements(By.CssSelector("[data-id='" + rid3 + "']")); Assert.IsTrue(row1.Count == 0, "Request 1 in results!"); Assert.IsTrue(row2.Count == 0, "Request 2 in results!"); Assert.IsTrue(row3.Count > 0, "Request 3 not in results!"); //======================================== // Mr. Clean to the rescue! //======================================== // Cleanup KeywordQuestion var cdc2 = new CAIRSDataContext(); IQueryable<KeywordQuestion> keyq1 = cdc2.KeywordQuestions.Where(kq => kq.RequestID == rid1); IQueryable<KeywordQuestion> keyq2 = cdc2.KeywordQuestions.Where(kq => kq.RequestID == rid2); IQueryable<KeywordQuestion> keyq3 = cdc2.KeywordQuestions.Where(kq => kq.RequestID == rid3); if (keyq1 == null || keyq2 == null || keyq3 == null) { Assert.Fail("KeywordQuestion can't be found for Teardown!"); } cdc2.KeywordQuestions.DeleteAllOnSubmit(keyq1); cdc2.KeywordQuestions.DeleteAllOnSubmit(keyq2); cdc2.KeywordQuestions.DeleteAllOnSubmit(keyq3); cdc2.SubmitChanges(); // Cleanup Keyword Keyword kwDel1 = cdc2.Keywords.FirstOrDefault(k => k.KeywordID == kw1.KeywordID); Keyword kwDel2 = cdc2.Keywords.FirstOrDefault(k => k.KeywordID == kw2.KeywordID); if (kwDel1 == null || kwDel2 == null) { Assert.Fail("KeywordQuestion can't be found for Teardown!"); } cdc2.Keywords.DeleteAllOnSubmit(new List<Keyword> {kwDel1, kwDel2}); cdc2.SubmitChanges(); // Cleanup QuestionResponse QuestionResponse qresp1 = cdc2.QuestionResponses.FirstOrDefault(qr => qr.RequestID == rid1); QuestionResponse qresp2 = cdc2.QuestionResponses.FirstOrDefault(qr => qr.RequestID == rid2); QuestionResponse qresp3 = cdc2.QuestionResponses.FirstOrDefault(qr => qr.RequestID == rid3); if (qresp1 == null || qresp2 == null || qresp3 == null) { Assert.Fail("QuestionResponse can't be found for Teardown!"); } cdc2.QuestionResponses.DeleteAllOnSubmit( new List<QuestionResponse> {qresp1, qresp2, qresp3}); cdc2.SubmitChanges(); // Cleanup Request Request req1 = cdc2.Requests.FirstOrDefault(r => r.RequestID == rid1); Request req2 = cdc2.Requests.FirstOrDefault(r => r.RequestID == rid2); Request req3 = cdc2.Requests.FirstOrDefault(r => r.RequestID == rid3); if (req1 == null || req2 == null || req3 == null) { Assert.Fail("Request can't be found for Teardown!"); } cdc2.Requests.DeleteAllOnSubmit(new List<Request> {req1, req2, req3}); cdc2.SubmitChanges(); }
public void TestFixtureSetUp() { _db = new CAIRSDataContext(); _rmc = new RequestManagementController(); var random = new Random(); _up = new UserProfile { UserName = "******" + random.Next(1, 100000000) }; _db.UserProfiles.InsertOnSubmit(_up); _db.SubmitChanges(); _rType = new RequestorType { Code = "TRMC" + random.Next(1, 100000), Value = "TestRequestManagementController" + random.Next(1, 100000000), Active = true }; _db.RequestorTypes.InsertOnSubmit(_rType); _db.SubmitChanges(); _region = new Region { Code = "TRMC" + random.Next(1, 100000), Value = "TestRequestManagementController" + random.Next(1, 100000000), Active = true }; _db.Regions.InsertOnSubmit(_region); _db.SubmitChanges(); _tGroup = new TumourGroup { Code = "TRMC" + random.Next(1, 100000), Value = "TestRequestManagementController" + random.Next(1, 100000000), Active = true }; _db.TumourGroups.InsertOnSubmit(_tGroup); _db.SubmitChanges(); _qType = new QuestionType { Code = "TRMC" + random.Next(1, 100000), Value = "TestRequestManagementController" + random.Next(1, 100000000), Active = true }; _db.QuestionTypes.InsertOnSubmit(_qType); _db.SubmitChanges(); }
public void TestViewRequestWorking() { // Add some Dependencies var rt = new RequestorType { Code = _random.Next(1000000) .ToString(CultureInfo.InvariantCulture), Value = "VRInt-" + _random.Next() .ToString(CultureInfo.InvariantCulture), Active = true }; _cdc.RequestorTypes.InsertOnSubmit(rt); var qt = new QuestionType { Code = _random.Next(1000000) .ToString(CultureInfo.InvariantCulture), Value = "VRInt-" + _random.Next() .ToString(CultureInfo.InvariantCulture), Active = true }; _cdc.QuestionTypes.InsertOnSubmit(qt); var tg = new TumourGroup { Code = _random.Next(1000000) .ToString(CultureInfo.InvariantCulture), Value = "VRInt-" + _random.Next() .ToString(CultureInfo.InvariantCulture), Active = true }; _cdc.TumourGroups.InsertOnSubmit(tg); var r = new Region { Code = _random.Next(1000000) .ToString(CultureInfo.InvariantCulture), Value = "VRInt-" + _random.Next() .ToString(CultureInfo.InvariantCulture), Active = true }; _cdc.Regions.InsertOnSubmit(r); var k = new Keyword { KeywordValue = "VRInt-" + _random.Next() .ToString(CultureInfo.InvariantCulture), Active = true }; _cdc.Keywords.InsertOnSubmit(k); // Submit our changes so far. _cdc.SubmitChanges(); // Create a test request in the DB var rc = new RequestContent { patientFName = "VRInt-" + _random.Next() .ToString(CultureInfo.InvariantCulture), patientLName = "VRInt-" + _random.Next() .ToString(CultureInfo.InvariantCulture), patientAgencyID = _random.Next() .ToString(CultureInfo.InvariantCulture), patientGender = Constants.Gender.Female, patientAge = 255, requestorTypeID = rt.RequestorTypeID, regionID = r.RegionID, requestorFirstName = "VRInt-" + _random.Next() .ToString( CultureInfo.InvariantCulture), requestorLastName = "VRInt-" + _random.Next() .ToString( CultureInfo.InvariantCulture), requestorEmail = _random.Next() .ToString(CultureInfo.InvariantCulture) + "@example.com", requestorPhoneNum = _random.Next() .ToString( CultureInfo.InvariantCulture), requestorPhoneExt = _random.Next() .ToString( CultureInfo.InvariantCulture) }; var refCont = new ReferenceContent { referenceType = Constants.ReferenceType.Text, referenceString = "VRInt-" + _random.Next() .ToString( CultureInfo.InvariantCulture) }; var qrc = new QuestionResponseContent { question = "VRInt-" + _random.Next() .ToString( CultureInfo.InvariantCulture), response = "VRInt-" + _random.Next() .ToString( CultureInfo.InvariantCulture), specialNotes = "VRInt-" + _random.Next() .ToString( CultureInfo.InvariantCulture), consequence = Constants.Consequence.Certain, severity = Constants.Severity.Major, keywords = new List<string> {k.KeywordValue}, referenceList = new List<ReferenceContent> {refCont}, timeSpent = 255, questionTypeID = qt.QuestionTypeID, tumourGroupID = tg.TumourGroupID }; rc.addQuestionResponse(qrc); var rmc = new RequestManagementController(); long rid = rmc.create(rc); var dmc = new DropdownManagementController(); // Attempt to go to the appropriate View Request Page Directly _driver.Navigate().GoToUrl(CommonTestingMethods.getURL()); _driver.Navigate() .GoToUrl(CommonTestingMethods.getURL() + "/Request/Details/" + rid.ToString(CultureInfo.InvariantCulture)); // Assert that we're not redirected StringAssert.Contains("/Request/Details", _driver.Url); // Go through fields and check values IWebElement element = _driver.FindElement(By.Id("status")); StringAssert.AreEqualIgnoringCase(rc.requestStatus.ToString(), element.Text); element = _driver.FindElement(By.Id("total-time-spent")); StringAssert.Contains(qrc.timeSpent.ToString(), element.Text); element = _driver.FindElement(By.Id("requestor-name")); StringAssert.Contains(rc.requestorFirstName, element.Text); StringAssert.Contains(rc.requestorLastName, element.Text); element = _driver.FindElement(By.Id("requestor-email")); StringAssert.AreEqualIgnoringCase(rc.requestorEmail, element.Text); element = _driver.FindElement(By.Id("requestor-phone")); StringAssert.Contains(rc.requestorPhoneNum, element.Text); StringAssert.Contains(rc.requestorPhoneExt, element.Text); element = _driver.FindElement(By.Id("caller-type")); StringAssert.Contains(rt.Code, element.Text); StringAssert.Contains(rt.Value, element.Text); element = _driver.FindElement(By.Id("region")); StringAssert.Contains(r.Code, element.Text); StringAssert.Contains(r.Value, element.Text); element = _driver.FindElement(By.Id("patient-name")); StringAssert.Contains(rc.patientFName, element.Text); StringAssert.Contains(rc.patientLName, element.Text); element = _driver.FindElement(By.Id("patient-gender")); StringAssert.AreEqualIgnoringCase(rc.patientGender.ToString(), element.Text); element = _driver.FindElement(By.Id("patient-id")); StringAssert.AreEqualIgnoringCase(rc.patientAgencyID, element.Text); element = _driver.FindElement(By.Id("patient-age")); StringAssert.AreEqualIgnoringCase(rc.patientAge.ToString(), element.Text); element = _driver.FindElement(By.ClassName("question")); StringAssert.AreEqualIgnoringCase(qrc.question, element.Text); element = _driver.FindElement(By.ClassName("response")); StringAssert.AreEqualIgnoringCase(qrc.response, element.Text); element = _driver.FindElement(By.ClassName("special-notes")); StringAssert.AreEqualIgnoringCase(qrc.specialNotes, element.Text); element = _driver.FindElement(By.ClassName("question-type")); StringAssert.Contains(qt.Code, element.Text); StringAssert.Contains(qt.Value, element.Text); element = _driver.FindElement(By.ClassName("tumour-group")); StringAssert.Contains(tg.Code, element.Text); StringAssert.Contains(tg.Value, element.Text); element = _driver.FindElement(By.ClassName("time-spent")); StringAssert.Contains(qrc.timeSpent.ToString(), element.Text); element = _driver.FindElement(By.ClassName("score")); StringAssert.AreEqualIgnoringCase( 1.ToString(CultureInfo.InvariantCulture), element.Text); element = _driver.FindElement(By.ClassName("impact-sev")); StringAssert.AreEqualIgnoringCase(qrc.severity.ToString(), element.Text); element = _driver.FindElement(By.ClassName("impact-cons")); StringAssert.AreEqualIgnoringCase(qrc.consequence.ToString(), element.Text); element = _driver.FindElement(By.ClassName("reference-string")); StringAssert.AreEqualIgnoringCase(refCont.referenceString, element.Text); // Cleanup var cdc2 = new CAIRSDataContext(); IQueryable<KeywordQuestion> kqs = cdc2.KeywordQuestions.Where(kq => kq.RequestID == rid); Assert.IsTrue(kqs.Any()); cdc2.KeywordQuestions.DeleteAllOnSubmit(kqs); IQueryable<AuditLog> als = cdc2.AuditLogs.Where(al => al.RequestID == rid); Assert.IsTrue(als.Any()); cdc2.AuditLogs.DeleteAllOnSubmit(als); IQueryable<QuestionResponse> qrs = cdc2.QuestionResponses.Where(dbQr => dbQr.RequestID == rid); Assert.IsTrue(qrs.Any()); cdc2.QuestionResponses.DeleteAllOnSubmit(qrs); IQueryable<Request> rs = cdc2.Requests.Where(rq => rq.RequestID == rid); Assert.IsTrue(rs.Any()); cdc2.Requests.DeleteAllOnSubmit(rs); IQueryable<Reference> refs = cdc2.References.Where(rf => rf.RequestID == rid); Assert.IsTrue(refs.Any()); cdc2.References.DeleteAllOnSubmit(refs); IQueryable<RequestorType> rqts = cdc2.RequestorTypes.Where( rqt => rqt.RequestorTypeID == rt.RequestorTypeID); Assert.IsTrue(rqts.Any()); cdc2.RequestorTypes.DeleteAllOnSubmit(rqts); IQueryable<QuestionType> qts = cdc2.QuestionTypes.Where( dbQt => dbQt.Value == qt.Value); Assert.IsTrue(qts.Any()); cdc2.QuestionTypes.DeleteAllOnSubmit(qts); IQueryable<TumourGroup> tgs = cdc2.TumourGroups.Where( dbTg => dbTg.TumourGroupID == tg.TumourGroupID); Assert.IsTrue(tgs.Any()); cdc2.TumourGroups.DeleteAllOnSubmit(tgs); IQueryable<Region> regions = cdc2.Regions.Where(dbRg => dbRg.RegionID == r.RegionID); Assert.IsTrue(regions.Any()); cdc2.Regions.DeleteAllOnSubmit(regions); IQueryable<Keyword> keywords = cdc2.Keywords.Where(kw => kw.KeywordID == k.KeywordID); Assert.IsTrue(keywords.Any()); cdc2.Keywords.DeleteAllOnSubmit(keywords); IQueryable<Request> rqs = cdc2.Requests.Where(dbRq => dbRq.RequestID == rid); Assert.IsTrue(rqs.Any()); cdc2.Requests.DeleteAllOnSubmit(rqs); cdc2.SubmitChanges(); }