public void MetadataStudiesRequest_can_format_response_properly()
        {
            string response_data =
                @"<ODM FileType=""Snapshot"" FileOID=""767a1f8b-7b72-4d12-adbe-37d4d62ba75e""
                         CreationDateTime=""2013-04-08T10:02:17.781-00:00""
                         ODMVersion=""1.3""
                         xmlns:mdsol=""http://www.mdsol.com/ns/odm/metadata""
                         xmlns:xlink=""http://www.w3.org/1999/xlink""
                         xmlns=""http://www.cdisc.org/ns/odm/v1.3"">
                         <Study OID=""FakeItTillYaMakeIt(Dev)"">
                            <GlobalVariables>
                                  <StudyName>FakeItTillYaMakeIt(Dev)</StudyName>
                                  <StudyDescription/>
                                  <ProtocolName>FakeItTillYaMakeIt</ProtocolName>
                            </GlobalVariables>
                         </Study>
                         <Study OID=""Mediflex(Prod)"" mdsol:ProjectType=""Project"">
                            <GlobalVariables>
                                  <StudyName>Mediflex(Prod)</StudyName>
                                  <StudyDescription/>
                                  <ProtocolName>Mediflex</ProtocolName>
                            </GlobalVariables>
                         </Study>
                    </ODM>";

            var request = new MetadataStudiesRequest();

            var mockResponse = new Mock <IRestResponse>();

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

            var response = request.Result(mockResponse.Object) as RWSStudies;

            Assert.IsInstanceOfType(response, typeof(RWSStudies));

            var studyOIDS    = new string[] { "Mediflex(Prod)", "FakeItTillYaMakeIt(Dev)" };
            var environments = new string[] { "Prod", "Dev" };

            foreach (var study in response)
            {
                Assert.IsTrue(studyOIDS.Contains(study.OID));
                Assert.IsTrue(environments.Contains(study.Environment),
                              string.Format("Unexpected environment ({0})", study.Environment));
                Assert.IsFalse(study.IsProduction);
            }
        }
        public async Task MetadataStudiesRequest_can_format_a_response()
        {
            _httpTest.RespondWith(
                new StringContent(@"<?xml version=""1.0"" encoding=""utf-8""?>
                <ODM ODMVersion=""1.3"" Granularity=""Metadata"" FileType=""Snapshot"" FileOID=""d5457ec2-feee-4a0f-88c1-fbedc391974b"" CreationDateTime=""2018-06-20T12:02:50"" xmlns=""http://www.cdisc.org/ns/odm/v1.3"" xmlns:mdsol=""http://www.mdsol.com/ns/odm/metadata"">
                    <Study OID=""Lab Test(Dev)"">
                        <GlobalVariables>
                            <StudyName>Lab Test(Dev)</StudyName>
                            <StudyDescription></StudyDescription>
                            <ProtocolName>Lab Test</ProtocolName>
                        </GlobalVariables>
                    </Study>
                    <Study OID=""Mediflex(Prod)"">
                        <GlobalVariables>
                            <StudyName>Mediflex(Prod)</StudyName>
                            <StudyDescription></StudyDescription>
                            <ProtocolName>Mediflex</ProtocolName>
                        </GlobalVariables>
                    </Study>
                </ODM>", Encoding.UTF8, "text/xml"));

            var rwsConnection = new RwsConnection("innovate", "test", "password");
            var request       = new MetadataStudiesRequest();
            var result        = await rwsConnection.SendRequestAsync(request) as RwsStudies;

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(RwsStudies));

            var studies      = new[] { "Lab Test(Dev)", "Mediflex(Prod)" };
            var environments = new[] { "Dev", "Prod" };

            foreach (var study in result)
            {
                Assert.IsTrue(studies.Contains(study.Oid));
                Assert.IsTrue(environments.Contains(study.Environment),
                              $"Unexpected environment ({study.Environment})");
            }
        }
        public void ClinicalStudiesRequest_can_properly_construct_a_url()
        {
            var request = new MetadataStudiesRequest();

            Assert.AreEqual("metadata/studies", request.UrlPath());
        }
        public void MetadataStudiesRequest_computes_URL_correctly()
        {
            var req = new MetadataStudiesRequest();

            Assert.AreEqual("metadata/studies", req.UrlPath());
        }