本文整理汇总了C#中TestHelper.PutItemInContainer方法的典型用法代码示例。如果您正苦于以下问题:C# TestHelper.PutItemInContainer方法的具体用法?C# TestHelper.PutItemInContainer怎么用?C# TestHelper.PutItemInContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestHelper
的用法示例。
在下文中一共展示了TestHelper.PutItemInContainer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Should_get_200_OK_or_204_No_Content_when_item_exists
public void Should_get_200_OK_or_204_No_Content_when_item_exists()
{
using (var testHelper = new TestHelper(authToken, storageUrl))
{
try
{
testHelper.PutItemInContainer(Constants.HeadStorageItemName);
testHelper.AddMetadataToItem(Constants.HeadStorageItemName);
var getStorageItemInformation = new GetStorageItemInformation(storageUrl, Constants.CONTAINER_NAME, Constants.HeadStorageItemName);
var getStorageItemInformationResponse = new GenerateRequestByType().Submit(
getStorageItemInformation, authToken);
Assert.That(getStorageItemInformationResponse.Status == HttpStatusCode.OK
|| getStorageItemInformationResponse.Status == HttpStatusCode.NoContent, Is.True);
var metadata = getStorageItemInformationResponse.Metadata;
Assert.That(metadata["Test"], Is.EqualTo("test"));
Assert.That(metadata["Test2"], Is.EqualTo("test2"));
}
finally
{
testHelper.DeleteItemFromContainer(Constants.HeadStorageItemName);
}
}
}
示例2: 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, authToken, Constants.CONTAINER_NAME, Constants.StorageItemName);
var response = new ResponseFactory<CloudFilesResponse>().Create(new CloudFilesRequest(deleteStorageItem));
Assert.That(response.Status, Is.EqualTo(HttpStatusCode.NoContent));
Assert.That(response.Headers["Content-Type"].Contains("text/plain"), Is.True);
}
}
示例3: 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));
Console.WriteLine(response.Headers["Content-Type"]);
Assert.That(Regex.Match(response.Headers["Content-Type"], "text/(plain|html)").Success, Is.True);
}
}
示例4: Should_return_no_content_when_the_container_exists
public void Should_return_no_content_when_the_container_exists()
{
using (var testHelper = new TestHelper(authToken, storageUrl))
{
testHelper.PutItemInContainer(Constants.StorageItemName, Constants.StorageItemName);
var getContainerInformation = new GetContainerInformation(storageUrl, Constants.CONTAINER_NAME);
var informationResponse = new GenerateRequestByType().Submit(getContainerInformation, authToken);
Assert.That(informationResponse.Status, Is.EqualTo(HttpStatusCode.NoContent));
Assert.That(informationResponse.Headers[Constants.XContainerObjectCount], Is.EqualTo("1"));
Assert.That(informationResponse.Headers[Constants.XContainerBytesUsed], (Is.Not.Null));
testHelper.DeleteItemFromContainer(Constants.StorageItemName);
}
}
示例5: 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();
}
示例6: 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);
}
}
示例7: 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, authToken, Constants.CONTAINER_NAME, Constants.StorageItemName, metadata);
var metaInformationResponse = new ResponseFactory<CloudFilesResponse>().Create(new CloudFilesRequest(setStorageItemMetaInformation));
Assert.That(metaInformationResponse.Status, Is.EqualTo(HttpStatusCode.Accepted));
testHelper.DeleteItemFromContainer();
}
}
示例8: Should_return_ok_if_the_item_exists
public void Should_return_ok_if_the_item_exists()
{
using (var testHelper = new TestHelper(authToken, storageUrl))
{
ICloudFilesResponse getStorageItemResponse = null;
try
{
testHelper.PutItemInContainer();
var getStorageItem = new GetStorageItem(storageUrl, Constants.CONTAINER_NAME, Constants.StorageItemName, requestHeaderFields);
getStorageItemResponse = new GenerateRequestByType().Submit(getStorageItem, authToken);
Assert.That(getStorageItemResponse.Status, Is.EqualTo(HttpStatusCode.OK));
}
finally
{
if (getStorageItemResponse != null) getStorageItemResponse.Dispose();
testHelper.DeleteItemFromContainer();
}
}
}
示例9: should_return_number_of_containers_and_bytes_used
public void should_return_number_of_containers_and_bytes_used()
{
try
{
connection.CreateContainer(Constants.CONTAINER_NAME);
connection.PutStorageItem(Constants.CONTAINER_NAME, Constants.StorageItemName);
}
finally
{
connection.DeleteStorageItem(Constants.CONTAINER_NAME, Constants.StorageItemName);
connection.DeleteContainer(Constants.CONTAINER_NAME);
}
using (TestHelper testHelper = new TestHelper(authToken, storageUrl))
{
testHelper.PutItemInContainer(Constants.StorageItemName, Constants.StorageItemName);
GetAccountInformation getAccountInformation = new GetAccountInformation(storageUrl, authToken);
var response = new ResponseFactory<CloudFilesResponse>().Create(new CloudFilesRequest(getAccountInformation));
Assert.That(response.Headers[Constants.XAccountBytesUsed], Is.Not.Null);
Assert.That(response.Headers[Constants.XAccountContainerCount], Is.Not.Null);
testHelper.DeleteItemFromContainer(Constants.StorageItemName);
}
}
示例10: Should_get_204_No_Content_when_item_exists
public void Should_get_204_No_Content_when_item_exists()
{
using (TestHelper testHelper = new TestHelper(authToken, storageUrl))
{
try
{
testHelper.PutItemInContainer(Constants.HeadStorageItemName);
testHelper.AddMetadataToItem(Constants.HeadStorageItemName);
var getStorageItemInformation = new GetStorageItemInformation(storageUrl, authToken, Constants.CONTAINER_NAME, Constants.HeadStorageItemName);
var getStorageItemInformationResponse = new ResponseFactory<CloudFilesResponse>().Create(new CloudFilesRequest(getStorageItemInformation));
Assert.That(getStorageItemInformationResponse.Status, Is.EqualTo(HttpStatusCode.NoContent));
var metadata = getStorageItemInformationResponse.Metadata;
Assert.That(metadata["Test"], Is.EqualTo("test"));
Assert.That(metadata["Test2"], Is.EqualTo("test2"));
}
finally
{
testHelper.DeleteItemFromContainer(Constants.HeadStorageItemName);
}
}
}
示例11: Should_return_item_if_the_item_exists_and_has_been_modified_since_designated_time
public void Should_return_item_if_the_item_exists_and_has_been_modified_since_designated_time()
{
requestHeaderFields = new Dictionary<RequestHeaderFields, string>
{{RequestHeaderFields.IfModifiedSince, pastDateTime.ToString()}};
using (var testHelper = new TestHelper(authToken, storageUrl))
{
ICloudFilesResponse getStorageItemResponse = null;
try
{
testHelper.PutItemInContainer();
var getStorageItem = new GetStorageItem(storageUrl, Constants.CONTAINER_NAME, Constants.StorageItemName, requestHeaderFields);
getStorageItemResponse = new GenerateRequestByType().Submit(getStorageItem, authToken);
Assert.That(getStorageItemResponse.Status, Is.EqualTo(HttpStatusCode.OK));
}
finally
{
if (getStorageItemResponse != null) getStorageItemResponse.Dispose();
testHelper.DeleteItemFromContainer();
}
}
}
示例12: Should_return_412_precondition_failed_if_the_item_exists_and_has_been_modified_since_designated_time
public void Should_return_412_precondition_failed_if_the_item_exists_and_has_been_modified_since_designated_time()
{
requestHeaderFields = new Dictionary<RequestHeaderFields, string>
{{RequestHeaderFields.IfUnmodifiedSince, pastDateTime.ToString()}};
using (var testHelper = new TestHelper(authToken, storageUrl))
{
ICloudFilesResponse getStorageItemResponse = null;
var exceptionWasThrown = false;
try
{
testHelper.PutItemInContainer();
testHelper.PutItemInContainer();
var getStorageItem = new GetStorageItem(storageUrl, Constants.CONTAINER_NAME, Constants.StorageItemName, requestHeaderFields);
getStorageItemResponse = new GenerateRequestByType().Submit(getStorageItem, authToken);
Assert.That(getStorageItemResponse.Status, Is.EqualTo(HttpStatusCode.OK));
}
catch (WebException ex)
{
var response = (HttpWebResponse)ex.Response;
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.PreconditionFailed));
exceptionWasThrown = true;
}
finally
{
if (getStorageItemResponse != null) getStorageItemResponse.Dispose();
testHelper.DeleteItemFromContainer();
}
Assert.That(exceptionWasThrown, Is.True);
}
}
示例13: Should_return_ten_objects_when_setting_the_limit_to_ten
public void Should_return_ten_objects_when_setting_the_limit_to_ten()
{
using (var testHelper = new TestHelper(authToken, storageUrl))
{
for (var i = 0; i < 12; ++i)
testHelper.PutItemInContainer(Constants.StorageItemName, i.ToString());
var parameters = new Dictionary<GetItemListParameters, string>
{{GetItemListParameters.Limit, "10"}};
var getContainerItemsRequest = new GetContainerItemList(storageUrl, Constants.CONTAINER_NAME, parameters);
var response = new GenerateRequestByType().Submit(getContainerItemsRequest, authToken);
for (var i = 0; i < 12; ++i)
testHelper.DeleteItemFromContainer(i.ToString());
Assert.That(response.Status, Is.EqualTo(HttpStatusCode.OK));
Assert.That(response.ContentBody.Count, Is.EqualTo(10));
response.Dispose();
}
}
示例14: Should_return_specific_files_under_a_directory_when_passed_a_top_directory
public void Should_return_specific_files_under_a_directory_when_passed_a_top_directory()
{
using (var testHelper = new TestHelper(authToken, storageUrl))
{
for (var i = 0; i < 12; ++i)
{
if(i % 3 == 0)
{
testHelper.PutItemInContainer(Constants.StorageItemName, "topdir1/subdir2/" + i + "file");
continue;
}
testHelper.PutItemInContainer(Constants.StorageItemName, "topdir1/" + i + "file");
}
var parameters = new Dictionary<GetItemListParameters, string> { { GetItemListParameters.Path, "topdir1" } };
var getContainerItemsRequest = new GetContainerItemList(storageUrl,
Constants.CONTAINER_NAME, parameters);
// getContainerItemsRequest.UserAgent = Constants.USER_AGENT;
var response = new GenerateRequestByType().Submit(getContainerItemsRequest, authToken);
for (var i = 0; i < 12; ++i)
{
if (i % 3 == 0)
{
testHelper.DeleteItemFromContainer("topdir1/subdir2/" + i + "file");
continue;
}
testHelper.DeleteItemFromContainer("topdir1/" + i + "file");
}
Assert.That(response.Status, Is.EqualTo(HttpStatusCode.OK));
Assert.That(response.ContentBody.Count, Is.EqualTo(8));
Assert.That(response.ContentBody[0], Is.EqualTo("topdir1/10file"));
Assert.That(response.ContentBody[1], Is.EqualTo("topdir1/11file"));
Assert.That(response.ContentBody[2], Is.EqualTo("topdir1/1file"));
Assert.That(response.ContentBody[3], Is.EqualTo("topdir1/2file"));
Assert.That(response.ContentBody[4], Is.EqualTo("topdir1/4file"));
Assert.That(response.ContentBody[5], Is.EqualTo("topdir1/5file"));
Assert.That(response.ContentBody[6], Is.EqualTo("topdir1/7file"));
Assert.That(response.ContentBody[7], Is.EqualTo("topdir1/8file"));
response.Dispose();
}
}
示例15: Should_return_objects_starting_with_2_when_setting_prefix_as_2
public void Should_return_objects_starting_with_2_when_setting_prefix_as_2()
{
using (var testHelper = new TestHelper(authToken, storageUrl))
{
for (var i = 0; i < 12; ++i)
testHelper.PutItemInContainer(Constants.StorageItemName, i.ToString());
var parameters = new Dictionary<GetItemListParameters, string>
{{GetItemListParameters.Prefix, "2"}};
var getContainerItemsRequest = new GetContainerItemList(storageUrl, Constants.CONTAINER_NAME, parameters);
// getContainerItemsRequest.UserAgent = Constants.USER_AGENT;
var response = new GenerateRequestByType().Submit(getContainerItemsRequest, authToken);
for (var i = 0; i < 12; ++i)
testHelper.DeleteItemFromContainer(i.ToString());
Assert.That(response.Status, Is.EqualTo(HttpStatusCode.OK));
Assert.That(response.ContentBody.Count, Is.EqualTo(1));
Assert.That(response.ContentBody[0], Is.EqualTo("2"));
response.Dispose();
}
}