Exemple #1
0
        public void test_put_object()
        {
            _headers.Add("request-type", "object");
            var            stream = new MemoryStream();
            ObjectResponse res    = _client.PutObject("", "", "", "", stream, _headers, new Dictionary <string, string>());

            Assert.True(res.Reason == "foo");
            Assert.True(res.Status == 201);
        }
        public void test_get_container()
        {
            string container_name = (prefix + Guid.NewGuid().ToString());

            created_containers.Add(container_name);
            var obj_cont_pair = new Dictionary <string, string>
            {
                { "container", container_name }, { "object", prefix + Guid.NewGuid().ToString() }
            };

            created_objects.Add(obj_cont_pair);
            obj_cont_pair = new Dictionary <string, string>
            {
                { "container", container_name }, { "object", prefix + Guid.NewGuid().ToString() }
            };
            client.PutContainer(storage_url, auth_token, container_name, new Dictionary <string, string>(), new Dictionary <string, string>());
            created_objects.Add(obj_cont_pair);
            foreach (var obj_dict in created_objects)
            {
                var    encoder    = new UTF8Encoding();
                byte[] byte_array = encoder.GetBytes(object_content);
                var    stream     = new MemoryStream(byte_array);
                client.PutObject(storage_url, auth_token, obj_dict["container"], obj_dict["object"], stream, new Dictionary <string, string>(), new Dictionary <string, string>());
            }
            var query = new Dictionary <string, string> {
                { "prefix", prefix }
            };
            var res = client.GetContainer(storage_url, auth_token, container_name, new Dictionary <string, string>(), query, false);

            foreach (var header in container_headers)
            {
                Assert.IsTrue(res.Headers.ContainsKey(header), "Header: " + header);
            }
            foreach (var object_hash in res.Objects)
            {
                if (object_hash.ContainsKey("subdir"))
                {
                    foreach (string key in subdir_listing_keys)
                    {
                        Assert.IsTrue(object_hash.ContainsKey(key));
                    }
                }
                else
                {
                    foreach (var key in object_listing_keys)
                    {
                        Assert.IsTrue(object_hash.ContainsKey(key));
                    }
                }
            }
            query.Add("limit", "1");
            obj_cont_pair = new Dictionary <string, string> {
                { "container", container_name }, { "object", folder_object_name }
            };
            created_objects.Add(obj_cont_pair);
            var coder       = new UTF8Encoding();
            var byte_array2 = coder.GetBytes(object_content);
            var stream2     = new MemoryStream(byte_array2);

            client.PutObject(storage_url, auth_token, container_name, folder_object_name, stream2, new Dictionary <string, string>(), new Dictionary <string, string>());
            foreach (var header in container_headers)
            {
                Assert.IsTrue(res.Headers.ContainsKey(header), "Header: " + header);
            }
            foreach (var object_hash in res.Objects)
            {
                if (object_hash.ContainsKey("subdir"))
                {
                    foreach (var key in subdir_listing_keys)
                    {
                        Assert.IsTrue(object_hash.ContainsKey(key));
                    }
                }
                else
                {
                    foreach (string key in object_listing_keys)
                    {
                        Assert.IsTrue(object_hash.ContainsKey(key));
                    }
                }
            }
        }