public void should_return_account_name_and_ok_status_200()
        {
            var accountInformationXml = new GetAccountInformationSerialized(storageUrl, Format.XML);
            var getAccountInformationXmlResponse =new GenerateRequestByType().Submit(accountInformationXml, authToken);
            Assert.That(getAccountInformationXmlResponse.Status, Is.EqualTo(HttpStatusCode.OK));

            var contentBody = "";
            foreach (var s in getAccountInformationXmlResponse.ContentBody)
            {
                contentBody += s;
            }

            getAccountInformationXmlResponse.Dispose();
            const string expectedSubString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><account name=\"MossoCloudFS_5d8f3dca-7eb9-4453-aa79-2eea1b980353\"></account>";
            Assert.That(contentBody, Is.EqualTo(expectedSubString));
        }
        public void should_return_account_information_in_json_format_including_name_count_and_bytes()
        {
            using (var testHelper = new TestHelper(authToken, storageUrl))
            {
                try
                {
                    testHelper.PutItemInContainer(Constants.StorageItemName);

                    var getAccountInformationJson = new GetAccountInformationSerialized(storageUrl,  Format.JSON);
                    var getAccountInformationJsonResponse = new GenerateRequestByType().Submit(getAccountInformationJson, authToken);

                    if(getAccountInformationJsonResponse.ContentBody.Count == 0)
                        Assert.Fail("No content body returned in response");

                    const string expectedSubString = "{\"name\":[ ]?\"" + Constants.CONTAINER_NAME + "\",[ ]?\"count\":[ ]?\\d+,[ ]?\"bytes\":[ ]?\\d+}";
                    var contentBody = getAccountInformationJsonResponse.ContentBody;
                    getAccountInformationJsonResponse.Dispose();
                    foreach (var s in contentBody)
                    {
                        if (Regex.Match(s, expectedSubString).Success) return;
                    }

                    Assert.Fail("Expected value: " + expectedSubString + " not found");

                }
                finally
                {

                    testHelper.DeleteItemFromContainer();
                }
            }
        }
        public void should_return_account_information_in_xml_format_including_name_count_and_size()
        {
            using (var testHelper = new TestHelper(authToken, storageUrl))
            {
                try
                {
                    testHelper.PutItemInContainer(Constants.StorageItemName);

                    var accountInformationXml = new GetAccountInformationSerialized(storageUrl,  Format.XML);
                    var getAccountInformationXmlResponse = new GenerateRequestByType().Submit(accountInformationXml,authToken);

                    if (getAccountInformationXmlResponse.ContentBody.Count == 0)
                        Assert.Ignore("No content body returned in response");

                    var contentBody = "";
                    foreach (var s in getAccountInformationXmlResponse.ContentBody)
                    {
                        contentBody += s;
                    }

                    getAccountInformationXmlResponse.Dispose();
                    var xmlDocument = new XmlDocument();
                    try
                    {
                        xmlDocument.LoadXml(contentBody);
                    }
                    catch(XmlException e)
                    {
                        Console.WriteLine(e.Message);
                    }

                    const string expectedSubString = "<container><name>"+ Constants.CONTAINER_NAME +"</name><count>\\d*</count><bytes>\\d+</bytes></container>";
                    Assert.That(Regex.Match(contentBody, expectedSubString).Success, Is.True);
                }
                finally
                {
                    testHelper.DeleteItemFromContainer();
                }
            }
        }
        public void should_return_empty_brackets_and_ok_status_200()
        {
            var getAccountInformationJson = new GetAccountInformationSerialized(storageUrl,  Format.JSON);
            var getAccountInformationJsonResponse = new GenerateRequestByType().Submit(getAccountInformationJson, authToken);
            Assert.That(getAccountInformationJsonResponse.Status, Is.EqualTo(HttpStatusCode.OK));
            var contentBody = String.Join("",getAccountInformationJsonResponse.ContentBody.ToArray());
            getAccountInformationJsonResponse.Dispose();

            Assert.That(contentBody, Is.EqualTo("[]"));
        }
Ejemplo n.º 5
0
        private XmlDocument BuildAccountXml()
        {
            var accountInformationXml = new GetAccountInformationSerialized(StorageUrl, Format.XML);
            var getAccountInformationXmlResponse = _requestfactory.Submit(accountInformationXml, AuthToken);

            if (getAccountInformationXmlResponse.ContentBody.Count == 0)
            {
                return new XmlDocument();
            }
            var contentBody = String.Join("", getAccountInformationXmlResponse.ContentBody.ToArray());

            getAccountInformationXmlResponse.Dispose();

            try
            {
                var doc = new XmlDocument();
                doc.LoadXml(contentBody);
                return doc;
            }
            catch (XmlException)
            {
                return new XmlDocument();
            }
        }
Ejemplo n.º 6
0
        private string BuildAccountJson()
        {
            string jsonResponse = "";
            var getAccountInformationJson = new GetAccountInformationSerialized(StorageUrl, Format.JSON);
            var getAccountInformationJsonResponse = _requestfactory.Submit(getAccountInformationJson, AuthToken);

            if (getAccountInformationJsonResponse.ContentBody.Count > 0)
                jsonResponse = String.Join("", getAccountInformationJsonResponse.ContentBody.ToArray());

            getAccountInformationJsonResponse.Dispose();
            return jsonResponse;
        }
 public void setup()
 {
     getAccountInformationSerialized = new GetAccountInformationSerialized("http://storageurl", Format.XML);
     _mockrequest = new Mock<ICloudFilesRequest>();
 }