public void MSLISTSWS_S02_TC48_GetListContentTypes_Succeed_WithListName()
{
#region Add a list
string listName = TestSuiteHelper.GetUniqueListName();
string listId = TestSuiteHelper.CreateList(listName);
bool isListCreatedSuccessful = !string.IsNullOrEmpty(listId);
this.Site.Assert.IsTrue(isListCreatedSuccessful, "Creating list successfully.");
#endregion Add a list
#region CreateContentType
string displayName = TestSuiteHelper.GetUniqueContentTypeName();
// This field has been added into current list.
string fieldName = Common.GetConfigurationPropertyValue("ListFieldText", this.Site);
List<string> fields = new List<string> { fieldName };
string contentTypeId = TestSuiteHelper.CreateContentType(listId, displayName, fields);
this.Site.Assert.IsTrue(!string.IsNullOrEmpty(contentTypeId), "CreateContentType successfully.");
#endregion CreateContentType
#region GetListContentTypes
GetListContentTypesResponseGetListContentTypesResult listContentTypes = this.listswsAdapter.GetListContentTypes(listName, string.Empty);
this.Site.Assert.IsNotNull(listContentTypes, "Calling GetListContentTypes successfully.");
if (Common.IsRequirementEnabled(18321, this.Site))
{
string[] contentTypeOrderArray = listContentTypes.ContentTypes.ContentTypeOrder.Split(',');
bool isR18321Verified = true;
foreach (string contentTypeOrder in contentTypeOrderArray)
{
isR18321Verified = isR18321Verified && listContentTypes.ContentTypes.ContentType.Any(ct => ct.ID == contentTypeOrder);
}
// If each split string is a valid content type ID, capture R18321.
Site.CaptureRequirementIfIsTrue(
isR18321Verified,
18321,
@"[GetListContentTypesResponse]Implementation does return a string of content type identifiers delimited by commas.(SharePoint Foundation 2010 and above follow this behavior.)");
}
// Get the created content type object.
GetListContentTypesResponseGetListContentTypesResultContentTypesContentType contentType = null;
contentType = listContentTypes.ContentTypes.ContentType.First(ct => ct.ID.Equals(contentTypeId, StringComparison.OrdinalIgnoreCase));
// If the content type object in GetListContentTypesResponse is the expected content type, capture R1831, R1838, R1839, R1840, R1841
Site.CaptureRequirementIfIsNotNull(
contentType,
1831,
@"[GetListContentTypesResponse]GetListContentTypesResult.ContentTypes: The container element for the content types.");
Site.CaptureRequirementIfAreEqual<string>(
displayName,
contentType.Name,
1838,
@"[GetListContentTypesResponse]GetListContentTypesResult.ContentTypes.ContentType.Name: The name of the content type.");
Site.CaptureRequirementIfAreEqual<string>(
contentTypeId,
contentType.ID,
1839,
@"[GetListContentTypesResponse]GetListContentTypesResult.ContentTypes.ContentType.ID: The content type identifier for this content type.");
// When the content type created, the display name is used for the description.
Site.CaptureRequirementIfAreEqual<string>(
displayName,
contentType.Description,
1840,
@"[GetListContentTypesResponse]GetListContentTypesResult.ContentTypes.ContentType.Description: The description of the content type.");
Uri contentTypeScope = null;
bool isR1841Verified = Uri.TryCreate(contentType.Scope, UriKind.Absolute, out contentTypeScope);
Site.CaptureRequirementIfIsTrue(
isR1841Verified,
1841,
@"[GetListContentTypesResponse]GetListContentTypesResult.ContentTypes.ContentType.Scope: The fully qualified URL to the content type scope.");
// If the create content type can be found in GetListContentTypes response, that means the list is the expected list, Then capture R609 R610.
bool isR609Verified = listContentTypes.ContentTypes.ContentType.Any(ct => ct.ID.Equals(contentTypeId, StringComparison.OrdinalIgnoreCase));
Site.CaptureRequirementIfIsTrue(
isR609Verified,
609,
@"[In GetListContentTypes operation] If the specified listName is not a valid GUID, the protocol server MUST check to see if listName corresponds to the title of a list on the site and if so, MUST use that list.");
Site.CaptureRequirementIfIsTrue(
isR609Verified,
610,
@"[In GetListContentTypes operation] If the specified listName does not correspond to the identification of a list on the site, the protocol server MUST check to see if listName corresponds to the title of a list on the site and if so, MUST use that list.");
#endregion
}