コード例 #1
0
ファイル: TestDashboard.cs プロジェクト: vladzaharia/cairs
        public void TestDashboardNoRequestEditor()
        {
            // Create a test request in the DB
            var rc1 = new RequestContent {
                patientFName = "DInt-" +
                               _random.Next()
                                      .ToString(CultureInfo.InvariantCulture),
                requestStatus = Constants.RequestStatus.Completed,
                timeOpened = DateTime.Now
            };
            var rc2 = new RequestContent {
                patientFName = "DInt-" +
                               _random.Next()
                                      .ToString(CultureInfo.InvariantCulture),
                requestStatus = Constants.RequestStatus.Open,
                timeOpened = DateTime.Now
            };
            var rmc = new RequestManagementController();
            long rid1 = rmc.create(rc1);
            long rid2 = rmc.create(rc2);

            _ctm.removeRole(Constants.Roles.REQUEST_EDITOR);
            _ctm.removeRole(Constants.Roles.ADMINISTRATOR);

            // Go to the Dashboard
            _driver.Navigate().GoToUrl(CommonTestingMethods.getURL());

            ReadOnlyCollection<IWebElement> elements =
                _driver.FindElements(By.CssSelector("[data-id='" + rid1 + "']"));
            Assert.Greater(elements.Count, 0);

            elements =
                _driver.FindElements(By.CssSelector("[data-id='" + rid2 + "']"));
            Assert.AreEqual(0, elements.Count);

            elements = _driver.FindElements(By.ClassName("add-button"));
            Assert.AreEqual(0, elements.Count);

            // Add the roles back
            _ctm.addRole(Constants.Roles.ADMINISTRATOR);
            _ctm.addRole(Constants.Roles.REQUEST_EDITOR);

            Request rq1 = _cdc.Requests.FirstOrDefault(r => r.RequestID == rid1);
            Request rq2 = _cdc.Requests.FirstOrDefault(r => r.RequestID == rid2);
            if (rq1 == null || rq2 == null) {
                Assert.Fail("Request is null");
            }
            _cdc.Requests.DeleteOnSubmit(rq1);
            _cdc.Requests.DeleteOnSubmit(rq2);
            _cdc.SubmitChanges();
        }
コード例 #2
0
        public void SetUp()
        {
            long randomRequestInt = _random.Next(1, 100000000);
            long randomUserInt = _random.Next(1, 100000000);
            var rmc = new RequestManagementController();

            // Create new Request Directly in DB
            rmc.create(new RequestContent {
                patientLName =
                    "TALM" +
                    randomRequestInt.ToString(CultureInfo.InvariantCulture)
            });

            // Create new UserProfile Directly in DB
            _dc.UserProfiles.InsertOnSubmit(new UserProfile {
                UserName =
                    "******" +
                    randomUserInt.ToString(CultureInfo.InvariantCulture)
            });

            _dc.SubmitChanges();

            rq =
                _dc.Requests.FirstOrDefault(
                    request =>
                    request.PatientLName ==
                    ("TALM" +
                     randomRequestInt.ToString(CultureInfo.InvariantCulture)));
            up =
                _dc.UserProfiles.FirstOrDefault(
                    userProfile =>
                    userProfile.UserName ==
                    ("TALM" +
                     randomUserInt.ToString(CultureInfo.InvariantCulture)));
        }
コード例 #3
0
ファイル: TestViewRequest.cs プロジェクト: vladzaharia/cairs
        public void TestViewRequestInvalid()
        {
            // Create a test request in the DB
            var rc = new RequestContent {
                patientFName = "VRInt-" +
                               _random.Next()
                                      .ToString(CultureInfo.InvariantCulture),
                requestStatus = Constants.RequestStatus.Invalid
            };
            var rmc = new RequestManagementController();
            long rid = rmc.create(rc);

            // Remove the Viewer Role from the User
            _ctm.removeRole(Constants.Roles.ADMINISTRATOR);

            // 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 redirected to the not authorized page
            StringAssert.Contains("/Request/Details", _driver.Url);
            _driver.FindElement(By.Id("error-header"));
            IWebElement msg = _driver.FindElement(By.Id("error-message"));
            StringAssert.AreEqualIgnoringCase(
                "You do not have the necessary permissions to view this request.",
                msg.Text);

            // Cleanup
            Request rq = _cdc.Requests.FirstOrDefault(r => r.RequestID == rid);
            if (rq == null) {
                Assert.Fail("Request is null");
            }

            _cdc.Requests.DeleteOnSubmit(rq);
            _cdc.SubmitChanges();

            _ctm.addRole(Constants.Roles.ADMINISTRATOR);
        }
コード例 #4
0
        public ActionResult Create(RequestContent reqContent)
        {
            var rmc = new RequestManagementController();

            bool valid = ModelState.IsValid;

            if (reqContent.parentRequestID != null &&
                !rmc.requestExists((long) reqContent.parentRequestID)) {
                ModelState.AddModelError("NonexistentParentRequest",
                                         "Parent Request ID must correspond to an existing request.");
                valid = false;
            }

            if (Request.Form["mark_as_complete"] != null) {
                foreach (
                    QuestionResponseContent qrContent in
                        reqContent.questionResponseList) {
                    if (String.IsNullOrEmpty(qrContent.question) ||
                        removeNewLinesAndTabs(qrContent.question).Equals("<br />") ||
                        String.IsNullOrEmpty(qrContent.response) ||
                        removeNewLinesAndTabs(qrContent.response).Equals("<br />") ||
                        qrContent.questionTypeID == null ||
                        qrContent.tumourGroupID == null ||
                        qrContent.timeSpent == null ||
                        qrContent.severity == null ||
                        qrContent.consequence == null ||
                        qrContent.keywords.Count < 1) {
                        ModelState.AddModelError("IncompleteQuestion",
                                                 "Questions must be completed before marking request as complete.");
                        valid = false;
                        break;
                    }

                    if (qrContent.keywords.Any(keyword => keyword.Length > 128)) {
                        ModelState.AddModelError("KeywordTooLong",
                                                 "Keywords must be less than 128 characters.");
                        valid = false;
                    }

                    if (qrContent.referenceList.Any(refContent => String.IsNullOrEmpty(refContent.referenceString))) {
                        ModelState.AddModelError("IncompleteReference",
                                                 "References must be completed before marking request as complete.");
                        valid = false;
                    }
                }

                reqContent.timeClosed = DateTime.Now;
                reqContent.requestStatus = Constants.RequestStatus.Completed;
            }

            // Encode HTML in question responses
            // Replace null references with empty string
            foreach (
                QuestionResponseContent qrContent in
                    reqContent.questionResponseList) {
                if (!String.IsNullOrEmpty(qrContent.question)) {
                    qrContent.question = HttpUtility.HtmlEncode(
                        removeNewLinesAndTabs(qrContent.question))
                                                    .Replace("&#39;", "'");
                }
                if (!String.IsNullOrEmpty(qrContent.response)) {
                    qrContent.response = HttpUtility.HtmlEncode(
                        removeNewLinesAndTabs(qrContent.response))
                                                    .Replace("&#39;", "'");
                }
                if (!String.IsNullOrEmpty(qrContent.specialNotes)) {
                    qrContent.specialNotes = HttpUtility.HtmlEncode(
                        removeNewLinesAndTabs(qrContent.specialNotes))
                                                        .Replace("&#39;", "'");
                }

                foreach (
                    ReferenceContent refContent in qrContent.referenceList) {

                    refContent.referenceString =
                        refContent.referenceString == null ?
                            "" :
                            refContent.referenceString.Replace("\\", "\\\\");
                }
            }

            if (!valid) {
                var dc = new DropdownManagementController();

                ViewBag.RequestorTypes = new SelectList(
                    dc.getEntries(Constants.DropdownTable.RequestorType),
                    "id", "text");
                ViewBag.Regions = new SelectList(
                    dc.getEntries(Constants.DropdownTable.Region),
                    "id", "text");

                ViewBag.GenderOptions = new SelectList(Constants.genderOptions);

                return View(reqContent);
            }

            long reqId = rmc.create(reqContent);

            var uc = new UserManagementController();
            UserProfile up = uc.getUserProfile(User.Identity.Name);
            var almc = new AuditLogManagementController();
            almc.addEntry(reqId, up.UserId,
                          Constants.AuditType.RequestCreation,
                          reqContent.timeOpened);

            if (reqContent.requestStatus == Constants.RequestStatus.Completed &&
                reqContent.timeClosed != null) {
                almc.addEntry(reqId, up.UserId,
                              Constants.AuditType.RequestCompletion,
                              (DateTime) reqContent.timeClosed);
            }

            if (Roles.IsUserInRole(Constants.Roles.VIEWER)) {
                return RedirectToAction("Details", "Request",
                                        new {
                                            id = reqId
                                        });
            }

            return RedirectToAction("Index", "Home",
                                    new {
                                        status =
                                        Constants.URLStatus.SuccessfulCreate
                                    });
        }
コード例 #5
0
ファイル: TestSearch.cs プロジェクト: vladzaharia/cairs
        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();
        }
コード例 #6
0
ファイル: TestSearch.cs プロジェクト: vladzaharia/cairs
        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();
        }
コード例 #7
0
ファイル: TestSearch.cs プロジェクト: vladzaharia/cairs
        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();
        }
コード例 #8
0
ファイル: TestSearch.cs プロジェクト: vladzaharia/cairs
        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();
        }
コード例 #9
0
ファイル: TestViewRequest.cs プロジェクト: vladzaharia/cairs
        public void TestViewRequestLockedToAnother()
        {
            // Create a test request in the DB
            var rc = new RequestContent {
                patientFName = "VRInt-" +
                               _random.Next()
                                      .ToString(CultureInfo.InvariantCulture)
            };
            var rmc = new RequestManagementController();
            long rid = rmc.create(rc);

            // Create the User
            var up = new UserProfile {
                UserName = "******" +
                           _random.Next()
                                  .ToString(CultureInfo.InvariantCulture)
            };
            _cdc.UserProfiles.InsertOnSubmit(up);
            _cdc.SubmitChanges();

            // Create the Lock
            var rlmc = new RequestLockManagementController();
            rlmc.addLock(rid, up.UserId);

            // Remove the Viewer Role from the User
            _ctm.removeRole(Constants.Roles.ADMINISTRATOR);

            // 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));
            _driver.FindElement(By.Id("error-header"));
            IWebElement msg = _driver.FindElement(By.Id("error-message"));
            StringAssert.AreEqualIgnoringCase(
                "This request has been locked to another person and cannot be viewed until unlocked.",
                msg.Text);

            // Assert that we're redirected to the not authorized page
            StringAssert.Contains("/Request/Details", _driver.Url);

            // Cleanup
            rlmc.removeLock(rid);
            _cdc.UserProfiles.DeleteOnSubmit(up);
            Request rq = _cdc.Requests.FirstOrDefault(r => r.RequestID == rid);
            if (rq == null) {
                Assert.Fail("Request is null");
            }
            _cdc.Requests.DeleteOnSubmit(rq);
            _cdc.SubmitChanges();

            _ctm.addRole(Constants.Roles.ADMINISTRATOR);
        }
コード例 #10
0
ファイル: TestViewRequest.cs プロジェクト: vladzaharia/cairs
        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();
        }
コード例 #11
0
ファイル: TestViewRequest.cs プロジェクト: vladzaharia/cairs
        public void TestViewRequestNotViewer()
        {
            // Create a test request in the DB
            var rc = new RequestContent {
                patientFName = "VRInt-" +
                               _random.Next()
                                      .ToString(CultureInfo.InvariantCulture)
            };
            var rmc = new RequestManagementController();
            long rid = rmc.create(rc);

            // Remove the Viewer Role from the User
            _ctm.removeRole(Constants.Roles.VIEWER);

            // 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 redirected to the not authorized page
            StringAssert.Contains("/Account/Auth", _driver.Url);

            // Cleanup
            Request rq = _cdc.Requests.FirstOrDefault(r => r.RequestID == rid);
            if (rq == null) {
                Assert.Fail("Request is null");
            }

            _cdc.Requests.DeleteOnSubmit(rq);
            _cdc.SubmitChanges();

            _ctm.addRole(Constants.Roles.VIEWER);
        }
コード例 #12
0
        public void TestCreateRequestValid()
        {
            // Create a test request in the DB
            var rc1 = new RequestContent {
                patientFName = "DInt-" +
                               _random.Next()
                                      .ToString(CultureInfo.InvariantCulture),
                requestStatus = Constants.RequestStatus.Open,
                timeOpened = DateTime.Now
            };
            var rmc = new RequestManagementController();
            long rid1 = rmc.create(rc1);

            // Attempt to go to the Create Request Page
            _driver.Navigate().GoToUrl(CommonTestingMethods.getURL());
            _ctm.findAndClick(Constants.UIString.ItemIDs.CREATE_REQUEST,
                              "/Request/Create");

            String rFName = "CrInt-" + Membership.GeneratePassword(10, 0);
            String rLName = "CrInt-" + Membership.GeneratePassword(10, 0);
            String rEmail = "*****@*****.**";
            String rPhone = "CrInt-" + Membership.GeneratePassword(10, 0);
            String rExt = "CrInt-" + Membership.GeneratePassword(10, 0);
            String pFName = "CrInt-" + Membership.GeneratePassword(10, 0);
            String pLName = "CrInt-" + Membership.GeneratePassword(10, 0);
            String pId = "CrInt-" + Membership.GeneratePassword(10, 0);
            String pAge = "123";
            String timeSpent = "1234";
            String parentRequest = rid1.ToString();
            String reference = "CrInt-" + Membership.GeneratePassword(10, 0);

            _driver.FindElement(By.Id("requestorFirstName"))
                   .SendKeys(rFName);
            _driver.FindElement(By.Id("requestorLastName"))
                   .SendKeys(rLName);
            _driver.FindElement(By.Id("requestorEmail"))
                   .SendKeys(rEmail);
            _driver.FindElement(By.Id("requestorPhoneNum"))
                   .SendKeys(rPhone);
            _driver.FindElement(By.Id("requestorPhoneExt"))
                   .SendKeys(rExt);
            _driver.FindElement(By.Id("patientFName"))
                   .SendKeys(pFName);
            _driver.FindElement(By.Id("patientLName"))
                   .SendKeys(pLName);
            _driver.FindElement(By.Id("patientAgencyID"))
                   .SendKeys(pId);
            _driver.FindElement(By.Id("patientAge"))
                   .SendKeys(pAge);
            _driver.FindElement(By.ClassName("time-spent"))
                   .SendKeys(timeSpent);
            _driver.FindElement(By.Id("parentRequestID"))
                   .SendKeys(parentRequest);
            _driver.FindElement(By.ClassName("reference"))
                   .SendKeys(reference);

            // Submit the Form
            _driver.FindElement(By.Id("save_draft")).Click();
            StringAssert.Contains("/Request/Details", _driver.Url);

            Request newReq =
                _cdc.Requests.OrderByDescending(r => r.RequestID).FirstOrDefault(r => true);
            if (newReq == null) {
                Assert.Fail("Can't find newly-created Request.");
            }

            StringAssert.AreEqualIgnoringCase(rFName, newReq.RequestorFName);
            StringAssert.AreEqualIgnoringCase(rLName, newReq.RequestorLName);
            StringAssert.AreEqualIgnoringCase(rEmail, newReq.RequestorEmail);
            StringAssert.AreEqualIgnoringCase(rPhone, newReq.RequestorPhone);
            StringAssert.AreEqualIgnoringCase(rExt, newReq.RequestorPhoneExt);
            StringAssert.AreEqualIgnoringCase(pFName, newReq.PatientFName);
            StringAssert.AreEqualIgnoringCase(pLName, newReq.PatientLName);
            StringAssert.AreEqualIgnoringCase(pId, newReq.PatientAgencyID);
            StringAssert.AreEqualIgnoringCase(pAge, newReq.PatientAge.ToString());
            StringAssert.AreEqualIgnoringCase(parentRequest, newReq.ParentRequestID.ToString());
            StringAssert.AreEqualIgnoringCase(timeSpent, newReq.QuestionResponses.First().TimeSpent.ToString());
            StringAssert.AreEqualIgnoringCase(reference, newReq.QuestionResponses.First().References.First().ReferenceString);

            // Cleanup Time
            IQueryable<AuditLog> aus =
                _cdc.AuditLogs.Where(a => a.RequestID == newReq.RequestID);
            _cdc.AuditLogs.DeleteAllOnSubmit(aus);

            Reference rf =
                _cdc.References.FirstOrDefault(r => r.RequestID == newReq.RequestID);
            if (rf == null) {
                Assert.Fail("Can't find Reference for Cleanup");
            }
            _cdc.References.DeleteOnSubmit(rf);

            QuestionResponse qr =
                _cdc.QuestionResponses.FirstOrDefault(qr2 => qr2.RequestID == newReq.RequestID);
            if (qr == null) {
                Assert.Fail("Can't find QuestionResponse for Cleanup");
            }

            Request req1 = _cdc.Requests.FirstOrDefault(r => r.RequestID == rid1);
            if (req1 == null) {
                Assert.Fail("Can't find Request for Cleanup");
            }

            _cdc.QuestionResponses.DeleteOnSubmit(qr);
            _cdc.Requests.DeleteOnSubmit(newReq);
            _cdc.Requests.DeleteOnSubmit(req1);
            _cdc.SubmitChanges();
        }
コード例 #13
0
        public void setUp()
        {
            Random random = new Random();
            _randomRequestInt = random.Next(1, 100000000);
            _randomRequestInt2 = random.Next(1, 10000000);
            _randomRequestInt3 = random.Next(1, 100000000);
            _randomKeyword = new Keyword
            {
                KeywordID = random.Next(1,100000000),
                KeywordValue = ("TSMC" + random.Next(1, 100000000).ToString(CultureInfo.InvariantCulture))
            };
            _randomKeyword2 = new Keyword
            {
                KeywordID = random.Next(1,100000000),
                KeywordValue = ("TSMC" + random.Next(1, 100000000).ToString(CultureInfo.InvariantCulture))
            };
            _randomKeyword3 = new Keyword
            {
                 KeywordValue = ("TSMC" + random.Next(1, 100000000).ToString(CultureInfo.InvariantCulture))
            };
            _randomKeyword4 = new Keyword
            {
                KeywordID = random.Next(1,100000000),
                KeywordValue = ("TSMC" + random.Next(1, 100000000).ToString(CultureInfo.InvariantCulture))
            };

            QuestionResponseContent testQrc = new QuestionResponseContent();
            testQrc.requestID = _randomRequestInt;
            testQrc.keywords.Add(_randomKeyword.KeywordValue);
            testQrc.keywords.Add(_randomKeyword2.KeywordValue);
            testQrc.severity = Constants.Severity.Minor;
            testQrc.consequence = Constants.Consequence.Certain;

            QuestionResponseContent testQrc2 = new QuestionResponseContent();
            testQrc2.requestID = _randomRequestInt2;
            testQrc2.keywords.Add(_randomKeyword3.KeywordValue);
            testQrc2.severity = Constants.Severity.Moderate;
            testQrc2.consequence = Constants.Consequence.Possible;

            QuestionResponseContent testQrc3 = new QuestionResponseContent();
            testQrc2.requestID = _randomRequestInt3;
            testQrc2.keywords.Add(_randomKeyword4.KeywordValue);
            testQrc.severity = Constants.Severity.Major;
            testQrc3.consequence = Constants.Consequence.Possible;

            RequestManagementController rmc = new RequestManagementController();
            RequestManagementController rmc2 = new RequestManagementController();
            RequestManagementController rmc3 = new RequestManagementController();

            rmc.create(new RequestContent
            {
                patientFName = "TSMC Test",
                questionResponseList = { testQrc, testQrc3 },
                requestStatus = Constants.RequestStatus.Open,
                requestorFirstName = "10",
                requestorLastName = "100",

            });

            rmc3.create(new RequestContent
            {
                patientFName = "TSMC Test2",
                requestorFirstName = "20",
                requestorLastName = "100",
                questionResponseList = { testQrc2, testQrc },
                requestStatus = Constants.RequestStatus.Open

            });

            rmc2.create(new RequestContent
            {
                patientFName = "TSMC Test3",
                requestorFirstName = "30",
                requestorLastName = "100",
                questionResponseList = { testQrc3 },
                requestStatus = Constants.RequestStatus.Open

            });

            _rq = _dc.Requests.FirstOrDefault(
                request =>
                request.PatientFName == "TSMC Test");

            _rq2 = _dc.Requests.FirstOrDefault(
                request =>
                request.PatientFName == "TSMC Test2");

            _rq3 = _dc.Requests.FirstOrDefault(
                request =>
                request.PatientFName == "TSMC Test3");
        }
コード例 #14
0
        public void Test_createReportForRequestWithMultipleRequests()
        {
            // Create an extra test request to test list with multiple
            long randomRequestInt = _random.Next(1, 100000000);
            var rmc = new RequestManagementController();

            // Create new Request Directly in DB
            rmc.create(new RequestContent {
                patientLName =
                    "TALM" +
                    randomRequestInt.ToString(CultureInfo.InvariantCulture)
            });

            _dc.SubmitChanges();

            rq2 = _dc.Requests.FirstOrDefault(
                request =>
                request.PatientLName ==
                ("TALM" +
                 randomRequestInt.ToString(CultureInfo.InvariantCulture)));

            var almc = new AuditLogManagementController();

            // create AuditLogs for rq
            _dc.AuditLogs.InsertOnSubmit(new AuditLog {
                RequestID = rq.RequestID,
                UserID = up.UserId,
                AuditType = (byte) Constants.AuditType.RequestView,
                AuditDate = DateTime.Now
            });
            _dc.SubmitChanges();

            // create AuditLogs for rq2
            _dc.AuditLogs.InsertOnSubmit(new AuditLog {
                RequestID = rq2.RequestID,
                UserID = up.UserId,
                AuditType = (byte) Constants.AuditType.RequestView,
                AuditDate = DateTime.Now
            });
            _dc.SubmitChanges();

            var auditRequests = new List<Request> {
                rq,
                rq2
            };

            bool returnValue = almc.createReportForRequest(auditRequests);

            // delete both AuditLogs created
            AuditLog alCreated =
                _dc.AuditLogs.FirstOrDefault(r => r.RequestID == rq.RequestID);
            _dc.AuditLogs.DeleteOnSubmit(alCreated);
            AuditLog alCreated2 =
                _dc.AuditLogs.FirstOrDefault(r => r.RequestID == rq2.RequestID);
            _dc.AuditLogs.DeleteOnSubmit(alCreated2);
            _dc.SubmitChanges();
        }