本文整理汇总了C#中TestHelper.DeleteItemFromContainer方法的典型用法代码示例。如果您正苦于以下问题:C# TestHelper.DeleteItemFromContainer方法的具体用法?C# TestHelper.DeleteItemFromContainer怎么用?C# TestHelper.DeleteItemFromContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestHelper
的用法示例。
在下文中一共展示了TestHelper.DeleteItemFromContainer方法的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_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();
}
}
示例3: Should_return_created_when_content_type_is_not_supplied_because_it_is_optional
public void Should_return_created_when_content_type_is_not_supplied_because_it_is_optional()
{
using (TestHelper testHelper = new TestHelper(authToken, storageUrl))
{
var putStorageItem = new PutStorageItem(storageUrl, authToken, Constants.CONTAINER_NAME, Constants.StorageItemName, Constants.StorageItemName);
putStorageItem.Headers.Remove("Content-Type");
var response = new ResponseFactory<CloudFilesResponse>().Create(new CloudFilesRequest(putStorageItem));
Assert.That(response.Status, Is.EqualTo(HttpStatusCode.Created));
Assert.That(response.Headers[Constants.ETAG], Is.EqualTo(putStorageItem.ETag));
testHelper.DeleteItemFromContainer();
}
}
示例4: 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();
}
}
示例5: 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 (TestHelper testHelper = new TestHelper(authToken, storageUrl))
{
var putStorageItem = new PutStorageItem(storageUrl, authToken, Constants.CONTAINER_NAME, Constants.StorageItemName, Constants.StorageItemName);
Assert.That(putStorageItem.ContentLength, Is.EqualTo(34));
var response = new ResponseFactory<CloudFilesResponse>().Create(new CloudFilesRequest(putStorageItem));
Assert.That(response.Status, Is.EqualTo(HttpStatusCode.Created));
Assert.That(response.Headers[Constants.ETAG], Is.EqualTo(putStorageItem.ETag));
testHelper.DeleteItemFromContainer();
}
}
示例6: 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();
}
示例7: Should_return_created_when_content_length_is_not_supplied_because_it_is_optional
public void Should_return_created_when_content_length_is_not_supplied_because_it_is_optional()
{
using (var testHelper = new TestHelper(authToken, storageUrl))
{
var putStorageItem = new PutStorageItem(storageUrl, Constants.CONTAINER_NAME, Constants.StorageItemName, Constants.StorageItemName);
var uri = putStorageItem.CreateUri();
var request = new CloudFilesRequest(uri);
putStorageItem.Apply(request);
// request.ContentLength = 0;
request.Headers.Add("X-Auth-Token", HttpUtility.UrlEncode(authToken));
var response= request.GetResponse();
Assert.That(response.Status, Is.EqualTo(HttpStatusCode.Created));
Assert.That(response.Headers[Constants.ETAG], Is.EqualTo(request.ETag));
testHelper.DeleteItemFromContainer();
}
}
示例8: 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);
}
}
示例9: 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();
}
}
示例10: 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();
}
}
}
示例11: 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);
}
}
示例12: 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);
}
}
}
示例13: should_return_account_information_in_xml_format_including_name_count_and_size
public void should_return_account_information_in_xml_format_including_name_count_and_size()
{
using (TestHelper testHelper = new TestHelper(authToken, storageUrl))
{
try
{
testHelper.PutItemInContainer(Constants.StorageItemName);
var accountInformationXml = new GetAccountInformationSerialized(storageUrl, authToken, Format.XML);
var getAccountInformationXmlResponse = new ResponseFactoryWithContentBody<CloudFilesResponseWithContentBody>().Create(new CloudFilesRequest(accountInformationXml));
if (getAccountInformationXmlResponse.ContentBody.Count == 0)
Assert.Fail("No content body returned in response");
var contentBody = "";
foreach (var s in getAccountInformationXmlResponse.ContentBody)
{
contentBody += s;
}
getAccountInformationXmlResponse.Dispose();
var xmlDocument = new XmlDocument();
try
{
xmlDocument.LoadXml(contentBody);
}
catch(XmlException e)
{
Console.WriteLine(e.Message);
}
// Console.WriteLine(xmlDocument.InnerXml);
var expectedSubString = "<container><name>"+ Constants.CONTAINER_NAME +"</name><count>1</count><bytes>34</bytes></container>";
Assert.That(contentBody.IndexOf(expectedSubString) > 0, Is.True);
}
finally
{
testHelper.DeleteItemFromContainer();
}
}
}
示例14: Should_fail_when_an_invalid_paramter_is_passed
public void Should_fail_when_an_invalid_paramter_is_passed()
{
using (var testHelper = new TestHelper(authToken, storageUrl))
{
for (var i = 0; i < 12; ++i)
testHelper.PutItemInContainer(Constants.StorageItemName, i.ToString());
try
{
var parameters =
new Dictionary<GetItemListParameters, string> {{(GetItemListParameters) int.MaxValue, "2"}};
new GetContainerItemList(storageUrl, Constants.CONTAINER_NAME, parameters);
}
catch (NotImplementedException ne)
{
Assert.That(ne, Is.TypeOf(typeof (NotImplementedException)));
}
finally
{
for (var i = 0; i < 12; ++i)
testHelper.DeleteItemFromContainer(i.ToString());
}
}
}
示例15: should_return_account_information_in_json_format_including_name_count_and_bytes
public void should_return_account_information_in_json_format_including_name_count_and_bytes()
{
using (var testHelper = new TestHelper(authToken, storageUrl))
{
try
{
testHelper.PutItemInContainer(Constants.StorageItemName);
var getAccountInformationJson = new GetAccountInformationSerialized(storageUrl, Format.JSON);
var getAccountInformationJsonResponse = new GenerateRequestByType().Submit(getAccountInformationJson, authToken);
if(getAccountInformationJsonResponse.ContentBody.Count == 0)
Assert.Fail("No content body returned in response");
const string expectedSubString = "{\"name\":[ ]?\"" + Constants.CONTAINER_NAME + "\",[ ]?\"count\":[ ]?\\d+,[ ]?\"bytes\":[ ]?\\d+}";
var contentBody = getAccountInformationJsonResponse.ContentBody;
getAccountInformationJsonResponse.Dispose();
foreach (var s in contentBody)
{
if (Regex.Match(s, expectedSubString).Success) return;
}
Assert.Fail("Expected value: " + expectedSubString + " not found");
}
finally
{
testHelper.DeleteItemFromContainer();
}
}
}