public SimpleMembershipInitializer()
            {
                try {
                    using (var context = new CAIRSDataContext()) {
                        if (!context.DatabaseExists()) {
                            // Create the SimpleMembership database without
                            // Entity Framework migration schema
                            ((IObjectContextAdapter) context)
                                .ObjectContext
                                .CreateDatabase();
                        }
                    }
                    if (!WebMatrix.WebData.WebSecurity.Initialized) {
                        WebSecurity.InitializeDatabaseConnection(
                            "sasquatchConnectionString",
                            "UserProfile",
                            "UserId",
                            "UserName",
                            autoCreateTables: true);
                    }

                    // Initialize Roles
                    initializeRole(Constants.Roles.ADMINISTRATOR);
                    initializeRole(Constants.Roles.REPORT_GENERATOR);
                    initializeRole(Constants.Roles.REQUEST_EDITOR);
                    initializeRole(Constants.Roles.VIEWER);

                } catch (Exception ex) {
                    throw new InvalidOperationException(
                        "Database could not be initialized!", ex);
                }
            }
Exemple #2
0
        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();
        }
Exemple #3
0
        public void AddGroupTest()
        {
            var cdc = new CAIRSDataContext();
            UserGroup ug =
                cdc.UserGroups.FirstOrDefault(group => group.Active);

            if (ug == null) {
                Assert.Fail("No User Groups in system are Active!");
            }

            // Go to the Admin User Page
            _driver.Navigate().GoToUrl(CommonTestingMethods.getURL());
            _ctm.findAndClick(Constants.UIString.ItemIDs.ADMIN,
                              "/Admin/User/List");

            // Find and Click on Appropriate User
            _driver.FindElement(
                By.XPath("//td[contains(.,'" + CommonTestingMethods.USERNAME +
                         "')]")).Click();

            // Check the UG is
            IWebElement groupElement = _driver.FindElement(
                By.CssSelector("[for='userGroup-" + ug.GroupID + "']"));

            // Select the group if not already checked, else fail test
            if (!groupElement.GetAttribute("class").Contains("checked")) {
                groupElement.Click();
            } else {
                Assert.Fail("Group is already selected!");
            }

            // Submit the form
            _ctm.findAndClick(Constants.UIString.ItemIDs.SUBMIT_BUTTON,
                              "/Admin/User/List?success=True");

            // Click on the User Link in the header and verify the role is there
            _ctm.findAndClick("username", "/Account/Manage");
            IWebElement groups = _driver.FindElement(By.Id("user-groups"));

            StringAssert.Contains(ug.Value, groups.Text);

            // Clean up and remove the group
            _ctm.findAndClick(Constants.UIString.ItemIDs.ADMIN,
                              "/Admin/User/List");
            _driver.FindElement(
                By.XPath("//td[contains(.,'" + CommonTestingMethods.USERNAME +
                         "')]")).Click();
            _driver.FindElement(
                By.CssSelector("[for='userGroup-" + ug.GroupID + "']")).Click();
            _ctm.findAndClick(Constants.UIString.ItemIDs.SUBMIT_BUTTON,
                              "/Admin/User/List?success=True");
        }
        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 CreateDropDownAlreadyExists()
        {
            var cdc = new CAIRSDataContext();
            Region r =
                cdc.Regions.FirstOrDefault(region => true);
            var random = new Random();
            String codeVal =
                random.Next(1000000).ToString(CultureInfo.InvariantCulture);
            String valVal =
                random.Next(100000000).ToString(CultureInfo.InvariantCulture);

            if (r == null) {
                Assert.Fail("No Regions exist in the system!");
            }

            // 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(r.Code);
            _driver.FindElement(By.Id("value")).SendKeys(r.Value);

            // Try to Submit the Form + Verify that we're on the same page
            _ctm.findAndClick(Constants.UIString.ItemIDs.SUBMIT_BUTTON,
                              "/Admin/Dropdown/Create/Region");

            // Find the Code error and check the text
            IWebElement codeMsg =
                _driver.FindElement(By.CssSelector("[data-valmsg-for='code']"));
            IWebElement valMsg =
                _driver.FindElement(By.CssSelector("[data-valmsg-for='value']"));

            StringAssert.AreEqualIgnoringCase("That code is already in use!",
                                              codeMsg.Text);
            StringAssert.AreEqualIgnoringCase("That value is already in use!",
                                              valMsg.Text);

            // Replace the Code with a random value and recheck
            _driver.FindElement(By.Id("code")).Clear();
            _driver.FindElement(By.Id("code")).SendKeys(codeVal);
            _driver.FindElement(By.Id("value")).Clear();
            _driver.FindElement(By.Id("value")).SendKeys(r.Value);

            // Try to Submit the Form + Verify that we're on the same page
            _ctm.findAndClick(Constants.UIString.ItemIDs.SUBMIT_BUTTON,
                              "/Admin/Dropdown/Create/Region");

            valMsg =
                _driver.FindElement(By.CssSelector("[data-valmsg-for='value']"));
            StringAssert.AreEqualIgnoringCase("That value is already in use!",
                                              valMsg.Text);

            // Replace the Value with a random value and recheck
            _driver.FindElement(By.Id("code")).Clear();
            _driver.FindElement(By.Id("code")).SendKeys(r.Code);
            _driver.FindElement(By.Id("value")).Clear();
            _driver.FindElement(By.Id("value")).SendKeys(valVal);

            // Try to Submit the Form + Verify that we're on the same page
            _ctm.findAndClick(Constants.UIString.ItemIDs.SUBMIT_BUTTON,
                              "/Admin/Dropdown/Create/Region");

            valMsg =
                _driver.FindElement(By.CssSelector("[data-valmsg-for='code']"));
            StringAssert.AreEqualIgnoringCase("That code is already in use!",
                                              valMsg.Text);
        }
        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!");
        }
Exemple #7
0
        public ActionResult Index(
            Constants.URLStatus status = Constants.URLStatus.None)
        {
            var db = new CAIRSDataContext();
            var keywords = new Dictionary<long, List<string>>();

            if (!User.IsInRole(Constants.Roles.VIEWER)) {
                ViewBag.Requests = null;
                return View();
            }

            // Select all from Requests
            IQueryable<Request> requests;

            // Create request list based on roles
            if (User.IsInRole(Constants.Roles.ADMINISTRATOR)) {
                requests = db.Requests.Select(r => r);
            } else if (User.IsInRole(Constants.Roles.REQUEST_EDITOR)) {
                requests = db.Requests.Select(r => r).Where(
                    r =>
                    (Constants.RequestStatus) r.RequestStatus !=
                    Constants.RequestStatus.Invalid).Where(
                        r => !db.RequestLocks
                                .Any(rl => rl.RequestID == r.RequestID &&
                                           rl.UserProfile.UserName !=
                                           User.Identity.Name));
            } else {
                requests = db.Requests.Select(r => r).Where(
                    r =>
                    (Constants.RequestStatus) r.RequestStatus ==
                    Constants.RequestStatus.Completed).Where(
                        r => !db.RequestLocks
                                .Any(rl => rl.RequestID == r.RequestID &&
                                           rl.UserProfile.UserName !=
                                           User.Identity.Name));
            }

            requests = requests.OrderBy(r => r.RequestStatus)
                               .ThenByDescending(r => r.TimeOpened).Take(10);

            // Set the requests to null if there isn't anything on it,
            // as the view doesn't seem to have Any() available.
            if (!requests.Any()) {
                requests = null;
            }

            // Grab keywords for the requests
            if (requests != null) {
                foreach (Request rq in requests) {
                    List<string> kw =
                        (from kws in db.Keywords
                         join kqs in db.KeywordQuestions on kws.KeywordID equals
                             kqs.KeywordID
                         where kqs.RequestID == rq.RequestID
                         select kws.KeywordValue).Distinct()
                                                 .ToList();
                    keywords.Add(rq.RequestID, kw);
                }
            }

            ViewBag.Requests = requests;
            ViewBag.Keywords = keywords;
            if (status == Constants.URLStatus.Expired) {
                ViewBag.Status =
                    "Your session has expired due to inactivity. All unsaved changes have been lost.";
                ViewBag.StatusColor = "danger";
            } else if (status == Constants.URLStatus.Unlocked) {
                ViewBag.Status =
                    "The request has now been unlocked and is available for editing by all users.";
                ViewBag.StatusColor = "success";
            } else if (status == Constants.URLStatus.Deleted) {
                ViewBag.Status =
                    "The request has been marked as invalid and cannot be seen by non-Administrators.";
                ViewBag.StatusColor = "success";
            } else if (status == Constants.URLStatus.AccessingLocked) {
                ViewBag.Status =
                    "The request is locked and cannot be edited.";
                ViewBag.StatusColor = "danger";
            } else if (status == Constants.URLStatus.NotLockedToYou) {
                ViewBag.Status =
                    "The request is not locked to you and cannot be edited.";
                ViewBag.StatusColor = "danger";
            } else if (status == Constants.URLStatus.SuccessfulEdit) {
                ViewBag.Status =
                    "The request has been successfully edited.";
                ViewBag.StatusColor = "success";
            } else if (status == Constants.URLStatus.NoRequestEditorRole) {
                ViewBag.Status =
                    "You no longer have permissions to create or edit requests.";
                ViewBag.StatusColor = "danger";
            } else if (status == Constants.URLStatus.SuccessfulCreate) {
                ViewBag.Status =
                    "The request has been successfully created.";
                ViewBag.StatusColor = "success";
            } else if (status == Constants.URLStatus.EditingInvalid) {
                ViewBag.Status =
                    "The request is marked as invalid and cannot be edited.";
                ViewBag.StatusColor = "danger";
            }

            return View();
        }
        /// <summary>
        ///     Ability to Export a locked Request as a DOCX
        /// </summary>
        /// <param name="id">The Request ID to Export</param>
        /// <returns>A DOCX file.</returns>
        /// <request type="GET">/Request/Export</request>
        public ActionResult Export(long id)
        {
            var wec = new WordExportController();
            var db = new CAIRSDataContext();
            Request request = db.Requests.FirstOrDefault(r => r.RequestID == id);

            var markDate = new DateTime(2010, 01, 01, 00, 00, 00, 00);
            TimeSpan dateStamp = DateTime.Now.Subtract(markDate);
            string filePath =
                Server.MapPath(Constants.Export.REPORT_TEMP_PATH +
                               dateStamp.TotalSeconds + ".docx");
            string templatePath =
                Server.MapPath(Constants.Export.REPORT_TEMPLATE_PATH);

            IEnumerable<string> output = wec.requestToStrings(request);
            wec.generateDocument(output, templatePath, filePath, id);

            // add AuditLog entry for exporting
            var upc = new UserManagementController();
            var almc = new AuditLogManagementController();
            almc.addEntry(id, upc.getUserProfile(User.Identity.Name).UserId,
                          Constants.AuditType.RequestExport);

            return View("Details", new RequestContent(request));
        }
        public ActionResult Details(long id)
        {
            var rmc = new RequestManagementController();
            var rlc = new RequestLockManagementController();
            var upc = new UserManagementController();
            var db = new CAIRSDataContext();
            int timeSpent = 0;

            // Set up the Request Object
            RequestContent request = rmc.getRequestDetails(id);
            if (request == null) {
                ViewBag.Title = Constants.UIString.TitleText.VIEW_REQUEST
                                + " - "
                                + Constants.UIString.TitleText.ERROR;
                ViewBag.Error =
                    "The Request ID provided does not exist in the database.";

                return View((object) null);
            }

            ViewBag.Title = Constants.UIString.TitleText.VIEW_REQUEST
                            + " - "
                            + Constants.UIString.TitleText.REQUEST_NUM
                            + request.requestID;

            // Show error if not editor/administrator and request isn't complete
            if (!User.IsInRole(Constants.Roles.REQUEST_EDITOR)
                && !User.IsInRole(Constants.Roles.ADMINISTRATOR)
                && request.requestStatus != Constants.RequestStatus.Completed) {
                ViewBag.Title = Constants.UIString.TitleText.VIEW_REQUEST
                                + " - "
                                + Constants.UIString.TitleText.ERROR;
                ViewBag.Error =
                    "You do not have the necessary permissions to view this request.";

                return View((object) null);
            }

            // Show error if not administrator and request is invalid (deleted)
            if (!User.IsInRole(Constants.Roles.ADMINISTRATOR)
                && request.requestStatus == Constants.RequestStatus.Invalid) {
                ViewBag.Title = Constants.UIString.TitleText.VIEW_REQUEST
                                + " - "
                                + Constants.UIString.TitleText.ERROR;
                ViewBag.Error =
                    "You do not have the necessary permissions to view this request.";

                return View((object) null);
            }

            // Show error if you can't view due to locked status
            if (rlc.isLocked(id) &&
                !User.IsInRole(Constants.Roles.ADMINISTRATOR)) {
                // Check if it's not locked to you
                if (!User.IsInRole(Constants.Roles.REQUEST_EDITOR) ||
                    rlc.getRequestLock(id).UserID !=
                    upc.getUserProfile(User.Identity.Name).UserId) {
                    request = null;
                    ViewBag.Title = Constants.UIString.TitleText.VIEW_REQUEST
                                    + " - "
                                    + Constants.UIString.TitleText.ERROR;
                    ViewBag.Error =
                        "This request has been locked to another person and cannot be viewed until unlocked.";

                    return View((object) null);
                }
            }

            // Set up Time Spent (Question-Dependent)
            foreach (QuestionResponseContent qr in request.questionResponseList) {
                timeSpent += qr.timeSpent.GetValueOrDefault(0);
            }

            ViewBag.TimeSpent = timeSpent;
            ViewBag.DataContext = new CAIRSDataContext();

            // Created By
            AuditLog auditLog = (from al in db.AuditLogs
                                 where
                                     (int) al.AuditType ==
                                     (int) Constants.AuditType.RequestCreation &&
                                     al.RequestID == request.requestID
                                 select al).FirstOrDefault();
            if (auditLog != null && auditLog.UserProfile != null) {
                ViewBag.CreatedBy = auditLog.UserProfile.UserFullName;
            } else {
                ViewBag.CreatedBy = "";
            }

            // Closed By
            auditLog = (from al in db.AuditLogs
                        where
                            (int) al.AuditType ==
                            (int) Constants.AuditType.RequestCompletion &&
                            al.RequestID == request.requestID
                        select al).FirstOrDefault();
            if (auditLog != null && auditLog.UserProfile != null) {
                ViewBag.CompletedBy = auditLog.UserProfile.UserFullName;
            } else {
                ViewBag.CompletedBy = "";
            }

            // add AuditLog entry for viewing
            var almc = new AuditLogManagementController();
            almc.addEntry(id, upc.getUserProfile(User.Identity.Name).UserId,
                          Constants.AuditType.RequestView);

            ViewBag.IsLocked = rlc.isLocked(id);

            if (ViewBag.IsLocked) {
                ViewBag.IsLockedToMe = rlc.getRequestLock(id).UserID ==
                                       upc.getUserProfile(User.Identity.Name)
                                          .UserId;
            } else {
                ViewBag.IsLockedToMe = false;
            }

            return View(request);
        }
Exemple #10
0
        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();
        }
Exemple #11
0
        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();
        }
Exemple #12
0
        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();
        }
Exemple #13
0
        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();
        }
Exemple #15
0
        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();
        }