public void MSLISTSWS_S04_TC10_DeleteAttachment_Succeed()
{
#region Add a list and add a list item
string uniqueListName = TestSuiteHelper.GetUniqueListName();
string listId = TestSuiteHelper.CreateList(uniqueListName);
// add one item, if not successful or added number not equal to the specified, fail the test case.
List<string> listitemIds = TestSuiteHelper.AddListItems(listId, 1);
#endregion
// Add an attachment using valid GUID as listName parameter.
string attachmentFileName = Common.GetConfigurationPropertyValue("AttachmentName", this.Site);
byte[] attachmentData = TestSuiteHelper.GetAttachmentContent(attachmentFileName);
string addedListitemId = listitemIds[0];
#region Add an attachment
// call AddAttachment operation to add an attachment to the added list item.
string attachmentUrl = this.listswsAdapterInstance.AddAttachment(
listId,
addedListitemId,
attachmentFileName,
attachmentData);
this.Site.Assert.IsTrue(
attachmentUrl.IndexOf(attachmentFileName, StringComparison.OrdinalIgnoreCase) > 0,
"Add an attachment into the list item should be successful.");
#endregion
#region Invoke DeleteAttachment and capture requirements
// Delete the attachment with valid GUID as listName parameter.
string fullUrlOfAttachment = TestSuiteHelper.GetAttachmentFullUrl(listId, addedListitemId, attachmentFileName);
this.listswsAdapterInstance.DeleteAttachment(listId, addedListitemId, fullUrlOfAttachment);
// Call GetAttachmentCollection to verify delete successfully or not.
GetAttachmentCollectionResponseGetAttachmentCollectionResult getAttachmenResult = null;
getAttachmenResult = this.listswsAdapterInstance.GetAttachmentCollection(listId, addedListitemId);
if (null == getAttachmenResult || null == getAttachmenResult.Attachments)
{
this.Site.Assert.Fail("Could not Get the valid response of GetAttachmentCollection operation");
}
// Capture R466, R473 and R478 if the DeleteAttachment succeeds.
Site.CaptureRequirementIfAreEqual<int>(
0,
getAttachmenResult.Attachments.Length,
466,
@"[In DeleteAttachment operation] If the specified listName is a valid GUID and corresponds to the identification of a list on the site, use that list.");
Site.CaptureRequirementIfAreEqual<int>(
0,
getAttachmenResult.Attachments.Length,
473,
@"[In DeleteAttachment operation] If the protocol client calls the operation by passing valid input parameters, the protocol server MUST delete the attachment associated with the specified list item in the specified list.");
Site.CaptureRequirementIfAreEqual<int>(
0,
getAttachmenResult.Attachments.Length,
478,
@"[In DeleteAttachment operation] If the operation succeeds, the attachment MUST be deleted.");
// Add an attachment.
List<string> listitemIdsOfsecond = TestSuiteHelper.AddListItems(listId, 1);
string secondListitemId = listitemIdsOfsecond[0];
attachmentUrl = string.Empty;
attachmentUrl = this.listswsAdapterInstance.AddAttachment(
listId,
secondListitemId,
attachmentFileName,
attachmentData);
this.Site.Assert.IsTrue(
!string.IsNullOrEmpty(attachmentUrl)
&& attachmentUrl.IndexOf(attachmentFileName, StringComparison.OrdinalIgnoreCase) > 0,
"Add an attachment into the list item should be successful.");
// Delete the attachment with valid list title as listName parameter.
fullUrlOfAttachment = string.Empty;
fullUrlOfAttachment = TestSuiteHelper.GetAttachmentFullUrl(listId, secondListitemId, attachmentFileName);
this.listswsAdapterInstance.DeleteAttachment(uniqueListName, secondListitemId, fullUrlOfAttachment);
// Call GetAttachmentCollection to verify delete successfully or not.
getAttachmenResult = null;
getAttachmenResult = this.listswsAdapterInstance.GetAttachmentCollection(listId, secondListitemId);
if (null == getAttachmenResult || null == getAttachmenResult.Attachments)
{
this.Site.Assert.Fail("Could Not Get the valid response of GetAttachmentCollection operation");
}
// Capture R467 and R468 if the DeleteAttachment succeeds.
Site.CaptureRequirementIfAreEqual<int>(
0,
getAttachmenResult.Attachments.Length,
467,
@"[In DeleteAttachment operation] If the specified listName is not a valid GUID, check if the listName corresponds to the list title of a list on the site and if so, use that list.");
Site.CaptureRequirementIfAreEqual<int>(
0,
getAttachmenResult.Attachments.Length,
468,
@"[In DeleteAttachment operation] If the specified listName does not correspond to the identification of a list on the site, check if the listName corresponds to the list title of a list on the site and if so, use that list.");
#endregion
}