当前位置: 首页>>代码示例>>C#>>正文


C# request.GenerateRequestByType类代码示例

本文整理汇总了C#中com.mosso.cloudfiles.domain.request.GenerateRequestByType的典型用法代码示例。如果您正苦于以下问题:C# GenerateRequestByType类的具体用法?C# GenerateRequestByType怎么用?C# GenerateRequestByType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GenerateRequestByType类属于com.mosso.cloudfiles.domain.request命名空间,在下文中一共展示了GenerateRequestByType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: should_be_able_to_return_stream_more_than_once

        public void should_be_able_to_return_stream_more_than_once()
        {
            ICloudFilesResponse getStorageItemResponse = null;
            Stream stream = null;
            Stream streamcopy = null;
            try
            {
                connection.CreateContainer(Constants.CONTAINER_NAME);
                connection.PutStorageItem(Constants.CONTAINER_NAME, Constants.StorageItemName);

                var getStorageItem = new GetStorageItem(storageUrl, Constants.CONTAINER_NAME, Constants.StorageItemName);

                getStorageItemResponse = new GenerateRequestByType().Submit(getStorageItem, authToken);
                stream = getStorageItemResponse.GetResponseStream();
                streamcopy = getStorageItemResponse.GetResponseStream();
                Assert.AreEqual(stream.Length, streamcopy.Length);
                Assert.Greater(getStorageItemResponse.ContentLength, 0);
                Assert.IsTrue(stream.CanRead);
                Assert.IsTrue(streamcopy.CanRead);
            }
            finally
            {
                if (getStorageItemResponse != null) getStorageItemResponse.Close();
                if (stream != null) stream.Close();
                if (streamcopy != null) streamcopy.Close();
                connection.DeleteStorageItem(Constants.CONTAINER_NAME, Constants.StorageItemName);
                connection.DeleteContainer(Constants.CONTAINER_NAME);
            }
        }
开发者ID:nzeyimana,项目名称:csharp-cloudfiles,代码行数:29,代码来源:CloudFileResponseSpec.cs

示例2: Should_return_no_content_when_the_container_exists

 public void Should_return_no_content_when_the_container_exists()
 {
     PutContainer(storageUrl, Constants.CONTAINER_NAME);
     var deleteContainer = new DeleteContainer(storageUrl, Constants.CONTAINER_NAME);
     var response = new GenerateRequestByType().Submit(deleteContainer, authToken);
     Assert.That(response.Status, Is.EqualTo(HttpStatusCode.NoContent));
 }
开发者ID:bhowerton,项目名称:csharp-cloudfiles,代码行数:7,代码来源:DeleteContainerSpecs.cs

示例3: Should_return_conflict_status_when_the_container_exists_and_is_not_empty

        public void Should_return_conflict_status_when_the_container_exists_and_is_not_empty()
        {
            try
            {
                using (new TestHelper(authToken, storageUrl))
                {
                    var putStorageItem = new PutStorageItem(storageUrl, Constants.CONTAINER_NAME, Constants.StorageItemName, Constants.StorageItemName);

                 //   Assert.That(putStorageItem.ContentLength, Is.GreaterThan(0));

                  var putStorageItemResponse=  new GenerateRequestByType().Submit(putStorageItem, authToken);
                    Assert.That(putStorageItemResponse.Status, Is.EqualTo(HttpStatusCode.Created));
                }
                Assert.Fail("409 conflict expected");
            }
            catch (WebException we)
            {
                var response = (HttpWebResponse)we.Response;
                Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.Conflict));
            }
            finally
            {
                var genrequest = new GenerateRequestByType();
                  genrequest.Submit( new DeleteStorageItem(storageUrl, Constants.CONTAINER_NAME, Constants.StorageItemName),authToken);
                genrequest.Submit(new DeleteContainer(storageUrl, Constants.CONTAINER_NAME), authToken);
            }
        }
开发者ID:bhowerton,项目名称:csharp-cloudfiles,代码行数:27,代码来源:DeleteContainerSpecs.cs

示例4: should_not_throw_an_exception_when_the_container_name_starts_with_pound

        public void should_not_throw_an_exception_when_the_container_name_starts_with_pound()
        {
            var getContainerItemList = new GetContainerItemList(storageUrl, "#container");

            var response = new GenerateRequestByType().Submit(getContainerItemList, authToken);
            response.Dispose();
            Assert.That(true);
        }
开发者ID:nzeyimana,项目名称:csharp-cloudfiles,代码行数:8,代码来源:GetContainerItemListSpecs.cs

示例5: Should_return_created_status_when_the_container_does_not_exist

        public void Should_return_created_status_when_the_container_does_not_exist()
        {
            CreateContainer createContainer = new CreateContainer(storageUrl, Constants.CONTAINER_NAME);

            IResponse response = new GenerateRequestByType( ).Submit(createContainer, authToken);
            Assert.That(response.Status, Is.EqualTo(HttpStatusCode.Created));

            DeleteContainer(storageUrl, Constants.CONTAINER_NAME);
        }
开发者ID:nzeyimana,项目名称:csharp-cloudfiles,代码行数:9,代码来源:PutContainerSpecs.cs

示例6: AddMetadataToItem

 public void AddMetadataToItem(string storageItemName)
 {
     var metadata = new Dictionary<string, string> {{"Test", "test"}, {"Test2", "test2"}};
     var setStorageItemMetaInformation = new SetStorageItemMetaInformation(storageUrl, containerName, storageItemName, metadata);
     var postStorageItemResponse = new GenerateRequestByType().Submit(setStorageItemMetaInformation, authToken);
     Assert.That(postStorageItemResponse.Status, Is.EqualTo(HttpStatusCode.Accepted));
     Assert.That(postStorageItemResponse.Headers["Content-Type"].Contains("text/plain"), Is.True);
     Assert.That(postStorageItemResponse.Headers["Content-Length"], Is.EqualTo("0"));
 }
开发者ID:asw,项目名称:csharp-cloudfiles,代码行数:9,代码来源:TestHelper.cs

示例7: Should_return_created_when_a_stream_is_passed_instead_of_a_file_name

 public void Should_return_created_when_a_stream_is_passed_instead_of_a_file_name()
 {
     using (var testHelper = new TestHelper(authToken, storageUrl))
     {
         var fs = new FileStream(Constants.StorageItemName, FileMode.Open, FileAccess.Read);
         var putStorageItem = new PutStorageItem(storageUrl, Constants.CONTAINER_NAME, Constants.StorageItemName, fs, null);
         var response = new GenerateRequestByType().Submit(putStorageItem, authToken);
         fs.Close();
         Assert.That(response.Status, Is.EqualTo(HttpStatusCode.Created));
         testHelper.DeleteItemFromContainer();
     }
 }
开发者ID:bhowerton,项目名称:csharp-cloudfiles,代码行数:12,代码来源:PutStorageItemSpecs.cs

示例8: should_not_throw_an_exception_when_the_container_contains_utf8_characters_3

        public void should_not_throw_an_exception_when_the_container_contains_utf8_characters_3()
        {
            var containerName = '\uDCFF' + "container";
            var getContainerItemList = new GetContainerItemList(storageUrl,  containerName);

            var response = new GenerateRequestByType().Submit(getContainerItemList, authToken);

            response.Dispose();
            foreach (string s in response.ContentBody)
                Console.WriteLine(s);
            Assert.That(true);
        }
开发者ID:nzeyimana,项目名称:csharp-cloudfiles,代码行数:12,代码来源:GetContainerItemListSpecs.cs

示例9: should_return_204_no_content_when_the_item_exists

        public void should_return_204_no_content_when_the_item_exists()
        {
            using (TestHelper testHelper = new TestHelper(authToken, storageUrl))
            {
                testHelper.PutItemInContainer();

                var deleteStorageItem = new DeleteStorageItem(storageUrl, Constants.CONTAINER_NAME, Constants.StorageItemName);
                var response = new GenerateRequestByType().Submit(deleteStorageItem,authToken );

                Assert.That(response.Status, Is.EqualTo(HttpStatusCode.NoContent));
                Assert.That(response.Headers["Content-Type"].Contains("text/plain"), Is.True);
            }
        }
开发者ID:bhowerton,项目名称:csharp-cloudfiles,代码行数:13,代码来源:DeleteContainerItemSpecs.cs

示例10: Should_return_No_Content_status

        public void Should_return_No_Content_status()
        {
            Assert.Ignore("Is returning OK instead of NoContent, need to investigate - 7/14/2010");
            var request = new GetContainers(storageUrl);

            var response = new GenerateRequestByType(
                new RequestFactoryWithAgentSupport("NASTTestUserAgent")).Submit(request, authToken);

            Assert.That(response.Status, Is.EqualTo(HttpStatusCode.NoContent));
            if(response.ContentBody != null)
                Assert.That(response.ContentBody.Count, Is.EqualTo(0));
            response.Dispose();
        }
开发者ID:bhowerton,项目名称:csharp-cloudfiles,代码行数:13,代码来源:GetContainersSpecs.cs

示例11: Connection

        public Connection(UserCredentials userCreds)
        {
            _requestfactory = new GenerateRequestByType();
            callbackFuncs = new List<ProgressCallback>();
            Log.EnsureInitialized();
            AuthToken = "";
            StorageUrl = "";
            if (userCreds == null) throw new ArgumentNullException("userCredentials");

            _usercreds = userCreds;

            VerifyAuthentication();
        }
开发者ID:nzeyimana,项目名称:csharp-cloudfiles,代码行数:13,代码来源:Connection.cs

示例12: Should_return_created_as_status_when_the_file_does_not_already_exist

        public void Should_return_created_as_status_when_the_file_does_not_already_exist()
        {
            using (var testHelper = new TestHelper(authToken, storageUrl))
            {
                var putStorageItem = new PutStorageItem(storageUrl, Constants.CONTAINER_NAME, Constants.StorageItemName, Constants.StorageItemName);

               // Assert.That(putStorageItem.ContentLength, Is.EqualTo(34)); //does not belong in this test

                var response = new GenerateRequestByType().Submit(putStorageItem, authToken);
                Assert.That(response.Status, Is.EqualTo(HttpStatusCode.Created));
                Assert.That(response.Headers[Constants.ETAG], Is.EqualTo(response.ETag));
                testHelper.DeleteItemFromContainer();
            }
        }
开发者ID:bhowerton,项目名称:csharp-cloudfiles,代码行数:14,代码来源:PutStorageItemSpecs.cs

示例13: Should_get_serialized_json_format

        public void Should_get_serialized_json_format()
        {
            var testHelper = new TestHelper(authToken, storageUrl);
            testHelper.PutItemInContainer(Constants.StorageItemNameJpg);
            var getContainerInformation = new GetContainerInformationSerialized(storageUrl,  Constants.CONTAINER_NAME, Format.JSON);

            var jsonResponse = new GenerateRequestByType().Submit(getContainerInformation, authToken);
            Assert.That(jsonResponse.Status, Is.EqualTo(HttpStatusCode.OK));
            var jsonReturnValue = String.Join("", jsonResponse.ContentBody.ToArray());
            jsonResponse.Dispose();
            var expectedSubString = "[{\"name\":[ ]?\"" + Constants.StorageItemNameJpg + "\",[ ]?\"hash\":[ ]?\"b44a59383b3123a747d139bd0e71d2df\",[ ]?\"bytes\":[ ]?\\d+,[ ]?\"content_type\":[ ]?\"image.*jpeg\",[ ]?\"last_modified\":[ ]?\"" + String.Format("{0:yyyy-MM}", DateTime.Now);

            Assert.That(Regex.Match(jsonReturnValue, expectedSubString).Success, Is.True);
            testHelper.DeleteItemFromContainer(Constants.StorageItemNameJpg);
            testHelper.Dispose();
        }
开发者ID:bhowerton,项目名称:csharp-cloudfiles,代码行数:16,代码来源:GetContainerInformationSpecs.cs

示例14: Should_get_serialized_xml_format

        public void Should_get_serialized_xml_format()
        {
            using (var testHelper = new TestHelper(authToken, storageUrl))
            {
                testHelper.PutItemInContainer(Constants.StorageItemNameJpg);
                var getContainerInformation = new GetContainerInformationSerialized(storageUrl,  Constants.CONTAINER_NAME, Format.XML);

                var xmlResponse = new GenerateRequestByType().Submit(getContainerInformation, authToken);
                Assert.That(xmlResponse.Status, Is.EqualTo(HttpStatusCode.OK));
                var xmlReturnValue = String.Join("", xmlResponse.ContentBody.ToArray());
                xmlResponse.Dispose();
                var expectedSubString = "<container name=\"" + Constants.CONTAINER_NAME + "\"><object><name>" + Constants.StorageItemNameJpg + "<\\/name><hash>b44a59383b3123a747d139bd0e71d2df<\\/hash><bytes>\\d+<\\/bytes><content_type>image.*jpeg<\\/content_type><last_modified>" + String.Format("{0:yyyy-MM}", DateTime.Now);

                Assert.That(Regex.Match(xmlReturnValue, expectedSubString).Success || string.IsNullOrEmpty(xmlReturnValue), Is.True);
                testHelper.DeleteItemFromContainer(Constants.StorageItemNameJpg);
            }
        }
开发者ID:bhowerton,项目名称:csharp-cloudfiles,代码行数:17,代码来源:GetContainerInformationSpecs.cs

示例15: Should_return_accepted_when_meta_information_is_supplied

        public void Should_return_accepted_when_meta_information_is_supplied()
        {
            using (TestHelper testHelper = new TestHelper(authToken, storageUrl))
            {
                testHelper.PutItemInContainer();

                Dictionary<string, string> metadata = new Dictionary<string, string>();
                metadata.Add("Test", "test");
                metadata.Add("Test2", "test2");

                SetStorageItemMetaInformation setStorageItemMetaInformation = new SetStorageItemMetaInformation(storageUrl, Constants.CONTAINER_NAME, Constants.StorageItemName, metadata);

                var metaInformationResponse = new GenerateRequestByType().Submit(setStorageItemMetaInformation, authToken);

                Assert.That(metaInformationResponse.Status, Is.EqualTo(HttpStatusCode.Accepted));
                testHelper.DeleteItemFromContainer();
            }
        }
开发者ID:nzeyimana,项目名称:csharp-cloudfiles,代码行数:18,代码来源:SetStorageItemMetaInformationSpecs.cs


注:本文中的com.mosso.cloudfiles.domain.request.GenerateRequestByType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。