public void should_return_xml_document_with_xxxxx()
        {
            var          container   = new MockCFContainer("testcontainername");
            const string expectedXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><container name=\"testcontainername\"></container>";

            Assert.That(container.XML.InnerXml, Is.EqualTo(expectedXml));
        }
        public void should_add_the_object()
        {
            var container = new MockCFContainer("testcontainername");

            container.AddObject(Constants.STORAGE_ITEM_NAME);
            Assert.That(container.ObjectExists(Constants.STORAGE_ITEM_NAME), Is.True);
        }
        public void should_return_json_string_emptry_brackets()
        {
            var          container    = new MockCFContainer("testcontainername");
            const string expectedJson = "[]";

            Assert.That(container.JSON, Is.EqualTo(expectedJson));
        }
        public void should_return_only_objects_beginning_with_the_provided_substring()
        {
            var container = new MockCFContainer("testcontainername");

            container.AddObject(Constants.STORAGE_ITEM_NAME);
            Assert.That(container.ObjectExists(Constants.STORAGE_ITEM_NAME), Is.True);
            container.AddObject(Constants.HEAD_STORAGE_ITEM_NAME);
            Assert.That(container.ObjectExists(Constants.HEAD_STORAGE_ITEM_NAME), Is.True);

            string[] objectNames = container.GetObjectNames();
            Assert.That(objectNames.Length, Is.EqualTo(2));
            Assert.That(objectNames[0], Is.EqualTo(Constants.STORAGE_ITEM_NAME));
            Assert.That(objectNames[1], Is.EqualTo(Constants.HEAD_STORAGE_ITEM_NAME));

            var parameters = new Dictionary <GetItemListParameters, string>
            {
                { GetItemListParameters.Prefix, "h" }
            };

            objectNames = container.GetObjectNames(parameters);
            Assert.That(objectNames.Length, Is.EqualTo(1));
            Assert.That(objectNames[0], Is.EqualTo(Constants.HEAD_STORAGE_ITEM_NAME));

            parameters.Clear();
            parameters.Add(GetItemListParameters.Prefix, "t");
            objectNames = container.GetObjectNames(parameters);
            Assert.That(objectNames.Length, Is.EqualTo(1));
            Assert.That(objectNames[0], Is.EqualTo(Constants.STORAGE_ITEM_NAME));
        }
        public void Should_obtain_a_public_url()
        {
            var container = new MockCFContainer("testcontainername");

            container.MarkAsPublic();

            Assert.That(container.PublicUrl.ToString().Contains("http://tempuri.org"), Is.True);
        }
        public void should_throw_storage_item_not_found_exception()
        {
            var container = new MockCFContainer("testcontainername");

            container.DeleteObject(Constants.STORAGE_ITEM_NAME);

            Assert.Fail("Allowed deletion of non-existant object");
        }
        public void should_add_the_object()
        {
            var container = new MockCFContainer("testcontainername");

            container.AddObject(Constants.STORAGE_ITEM_NAME);
            Assert.That(container.ObjectExists(Constants.STORAGE_ITEM_NAME), Is.True);
            string[] objectNames = container.GetObjectNames();
            Assert.That(objectNames[0], Is.EqualTo(Constants.STORAGE_ITEM_NAME));
        }
        public void should_give_the_object_public_url()
        {
            var container = new MockCFContainer("testcontainername");

            container.MarkAsPublic();
            var @object = container.AddObject(Constants.STORAGE_ITEM_NAME);

            Assert.That(@object.PublicUrl.ToString(), Is.EqualTo("http://tempuri.org/" + Constants.STORAGE_ITEM_NAME));
        }
        public void should_return_xml_document_with_objects_names_and_hash_and_bytes_and_content_type_and_last_modified_date()
        {
            var container = new MockCFContainer("testcontainername");

            container.AddObject("object");
            const string expectedXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><container name=\"testcontainername\"><object><name>object</name><hash>4281c348eaf83e70ddce0e07221c3d28</hash><bytes>14</bytes><content_type>application/octet-stream</content_type><last_modified>2009-02-03T05:26:32.612278</last_modified></object></container>";

            Assert.That(container.XML.InnerXml, Is.EqualTo(expectedXml));
        }
        public void should_return_json_string_with_object_names_and_hash_and_bytes_and_content_type_and_last_modified_date()
        {
            var container = new MockCFContainer("testcontainername");

            container.AddObject("test_object_1");
            const string expectedJson = "[{\"name\":[ ]?\"test_object_1\",[ ]?\"hash\":[ ]?\"4281c348eaf83e70ddce0e07221c3d28\",[ ]?\"bytes\":[ ]?14,[ ]?\"content_type\":[ ]?\"application\\/octet-stream\",[ ]?\"last_modified\":[ ]?\"2009-02-03T05:26:32.612278\"}]";

            Assert.That(container.JSON, Is.EqualTo(expectedJson));
        }
        public void should_return_only_the_specified_number_of_objects()
        {
            var container = new MockCFContainer("testcontainername");

            container.AddObject(Constants.STORAGE_ITEM_NAME);
            Assert.That(container.ObjectExists(Constants.STORAGE_ITEM_NAME), Is.True);
            container.AddObject(Constants.HEAD_STORAGE_ITEM_NAME);
            Assert.That(container.ObjectExists(Constants.HEAD_STORAGE_ITEM_NAME), Is.True);

            string[] objectNames = container.GetObjectNames();
            Assert.That(objectNames.Length, Is.EqualTo(2));
            Assert.That(objectNames[0], Is.EqualTo(Constants.STORAGE_ITEM_NAME));
            Assert.That(objectNames[1], Is.EqualTo(Constants.HEAD_STORAGE_ITEM_NAME));

            var parameters = new Dictionary <GetItemListParameters, string>
            {
                { GetItemListParameters.Limit, "1" }
            };

            objectNames = container.GetObjectNames(parameters);
            Assert.That(objectNames.Length, Is.EqualTo(1));
            Assert.That(objectNames[0], Is.EqualTo(Constants.STORAGE_ITEM_NAME));
        }
Exemplo n.º 12
0
        public void should_return_json_string_emptry_brackets()
        {
            var container  = new MockCFContainer("testcontainername");
            var expectedJson = "[]";

            Assert.That(container.JSON, Is.EqualTo(expectedJson));
        }
Exemplo n.º 13
0
        public void should_return_json_string_with_object_names_and_hash_and_bytes_and_content_type_and_last_modified_date()
        {
            var container = new MockCFContainer("testcontainername");
            container.AddObject("test_object_1");
            var expectedJson = "[{\"name\":\"test_object_1\",\"hash\":\"4281c348eaf83e70ddce0e07221c3d28\",\"bytes\":14,\"content_type\":\"application\\/octet-stream\",\"last_modified\":\"2009-02-03T05:26:32.612278\"}]";

            Assert.That(container.JSON, Is.EqualTo(expectedJson));
        }
Exemplo n.º 14
0
        public void should_return_only_objects_greater_than_the_marker_value()
        {
            var container = new MockCFContainer("testcontainername");
            container.AddObject(Constants.STORAGE_ITEM_NAME);
            Assert.That(container.ObjectExists(Constants.STORAGE_ITEM_NAME), Is.True);
            container.AddObject(Constants.HEAD_STORAGE_ITEM_NAME);
            Assert.That(container.ObjectExists(Constants.HEAD_STORAGE_ITEM_NAME), Is.True);

            string[] objectNames = container.GetObjectNames();
            Assert.That(objectNames.Length, Is.EqualTo(2));
            Assert.That(objectNames[0], Is.EqualTo(Constants.STORAGE_ITEM_NAME));
            Assert.That(objectNames[1], Is.EqualTo(Constants.HEAD_STORAGE_ITEM_NAME));

            Dictionary<GetItemListParameters, string> parameters = new Dictionary<GetItemListParameters, string>();
            parameters.Add(GetItemListParameters.Marker, "1");
            objectNames = container.GetObjectNames(parameters);
            Assert.That(objectNames.Length, Is.EqualTo(1));
            Assert.That(objectNames[0], Is.EqualTo(Constants.HEAD_STORAGE_ITEM_NAME));
        }
Exemplo n.º 15
0
        public void should_return_only_objects_beginning_with_the_provided_substring()
        {
            var container = new MockCFContainer("testcontainername");
            container.AddObject(Constants.STORAGE_ITEM_NAME);
            Assert.That(container.ObjectExists(Constants.STORAGE_ITEM_NAME), Is.True);
            container.AddObject(Constants.HEAD_STORAGE_ITEM_NAME);
            Assert.That(container.ObjectExists(Constants.HEAD_STORAGE_ITEM_NAME), Is.True);

            string[] objectNames = container.GetObjectNames();
            Assert.That(objectNames.Length, Is.EqualTo(2));
            Assert.That(objectNames[0], Is.EqualTo(Constants.STORAGE_ITEM_NAME));
            Assert.That(objectNames[1], Is.EqualTo(Constants.HEAD_STORAGE_ITEM_NAME));

            Dictionary<GetItemListParameters, string> parameters = new Dictionary<GetItemListParameters, string>();
            parameters.Add(GetItemListParameters.Prefix, "h");
            objectNames = container.GetObjectNames(parameters);
            Assert.That(objectNames.Length, Is.EqualTo(1));
            Assert.That(objectNames[0], Is.EqualTo(Constants.HEAD_STORAGE_ITEM_NAME));

            parameters.Clear();
            parameters.Add(GetItemListParameters.Prefix, "t");
            objectNames = container.GetObjectNames(parameters);
            Assert.That(objectNames.Length, Is.EqualTo(1));
            Assert.That(objectNames[0], Is.EqualTo(Constants.STORAGE_ITEM_NAME));
        }
Exemplo n.º 16
0
 public void should_add_the_object()
 {
     var container = new MockCFContainer("testcontainername");
     container.AddObject(Constants.STORAGE_ITEM_NAME);
     Assert.That(container.ObjectExists(Constants.STORAGE_ITEM_NAME), Is.True);
     string[] objectNames = container.GetObjectNames();
     Assert.That(objectNames[0], Is.EqualTo(Constants.STORAGE_ITEM_NAME));
 }
Exemplo n.º 17
0
 public void should_delete_the_object()
 {
     var container = new MockCFContainer("testcontainername");
     container.AddObject(Constants.STORAGE_ITEM_NAME);
     Assert.That(container.ObjectExists(Constants.STORAGE_ITEM_NAME), Is.True);
     container.DeleteObject(Constants.STORAGE_ITEM_NAME);
     Assert.That(container.ObjectExists(Constants.STORAGE_ITEM_NAME), Is.False);
 }
Exemplo n.º 18
0
        public void should_throw_storage_item_not_found_exception()
        {
            var container = new MockCFContainer("testcontainername");
            container.DeleteObject(Constants.STORAGE_ITEM_NAME);

            Assert.Fail("Allowed deletion of non-existant object");
        }
Exemplo n.º 19
0
        public void should_return_xml_document_with_xxxxx()
        {
            var container = new MockCFContainer("testcontainername");
            var expectedXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><container name=\"testcontainername\"></container>";

            Assert.That(container.XML.InnerXml, Is.EqualTo(expectedXml));
        }
Exemplo n.º 20
0
        public void should_give_the_object_public_url()
        {
            var container = new MockCFContainer("testcontainername");
            container.MarkAsPublic();
            var @object = container.AddObject(Constants.STORAGE_ITEM_NAME);

            Assert.That(@object.PublicUrl.ToString(), Is.EqualTo("http://tempuri.org/" + Constants.STORAGE_ITEM_NAME));
        }
Exemplo n.º 21
0
        public void should_return_xml_document_with_objects_names_and_hash_and_bytes_and_content_type_and_last_modified_date()
        {
            var container = new MockCFContainer("testcontainername");
            container.AddObject("object");
            var expectedXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><container name=\"testcontainername\"><object><name>object</name><hash>4281c348eaf83e70ddce0e07221c3d28</hash><bytes>14</bytes><content_type>application/octet-stream</content_type><last_modified>2009-02-03T05:26:32.612278</last_modified></object></container>";

            Assert.That(container.XML.InnerXml, Is.EqualTo(expectedXml));
        }
Exemplo n.º 22
0
        public void should_return_only_the_specified_number_of_objects()
        {
            var container = new MockCFContainer("testcontainername");
            container.AddObject(Constants.STORAGE_ITEM_NAME);
            Assert.That(container.ObjectExists(Constants.STORAGE_ITEM_NAME), Is.True);
            container.AddObject(Constants.HEAD_STORAGE_ITEM_NAME);
            Assert.That(container.ObjectExists(Constants.HEAD_STORAGE_ITEM_NAME), Is.True);

            string[] objectNames = container.GetObjectNames();
            Assert.That(objectNames.Length, Is.EqualTo(2));
            Assert.That(objectNames[0], Is.EqualTo(Constants.STORAGE_ITEM_NAME));
            Assert.That(objectNames[1], Is.EqualTo(Constants.HEAD_STORAGE_ITEM_NAME));

            var parameters = new Dictionary<GetItemListParameters, string>
            {{GetItemListParameters.Limit, "1"}};
            objectNames = container.GetObjectNames(parameters);
            Assert.That(objectNames.Length, Is.EqualTo(1));
            Assert.That(objectNames[0], Is.EqualTo(Constants.STORAGE_ITEM_NAME));
        }
Exemplo n.º 23
0
        public void Should_obtain_a_public_url()
        {
            var container = new MockCFContainer("testcontainername");
            container.MarkAsPublic();

            Assert.That(container.PublicUrl.ToString().Contains("http://tempuri.org"), Is.True);
        }
Exemplo n.º 24
0
 public void should_add_the_object()
 {
     var container = new MockCFContainer("testcontainername");
     container.AddObject(Constants.STORAGE_ITEM_NAME);
     Assert.That(container.ObjectExists(Constants.STORAGE_ITEM_NAME), Is.True);
     Assert.That(container.ObjectCount, Is.EqualTo(1));
     Assert.That(container.BytesUsed, Is.EqualTo(34));
 }