Пример #1
0
        public void ODMAdapter_can_raise_events_and_subscribers_are_notified()
        {
            var mockResponse = new Mock <IRestResponse>();

            mockResponse.Setup(x => x.Content).Returns(AuditRecordXML);

            var odmAdapterResponse = new Mock <RWSResponse>(mockResponse.Object);

            odmAdapterResponse.Setup(x => x.RawXMLString()).Returns(AuditRecordXML);

            var conn = new Mock <IRWSConnection>();

            var mockParser = new AuditEventParser();

            var dummySubscriber = new Mock <DummyDBWarehouseService>();

            conn.Setup(m => m.SendRequest(
                           It.IsAny <AuditRecordsRequest>(), null)).Returns(odmAdapterResponse.Object);

            var odmAdapter = new OdmAdapter(conn.Object, mockParser, "", "", dummySubscriber.Object);

            odmAdapter.Run(1, -1, 1000);

            dummySubscriber.Verify(x => x.OnContextBuilt(mockParser, It.IsAny <ContextEventArgs>()), Times.Exactly(7));

            dummySubscriber.Verify(x => x.OnParsingComplete(odmAdapter, It.IsAny <ODMAdapterEventArgs>()), Times.Once());

            dummySubscriber.Verify(x => x.OnPageProcessed(odmAdapter, It.IsAny <EventArgs>()), Times.Once());

            //We verified the subscriber was invoked as needed.
        }
Пример #2
0
        public void ODMAdapter_can_get_link_and_rel_from_response_headers()
        {
            var mockResponse = new Mock <IRestResponse>();

            mockResponse.Setup(x => x.Content).Returns(AuditRecordXML);

            mockResponse.Setup(x => x.Headers).Returns(new List <Parameter>()
            {
                new Parameter {
                    Name = "Link", Value = "<https://innovate.mdsol.com/RaveWebServices/datasets/ClinicalAuditRecords.odm?studyoid=Mediflex&per_page=10000&startid=8253885>; rel=\"next\""
                }
            });

            var odmAdapterResponse = new Mock <RWSResponse>(mockResponse.Object);

            odmAdapterResponse.Setup(x => x.RawXMLString()).Returns(AuditRecordXML);

            var conn = new Mock <IRWSConnection>();

            var mockParser = new AuditEventParser();

            conn.Setup(m => m.SendRequest(
                           It.IsAny <AuditRecordsRequest>(), null)).Returns(odmAdapterResponse.Object);

            conn.Setup(m => m.GetLastResult()).Returns(mockResponse.Object);

            var odmAdapter = new OdmAdapter(conn.Object, mockParser, "", "");

            odmAdapter.Run(1, 1, 1000);

            Assert.AreEqual("https://innovate.mdsol.com/RaveWebServices/datasets/ClinicalAuditRecords.odm?studyoid=Mediflex&per_page=10000&startid=8253885", odmAdapter.LastLink);
            Assert.AreEqual("next", odmAdapter.LastRel);
        }
Пример #3
0
        public void ODMAdapter_can_be_successfully_instantiated()
        {
            var conn = new RwsConnection("innovate", "fakeuser", "fakepass");

            var odm = new OdmAdapter(conn, new AuditEventParser(), "FAKESTUDY", "DEV3 LabTest");

            //no exceptions means we pass.
        }
Пример #4
0
        public void AuditEventParser_Parses_Subject_TransactionType()
        {
            response = new Mock <IRestResponse>();
            response.Setup(x => x.Content).Returns(SubjectCreatedXML);
            odmAdapterResponse = new Mock <RWSResponse>(response.Object);
            odmAdapterResponse.Setup(x => x.RawXMLString()).Returns(SubjectCreatedXML);
            connection = new Mock <IRWSConnection>();
            connection.Setup(m => m.SendRequest(
                                 It.IsAny <AuditRecordsRequest>(), null)).Returns(odmAdapterResponse.Object);

            var mockParser = new AuditEventParser();

            var odmAdapter = new OdmAdapter(connection.Object, mockParser, "", "", new SubjectDataSubscriber());

            odmAdapter.Run(1, -1, 1000);
        }
Пример #5
0
        public void ODMAdapter_contains_reference_to_correct_last_source_id()
        {
            var mockResponse = new Mock <IRestResponse>();

            mockResponse.Setup(x => x.Content).Returns(AuditRecordXML);

            var odmAdapterResponse = new Mock <RWSResponse>(mockResponse.Object);

            odmAdapterResponse.Setup(x => x.RawXMLString()).Returns(AuditRecordXML);

            var conn = new Mock <IRWSConnection>();

            var mockParser = new AuditEventParser();

            conn.Setup(m => m.SendRequest(
                           It.IsAny <AuditRecordsRequest>(), null)).Returns(odmAdapterResponse.Object);

            var odmAdapter = new OdmAdapter(conn.Object, mockParser, "", "");

            odmAdapter.Run(1, -1, 1000);

            Assert.AreEqual(8253891, odmAdapter.LastSourceId);
        }