public void MSLISTSWS_S05_TC06_CheckOutFile_InvalidParameter()
{
// create a normal document Library and upload a file to SUT
string listTitle = TestSuiteHelper.GetUniqueListName();
int docLibraryTemplateId = (int)TemplateType.Document_Library;
TestSuiteHelper.CreateList(listTitle, docLibraryTemplateId);
// Upload the file to the document library
string absoluteFileUrl = this.sutControlAdapter.UploadFile(listTitle);
Site.Assert.IsTrue(
!string.IsNullOrEmpty(absoluteFileUrl),
"Upload file to the list {0} should be successful, the file path is [{1}]",
listTitle,
absoluteFileUrl);
#region Check out the added file with null pageUrl parameter, try to capture R406; R2305;
bool isSoapFaultExist = false;
string errorCode = string.Empty;
try
{
string nullPageUrl = null;
this.listwsInstance.CheckOutFile(nullPageUrl, bool.TrueString, string.Empty);
}
catch (SoapException soapEx)
{
isSoapFaultExist = true;
errorCode = TestSuiteHelper.GetErrorCode(soapEx);
}
// if there are a soap fault and the error code equal to the "0x82000001", capture R406
Site.CaptureRequirementIfIsTrue(
isSoapFaultExist && errorCode.Equals("0x82000001", StringComparison.OrdinalIgnoreCase),
406,
@"[In CheckOutFile operation]If the pageUrl is null the protocol server MUST return a SOAP fault with error code 0x82000001.");
#endregion
#region Check out the added file with pageUrl is empty string, and try to capture R407; R1663
isSoapFaultExist = false;
errorCode = string.Empty;
try
{
string emptyPageUrl = string.Empty;
this.listwsInstance.CheckOutFile(emptyPageUrl, bool.TrueString, string.Empty);
}
catch (SoapException soapEx)
{
isSoapFaultExist = true;
errorCode = TestSuiteHelper.GetErrorCode(soapEx);
}
// If there are a soap fault and the error code equal to the "0x82000001", capture R407
Site.CaptureRequirementIfIsTrue(
isSoapFaultExist && errorCode.Equals("0x82000001", StringComparison.OrdinalIgnoreCase),
407,
@"[In CheckOutFile operation] If the pageUrl is empty string, the protocol server MUST return a SOAP fault with error code 0x82000001.");
// If there are a soap fault and the error code equal to the "0x82000001", capture R1663
Site.CaptureRequirementIfIsTrue(
isSoapFaultExist && errorCode.Equals("0x82000001", StringComparison.OrdinalIgnoreCase),
1663,
@"[In CheckOutFile operation] [If the pageUrl is empty string, the protocol server MUST return a SOAP fault with error code 0x82000001.] This indicates that the pageUrl is an empty string.");
#endregion
#region Check out the added file with pageUrl setting to an invalid URL, try to capture MS-LISTSWS_R4081 MS-LISTSWS_R1664 and MS-LISTSWS_R4082
isSoapFaultExist = false;
string errorString = string.Empty;
errorCode = string.Empty;
try
{
string invalidPageUrl = "/";
this.listwsInstance.CheckOutFile(invalidPageUrl, bool.TrueString, string.Empty);
}
catch (SoapException soapEx)
{
isSoapFaultExist = true;
errorString = TestSuiteHelper.GetErrorString(soapEx);
errorCode = TestSuiteHelper.GetErrorCode(soapEx);
}
if (Common.IsRequirementEnabled(4081, this.Site))
{
// Add the debug information
this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-LISTSWS_R4081. SOAP fault {0}.", isSoapFaultExist ? "is returned with error string '" + errorString + "'" : "is not returned");
// Verify MS-LISTSWS requirement: MS-LISTSWS_R4081
bool isVerifiedR4081 = isSoapFaultExist && string.Equals(errorString, "Invalid URI: The format of the URI could not be determined.");
this.Site.CaptureRequirementIfIsTrue(
isVerifiedR4081,
4081,
@"[In CheckOutFile operation] [If the pageUrl is an invalid URL] Implementation does return a SOAP fault with error string ""Invalid URI: The format of the URI could not be determined."".(SharePoint Foundation 2010 and above follow this behavior.)");
// If there is no any error code in soap fault, capture MS-LISTSWS_R1664
this.Site.CaptureRequirementIfIsTrue(
string.IsNullOrEmpty(errorCode),
1664,
@"[In CheckOutFile operation] [If the pageUrl is an invalid URL, the protocol server SHOULD<34> return a SOAP fault with error string ""Invalid URI: The format of the URI could not be determined."". ]There is no error code for this fault.");
}
if (Common.IsRequirementEnabled(4082, this.Site))
{
this.Site.CaptureRequirementIfIsFalse(
isSoapFaultExist,
4082,
@"[In CheckOutFile operation] [If the pageUrl is an invalid URL] Implementation does not return a SOAP fault.(<34> Section 3.1.4.8: wss3 does not return a SOAP fault.)");
}
#endregion
#region Check out the added file with the checkoutToLocal parameter does not resolve to a valid Boolean string.Try to capture R410;R1666;
isSoapFaultExist = false;
errorCode = string.Empty;
try
{
// Get an invalid path
string invalidBoolValue = Guid.NewGuid().ToString("N");
this.listwsInstance.CheckOutFile(absoluteFileUrl, invalidBoolValue, string.Empty);
}
catch (SoapException soapEx)
{
isSoapFaultExist = true;
errorCode = TestSuiteHelper.GetErrorCode(soapEx);
}
// If there are a Soap fault, capture R410
Site.CaptureRequirementIfIsTrue(
isSoapFaultExist,
410,
@"[In CheckOutFile operation] If the checkoutToLocal parameter does not resolve to a valid Boolean string (case-insensitive equality to ""True"" or ""False"", ignoring leading and trailing white space), the protocol server MUST return a SOAP fault.");
// If there are a soap fault and no error code return in SoapFault, capture R1666
Site.CaptureRequirementIfIsTrue(
isSoapFaultExist && string.IsNullOrEmpty(errorCode),
1666,
@"[In CheckOutFile operation] [If the checkoutToLocal parameter does not resolve to a valid Boolean string (case-insensitive equality to ""True"" or ""False"", ignoring leading and trailing white space), the protocol server MUST return a SOAP fault.]There is no error code for this fault.");
#endregion
isSoapFaultExist = false;
errorCode = string.Empty;
try
{
// Get an invalid path
string invalidBoolValue = Guid.NewGuid().ToString("N");
this.listwsInstance.CheckOutFile(absoluteFileUrl, invalidBoolValue, string.Empty);
}
catch (SoapException soapEx)
{
isSoapFaultExist = true;
errorCode = TestSuiteHelper.GetErrorCode(soapEx);
}
#region Check out a file that have been checked out, if the CheckOutFile should return false, capture R2305;
bool ischeckOutSuccess = false;
ischeckOutSuccess = this.listwsInstance.CheckOutFile(absoluteFileUrl, bool.TrueString, string.Empty);
Site.Assert.IsTrue(ischeckOutSuccess, "The CheckOutFile operation must be successful in the first time.");
// Check out a file that have been checked out
ischeckOutSuccess = this.listwsInstance.CheckOutFile(absoluteFileUrl, bool.TrueString, string.Empty);
// if the second CheckOutFile operation return false, capture R2305
Site.CaptureRequirementIfIsFalse(
ischeckOutSuccess,
2305,
@"[CheckOutFileResponse][The value is True if the operation is successful; ]otherwise, False is returned");
#endregion
}