Beispiel #1
0
        public static IQueryable<RequestorType> getSampleCallerTypes()
        {
            var requestor0 = new RequestorType {
                RequestorTypeID = 0,
                Code = "ADMIN",
                Value = "Administrator",
                Active = true
            };

            var requestor1 = new RequestorType {
                RequestorTypeID = 1,
                Code = "DRUG CO",
                Value = "Drug Company",
                Active = false
            };

            var requestor2 = new RequestorType {
                RequestorTypeID = 2,
                Code = "FAMILY",
                Value = "Family Members",
                Active = false
            };

            var sampleCallers = new List<RequestorType> {
                requestor0,
                requestor1,
                requestor2
            };

            return sampleCallers.AsQueryable();
        }
        /// <summary>
        ///     Add a new entry to one of the dropdown tables in the database.
        /// </summary>
        /// <param name="table">Table to add a new entry to.</param>
        /// <param name="entry">
        ///     DropdownEntry containing the value and code,
        ///     if exists.
        /// </param>
        public void addEntry(Constants.DropdownTable table,
                             DropdownEntry entry)
        {
            switch (table) {
                case Constants.DropdownTable.Keyword:
                    var kw = new Keyword {
                        KeywordValue = entry.value
                    };

                    _db.Keywords.InsertOnSubmit(kw);
                    break;
                case Constants.DropdownTable.QuestionType:
                    var qType = new QuestionType {
                        Code = entry.code,
                        Value = entry.value
                    };

                    _db.QuestionTypes.InsertOnSubmit(qType);

                    break;
                case Constants.DropdownTable.Region:
                    var region = new Region {
                        Code = entry.code,
                        Value = entry.value
                    };

                    _db.Regions.InsertOnSubmit(region);

                    break;
                case Constants.DropdownTable.RequestorType:
                    var rType = new RequestorType {
                        Code = entry.code,
                        Value = entry.value
                    };

                    _db.RequestorTypes.InsertOnSubmit(rType);

                    break;
                case Constants.DropdownTable.TumourGroup:
                    var tGroup = new TumourGroup {
                        Code = entry.code,
                        Value = entry.value
                    };

                    _db.TumourGroups.InsertOnSubmit(tGroup);

                    break;
                case Constants.DropdownTable.UserGroup:
                    var uGroup = new UserGroup {
                        Code = entry.code,
                        Value = entry.value
                    };

                    _db.UserGroups.InsertOnSubmit(uGroup);

                    break;
            }

            _db.SubmitChanges();
        }
Beispiel #3
0
 private void Reset()
 {
     RequestingHost_Renamed     = null;
     RequestingSite_Renamed     = null;
     RequestingPort_Renamed     = -1;
     RequestingProtocol_Renamed = null;
     RequestingPrompt_Renamed   = null;
     RequestingScheme_Renamed   = null;
     RequestingURL_Renamed      = null;
     RequestingAuthType         = RequestorType.SERVER;
 }
Beispiel #4
0
        /// <summary>
        /// Ask the authenticator that has been registered with the system
        /// for a password.
        /// <para>
        /// First, if there is a security manager, its {@code checkPermission}
        /// method is called with a
        /// {@code NetPermission("requestPasswordAuthentication")} permission.
        /// This may result in a java.lang.SecurityException.
        ///
        /// </para>
        /// </summary>
        /// <param name="host"> The hostname of the site requesting authentication. </param>
        /// <param name="addr"> The InetAddress of the site requesting authorization,
        ///             or null if not known. </param>
        /// <param name="port"> the port for the requested connection </param>
        /// <param name="protocol"> The protocol that's requesting the connection
        ///          (<seealso cref="java.net.Authenticator#getRequestingProtocol()"/>) </param>
        /// <param name="prompt"> A prompt string for the user </param>
        /// <param name="scheme"> The authentication scheme </param>
        /// <param name="url"> The requesting URL that caused the authentication </param>
        /// <param name="reqType"> The type (server or proxy) of the entity requesting
        ///              authentication.
        /// </param>
        /// <returns> The username/password, or null if one can't be gotten.
        /// </returns>
        /// <exception cref="SecurityException">
        ///        if a security manager exists and its
        ///        {@code checkPermission} method doesn't allow
        ///        the password authentication request.
        /// </exception>
        /// <seealso cref= SecurityManager#checkPermission </seealso>
        /// <seealso cref= java.net.NetPermission
        ///
        /// @since 1.5 </seealso>
        public static PasswordAuthentication RequestPasswordAuthentication(String host, InetAddress addr, int port, String protocol, String prompt, String scheme, URL url, RequestorType reqType)
        {
            SecurityManager sm = System.SecurityManager;

            if (sm != null)
            {
                NetPermission requestPermission = new NetPermission("requestPasswordAuthentication");
                sm.CheckPermission(requestPermission);
            }

            Authenticator a = TheAuthenticator;

            if (a == null)
            {
                return(null);
            }
            else
            {
                lock (a)
                {
                    a.Reset();
                    a.RequestingHost_Renamed     = host;
                    a.RequestingSite_Renamed     = addr;
                    a.RequestingPort_Renamed     = port;
                    a.RequestingProtocol_Renamed = protocol;
                    a.RequestingPrompt_Renamed   = prompt;
                    a.RequestingScheme_Renamed   = scheme;
                    a.RequestingURL_Renamed      = url;
                    a.RequestingAuthType         = reqType;
                    return(a.PasswordAuthentication);
                }
            }
        }
 public RideTerminated(int driverId, RequestorType destinatedEntityType)
 {
     DestinatedEntityId   = driverId;
     DestinatedEntityType = destinatedEntityType;
 }
        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();
        }
Beispiel #7
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();
        }
Beispiel #8
0
 public void Deconstruct(out RequestPersonalDetails requestor, out RequestPersonalDetails recipient, out RequestorType requestorType)
 {
     requestor     = Requestor;
     recipient     = Recipient;
     requestorType = RequestorType;
 }