public void MSLISTSWS_S01_TC02_AddListFromFeature_EmptyFeatureID()
{
string listName = TestSuiteHelper.GetUniqueListName();
string newListName = TestSuiteHelper.GetUniqueListName();
string errorCode = string.Empty;
bool addListSucceeded = false;
bool addUnmatchTemplateIDSucceeded = false;
bool addFeatureSucceeded = false;
bool addListWithExistentNameSucceeded = false;
bool isExistentFaultFirst = false;
bool isExistentFaultSecond = false;
int templateId = (int)TemplateType.Generic_List;
try
{
// Add a list with empty featureID.
try
{
string emptyFeatureID = string.Empty;
AddListFromFeatureResponseAddListFromFeatureResult result = this.listswsAdapter.AddListFromFeature(listName, string.Empty, emptyFeatureID, templateId);
addListSucceeded = result != null && result.List != null && !string.IsNullOrEmpty(result.List.ID);
}
catch (SoapException exp)
{
errorCode = TestSuiteHelper.GetErrorCode(exp);
isExistentFaultFirst = true;
}
this.Site.Assert.IsTrue(isExistentFaultFirst, "The server response should contain the SOAP fault during the AddList operation when the feature id is empty.");
Site.CaptureRequirementIfIsFalse(
addListSucceeded,
360,
@"[In AddListFromFeature operation] If the featureID tag is specified and the value is not a GUID or empty, the protocol server MUST return a SOAP fault.");
Site.CaptureRequirementIfIsNull(
errorCode,
1604,
@"[In AddListFromFeature operation] [If the featureID tag is specified and the value is not a GUID or empty, the protocol server MUST return a SOAP fault.]There is no error code returned for this fault.");
try
{
// Add a list with unmatched featureID and templateID
int unmatchTemplateId = (int)TemplateType.Grid;
AddListFromFeatureResponseAddListFromFeatureResult addResult = this.listswsAdapter.AddListFromFeature(
newListName,
string.Empty,
Common.GetConfigurationPropertyValue("ListFeatureId", this.Site),
unmatchTemplateId);
addUnmatchTemplateIDSucceeded = addResult != null && addResult.List != null && !string.IsNullOrEmpty(addResult.List.ID);
}
catch (SoapException exp)
{
errorCode = TestSuiteHelper.GetErrorCode(exp);
isExistentFaultSecond = true;
}
this.Site.Assert.IsTrue(isExistentFaultSecond, "The server response does not contain the SOAP fault during the AddList operation when the template id is not valid.");
// If the error code is 0x81072101, then capture R1605 and R1606.
Site.CaptureRequirementIfAreEqual<string>(
"0x81072101",
errorCode,
1605,
@"[AddListFromFeature]If the provided templateID cannot be used with the provided featureID, the protocol server MUST return a SOAP fault with error code 0x81072101");
Site.CaptureRequirementIfAreEqual<string>(
"0x81072101",
errorCode,
1606,
@"[AddListFromFeature] [If the provided templateID cannot be used with the provided featureID, the protocol server MUST return a SOAP fault with error code 0x81072101] This indicates that the SOAP protocol failed to add a list.");
// Add a list with correct value.
try
{
AddListFromFeatureResponseAddListFromFeatureResult addFeatureListResult = this.listswsAdapter.AddListFromFeature(
listName,
null,
Common.GetConfigurationPropertyValue("ListFeatureId", this.Site),
templateId);
addFeatureSucceeded = addFeatureListResult != null && addFeatureListResult.List != null && !string.IsNullOrEmpty(addFeatureListResult.List.ID);
}
catch (SoapException)
{
this.Site.Assert.Fail("Test suite should add the list successfully.");
}
bool isExistentFaultThird = false;
try
{
// Add a list with the listName that already exist.
AddListFromFeatureResponseAddListFromFeatureResult addFeatureResult = this.listswsAdapter.AddListFromFeature(listName, null, null, templateId);
addListWithExistentNameSucceeded = addFeatureResult != null && addFeatureResult.List != null && !string.IsNullOrEmpty(addFeatureResult.List.ID);
}
catch (SoapException exp)
{
errorCode = TestSuiteHelper.GetErrorCode(exp);
isExistentFaultThird = true;
}
this.Site.Assert.IsTrue(isExistentFaultThird, "The server response should contain the SOAP fault when the listName is used by another list.");
// If the error code is 0x81020012, then capture R365 and R1608.
Site.CaptureRequirementIfAreEqual<string>(
"0x81020012",
errorCode,
365,
@"[In AddListFromFeature] If the listName is already used by another list then the protocol server MUST return a SOAP fault with error code 0x81020012.");
Site.CaptureRequirementIfAreEqual<string>(
"0x81020012",
errorCode,
1608,
@"[In AddListFromFeature] [If the listName is already used by another list then the protocol server MUST return a SOAP fault with error code 0x81020012.] This indicates that another list has the specified listName.");
}
finally
{
if (addListSucceeded || addFeatureSucceeded || addListWithExistentNameSucceeded)
{
this.listswsAdapter.DeleteList(listName);
}
if (addUnmatchTemplateIDSucceeded)
{
this.listswsAdapter.DeleteList(newListName);
}
}
}