Example #1
0
        public void testParse()
        {
            string content = "<ListAllMyBucketsResult>"
                             + "<Owner>"
                             + " <ID>qcs::cam::uin/1147518609:uin/1147518609</ID>"
                             + "<DisplayName>1147518609</DisplayName>"
                             + " </Owner>"
                             + "<Buckets>"
                             + "<Bucket>"
                             + "<Name>01</Name>"
                             + "<Location>ap-beijing</Location>"
                             + "<CreateDate>2016-09-13 15:20:15</CreateDate>"
                             + "</Bucket>"
                             + "<Bucket>"
                             + "<Name>0111</Name>"
                             + "<Location>ap-hongkong</Location>"
                             + "<CreateDate>2017-01-11 17:23:51</CreateDate>"
                             + "</Bucket>"
                             + "<Bucket>"
                             + "<Name>1201new</Name>"
                             + "<Location>eu-frankfurt</Location>"
                             + "<CreateDate>2016-12-01 09:45:02</CreateDate>"
                             + "</Bucket>"
                             + "</Buckets>"
                             + "</ListAllMyBucketsResult>";

            byte[]           bytes        = Encoding.ASCII.GetBytes(content);
            MemoryStream     memoryStream = new MemoryStream(bytes);
            ListAllMyBuckets result       = new ListAllMyBuckets();

            XmlParse.ParseListAllMyBucketsResult(memoryStream, result);
            Assert.AreEqual("qcs::cam::uin/1147518609:uin/1147518609", result.owner.id);
            Assert.AreEqual(3, result.buckets.Count);
        }
Example #2
0
        public void GetInfoTest()
        {
            ListAllMyBuckets target   = new ListAllMyBuckets(); // TODO: Initialize to an appropriate value
            string           expected = string.Empty;           // TODO: Initialize to an appropriate value
            string           actual;

            actual = target.GetInfo();
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
        private void ValidateBucketList(ListAllMyBuckets bucketList)
        {
            Assert.True(bucketList.buckets.Count > 0);
            Assert.NotNull(bucketList.owner);
            Assert.NotNull(bucketList.owner.id);
            Assert.NotNull(bucketList.owner.disPlayName);

            foreach (var bucket in bucketList.buckets)
            {
                Assert.NotNull(bucket.createDate);
                Assert.NotNull(bucket.name);
                Assert.NotNull(bucket.location);
            }
        }
Example #4
0
        public void ListAllMyBucketsConstructorTest()
        {
            ListAllMyBuckets target = new ListAllMyBuckets();

            Assert.Inconclusive("TODO: Implement code to verify target");
        }
 internal override void ParseResponseBody(System.IO.Stream inputStream, string contentType, long contentLength)
 {
     listAllMyBuckets = new ListAllMyBuckets();
     XmlParse.ParseListAllMyBucketsResult(inputStream, listAllMyBuckets);
 }
Example #6
0
        public static void ParseListAllMyBucketsResult(Stream inStream, ListAllMyBuckets result)
        {
            XmlReader xmlReader = XmlReader.Create(inStream);

            ListAllMyBuckets.Bucket bucket = null;

            while (xmlReader.Read())
            {
                switch (xmlReader.NodeType)
                {
                case XmlNodeType.Element:                                                   // element start
                    if ("Owner".Equals(xmlReader.Name, StringComparison.OrdinalIgnoreCase)) // get element name
                    {
                        result.owner = new ListAllMyBuckets.Owner();
                    }
                    else if ("ID".Equals(xmlReader.Name, StringComparison.OrdinalIgnoreCase))
                    {
                        xmlReader.Read();
                        result.owner.id = xmlReader.Value;     // get element value
                    }
                    else if ("DisplayName".Equals(xmlReader.Name, StringComparison.OrdinalIgnoreCase))
                    {
                        xmlReader.Read();
                        result.owner.disPlayName = xmlReader.Value;
                    }
                    else if ("Buckets".Equals(xmlReader.Name, StringComparison.OrdinalIgnoreCase))
                    {
                        result.buckets = new List <ListAllMyBuckets.Bucket>();
                    }
                    else if ("Bucket".Equals(xmlReader.Name, StringComparison.OrdinalIgnoreCase))
                    {
                        bucket = new ListAllMyBuckets.Bucket();
                    }
                    else if ("Bucket".Equals(xmlReader.Name, StringComparison.OrdinalIgnoreCase))
                    {
                        bucket = new ListAllMyBuckets.Bucket();
                    }
                    else if ("Name".Equals(xmlReader.Name, StringComparison.OrdinalIgnoreCase))
                    {
                        xmlReader.Read();
                        bucket.name = xmlReader.Value;
                    }
                    else if ("Location".Equals(xmlReader.Name, StringComparison.OrdinalIgnoreCase))
                    {
                        xmlReader.Read();
                        bucket.location = xmlReader.Value;
                    }
                    else if ("CreateDate".Equals(xmlReader.Name, StringComparison.OrdinalIgnoreCase))
                    {
                        xmlReader.Read();
                        bucket.createDate = xmlReader.Value;
                    }
                    break;

                case XmlNodeType.EndElement:     //end element
                    if ("Bucket".Equals(xmlReader.Name, StringComparison.OrdinalIgnoreCase))
                    {
                        result.buckets.Add(bucket);
                        bucket = null;
                    }
                    break;
                }
            }
        }