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_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_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_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_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_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<GetListParameters, string>
            {{GetListParameters.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(GetListParameters.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_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_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));

            var parameters = new Dictionary<GetListParameters, string>
            {{GetListParameters.Marker, "1"}};
            objectNames = container.GetObjectNames(parameters);
            Assert.That(objectNames.Length, Is.EqualTo(1));
            Assert.That(objectNames[0], Is.EqualTo(Constants.HEAD_STORAGE_ITEM_NAME));
        }
 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_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);
 }
        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);
     Assert.That(container.ObjectCount, Is.EqualTo(1));
     Assert.That(container.BytesUsed, Is.EqualTo(34));
 }