public void StudyVersionsRequest_can_format_response_properly()
        {
            string response_data =
                @"<ODM ODMVersion=""1.3"" Granularity=""Metadata"" FileType=""Snapshot""
                FileOID=""d26b4d33-376d-4037-9747-684411190179""
                CreationDateTime=""2013-04-08T01:29:13""
                xmlns=""http://www.cdisc.org/ns/odm/v1.3""
                xmlns:mdsol=""http://www.mdsol.com/ns/odm/metadata"">
                    <Study OID=""Mediflex"">
                        <GlobalVariables>
                            <StudyName>Mediflex</StudyName>
                            <StudyDescription></StudyDescription>
                            <ProtocolName>Mediflex</ProtocolName>
                        </GlobalVariables>
                        <MetaDataVersion OID=""1213"" Name=""1.0_DRAFT"" />
                        <MetaDataVersion OID=""1194"" Name=""CF_TEST_DRAFT1"" />
                        <MetaDataVersion OID=""1164"" Name=""Initial"" />
                    </Study>
                </ODM>";

            var request = new StudyVersionsRequest(ProjectName: "FakeItTillYaMakeIt(Dev)");

            var mockResponse = new Mock <IRestResponse>();

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

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

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

            Assert.AreEqual(response.Study.OID, "Mediflex");

            var versionOIDS  = new string[] { "1213", "1194", "1164" };
            var versionNames = new string[] { "1.0_DRAFT", "CF_TEST_DRAFT1", "Initial" };

            foreach (var version in response)
            {
                Assert.IsTrue(versionOIDS.Contains(version.OID));
                Assert.IsTrue(versionNames.Contains(version.Name));
            }
        }
        public async Task StudyVersionsRequest_can_format_a_response()
        {
            _httpTest.RespondWith(
                @"<ODM ODMVersion=""1.3"" Granularity=""Metadata"" FileType=""Snapshot""
                FileOID=""d26b4d33-376d-4037-9747-684411190179""
                CreationDateTime=""2013-04-08T01:29:13""
                xmlns=""http://www.cdisc.org/ns/odm/v1.3""
                xmlns:mdsol=""http://www.mdsol.com/ns/odm/metadata"">
                    <Study OID=""Mediflex"">
                        <GlobalVariables>
                            <StudyName>Mediflex</StudyName>
                            <StudyDescription></StudyDescription>
                            <ProtocolName>Mediflex</ProtocolName>
                        </GlobalVariables>
                        <MetaDataVersion OID=""1213"" Name=""1.0_DRAFT"" />
                        <MetaDataVersion OID=""1194"" Name=""CF_TEST_DRAFT1"" />
                        <MetaDataVersion OID=""1164"" Name=""Initial"" />
                    </Study>
                </ODM>"
                );

            var rwsConnection = new RwsConnection("innovate", "test", "password");
            var request       = new StudyVersionsRequest("Mediflex(Dev)");
            var result        = await rwsConnection.SendRequestAsync(request) as RwsStudyMetadataVersions;

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(RwsStudyMetadataVersions));
            Assert.AreEqual(result.Study.Oid, "Mediflex");

            var versionOids  = new[] { "1213", "1194", "1164" };
            var versionNames = new[] { "1.0_DRAFT", "CF_TEST_DRAFT1", "Initial" };

            foreach (var version in result)
            {
                Assert.IsTrue(versionOids.Contains(version.OID));
                Assert.IsTrue(versionNames.Contains(version.Name));
            }
        }
        public void StudyVersionsRequest_can_properly_construct_a_url()
        {
            var request = new StudyVersionsRequest("Mediflex(Dev)");

            Assert.AreEqual("metadata/studies/Mediflex(Dev)/versions", request.UrlPath());
        }
        public void StudyVersionsRequest_computes_URL_correctly()
        {
            var req = new StudyVersionsRequest(ProjectName: "FakeItTillYaMakeIt(Dev)");

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