public void Should_get_serialized_json_format()
        {
            var testHelper = new TestHelper(authToken, storageUrl);
            testHelper.PutItemInContainer(Constants.StorageItemNameJpg);
            var getContainerInformation = new GetContainerInformationSerialized(storageUrl,  Constants.CONTAINER_NAME, Format.JSON);

            var jsonResponse = new GenerateRequestByType().Submit(getContainerInformation, authToken);
            Assert.That(jsonResponse.Status, Is.EqualTo(HttpStatusCode.OK));
            var jsonReturnValue = String.Join("", jsonResponse.ContentBody.ToArray());
            jsonResponse.Dispose();
            var expectedSubString = "[{\"name\":[ ]?\"" + Constants.StorageItemNameJpg + "\",[ ]?\"hash\":[ ]?\"b44a59383b3123a747d139bd0e71d2df\",[ ]?\"bytes\":[ ]?\\d+,[ ]?\"content_type\":[ ]?\"image.*jpeg\",[ ]?\"last_modified\":[ ]?\"" + String.Format("{0:yyyy-MM}", DateTime.Now);

            Assert.That(Regex.Match(jsonReturnValue, expectedSubString).Success, Is.True);
            testHelper.DeleteItemFromContainer(Constants.StorageItemNameJpg);
            testHelper.Dispose();
        }
        public void Should_get_serialized_xml_format()
        {
            using (var testHelper = new TestHelper(authToken, storageUrl))
            {
                testHelper.PutItemInContainer(Constants.StorageItemNameJpg);
                var getContainerInformation = new GetContainerInformationSerialized(storageUrl,  Constants.CONTAINER_NAME, Format.XML);

                var xmlResponse = new GenerateRequestByType().Submit(getContainerInformation, authToken);
                Assert.That(xmlResponse.Status, Is.EqualTo(HttpStatusCode.OK));
                var xmlReturnValue = String.Join("", xmlResponse.ContentBody.ToArray());
                xmlResponse.Dispose();
                var expectedSubString = "<container name=\"" + Constants.CONTAINER_NAME + "\"><object><name>" + Constants.StorageItemNameJpg + "<\\/name><hash>b44a59383b3123a747d139bd0e71d2df<\\/hash><bytes>\\d+<\\/bytes><content_type>image.*jpeg<\\/content_type><last_modified>" + String.Format("{0:yyyy-MM}", DateTime.Now);

                Assert.That(Regex.Match(xmlReturnValue, expectedSubString).Success || string.IsNullOrEmpty(xmlReturnValue), Is.True);
                testHelper.DeleteItemFromContainer(Constants.StorageItemNameJpg);
            }
        }
示例#3
0
        private XmlDocument getContainerInformationXml(string containerName)
        {
            var getContainerInformation = new GetContainerInformationSerialized(StorageUrl, containerName, Format.XML);
            var getSerializedResponse = _requestfactory.Submit(getContainerInformation, AuthToken, _usercreds.ProxyCredentials);
            var xmlResponse = String.Join("", getSerializedResponse.ContentBody.ToArray());
            getSerializedResponse.Dispose();

            var xmlDocument = new XmlDocument();
            try
            {
                xmlDocument.LoadXml(xmlResponse);
            }
            catch (XmlException xmlex)
            {
                Console.WriteLine(xmlex);
                return xmlDocument;
            }

            return xmlDocument;
        }
 public void setup()
 {
     GetContainerInformationSerialized = new GetContainerInformationSerialized("http://storageurl", "containername", Format.JSON);
 }
示例#5
0
 private string getContainerInformationJson(string containerName)
 {
     var getContainerInformation = new GetContainerInformationSerialized(StorageUrl, containerName, Format.JSON);
     var getSerializedResponse = _requestfactory.Submit(getContainerInformation, AuthToken, _usercreds.ProxyCredentials);
     var jsonResponse = String.Join("", getSerializedResponse.ContentBody.ToArray());
     getSerializedResponse.Dispose();
     return jsonResponse;
 }