public void MSOXWSSYNC_S01_TC02_SyncFolderHierarchy_CalendarFolder()
{
#region Step 1. Client invokes SyncFolderHierarchy operation to get initial syncState of calendar folder.
DistinguishedFolderIdNameType calendarFolder = DistinguishedFolderIdNameType.calendar;
// Set DefaultShapeNamesType to IdOnly and include SyncFolderId and SyncState element in the request
SyncFolderHierarchyType request = TestSuiteHelper.CreateSyncFolderHierarchyRequest(calendarFolder, DefaultShapeNamesType.IdOnly, true, true);
SyncFolderHierarchyResponseType response = this.SYNCAdapter.SyncFolderHierarchy(request);
SyncFolderHierarchyResponseMessageType responseMessage = TestSuiteHelper.EnsureResponse<SyncFolderHierarchyResponseMessageType>(response);
#endregion
#region Step 2. Client invokes CreateFolder operation to create two level folders in calendar folder.
// Generate the created folder name
string firstLevelFolderName = Common.GenerateResourceName(this.Site, calendarFolder + "FirstLevelFolder");
string secondLevelFolderName = Common.GenerateResourceName(this.Site, calendarFolder + "SecondLevelFolder");
// Create two level sub folders in calendar folder.
bool isSubFolderCreated = this.FOLDSUTControlAdapter.CreateSubFolders(
Common.GetConfigurationPropertyValue("User1Name", this.Site),
Common.GetConfigurationPropertyValue("User1Password", this.Site),
Common.GetConfigurationPropertyValue("Domain", this.Site),
calendarFolder.ToString(),
firstLevelFolderName,
secondLevelFolderName);
Site.Assert.IsTrue(isSubFolderCreated, string.Format("The new sub folders in '{0}' should be created successfully.", calendarFolder));
#endregion
#region Step 3. Client invokes SyncFolderHierarchy operation to sync the operation result in Step 2 and verify related requirements.
request.SyncState = responseMessage.SyncState;
response = this.SYNCAdapter.SyncFolderHierarchy(request);
responseMessage = TestSuiteHelper.EnsureResponse<SyncFolderHierarchyResponseMessageType>(response);
// Assert the changes in response is not null
Site.Assert.IsNotNull(responseMessage.Changes, "There are two folders created on server, so the changes between server and client should not be null");
SyncFolderHierarchyChangesType changes = responseMessage.Changes;
// Assert both the Items and ItemsElementName are not null
Site.Assert.IsNotNull(changes.ItemsElementName, "There should be changes information returned in SyncFolderHierarchy response since there are two folders created on server.");
Site.Assert.IsNotNull(changes.Items, "There should be folders information returned in SyncFolderHierarchy response since there are two folders created on server.");
bool isCalendarFolderCreated = false;
for (int i = 0; i < changes.Items.Length; i++)
{
Site.Log.Add(
LogEntryKind.Debug,
"Expected value: ItemsElementName: {0}, folder type: {1}; actual value: ItemsElementName: {2}, folder type: {3}",
ItemsChoiceType.Create,
typeof(CalendarFolderType),
changes.ItemsElementName[i],
(changes.Items[i] as SyncFolderHierarchyCreateOrUpdateType).Item.GetType());
if (changes.ItemsElementName[i] == ItemsChoiceType.Create &&
(changes.Items[i] as SyncFolderHierarchyCreateOrUpdateType).Item.GetType() == typeof(CalendarFolderType))
{
isCalendarFolderCreated = true;
}
else
{
isCalendarFolderCreated = false;
break;
}
}
// If the ItemsElementName of Changes is Create and the type of Item is CalendarFolderType,
// it indicates a calendar folder has been created on server and synced on client, then requirement MS-OXWSSYNC_R1021 can be captured.
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSSYNC_R1021");
// Verify MS-OXWSSYNC requirement: MS-OXWSSYNC_R1021
Site.CaptureRequirementIfIsTrue(
isCalendarFolderCreated,
1021,
@"[In t:SyncFolderHierarchyCreateOrUpdateType Complex Type] [The element CalendarFolder] specifies a calendar folder to create in the client message store.");
#endregion
#region Step 4. Client invokes UpdateFolder operation to change the second level folder's name.
// Generate a new folder name
string newFolderName = Common.GenerateResourceName(this.Site, calendarFolder + "NewFolderName");
// Update the name of the second level sub folder.
bool updatedFolder = this.SYNCSUTControlAdapter.FindAndUpdateFolderName(
Common.GetConfigurationPropertyValue("User1Name", this.Site),
Common.GetConfigurationPropertyValue("User1Password", this.Site),
Common.GetConfigurationPropertyValue("Domain", this.Site),
calendarFolder.ToString(),
secondLevelFolderName,
newFolderName);
Site.Assert.IsTrue(updatedFolder, string.Format("The folder name '{0}' should be updated to '{1}'.", secondLevelFolderName, newFolderName));
#endregion
#region Step 5. Client invokes SyncFolderHierarchy operation with previous syncState to sync the operation result in Step 4 and verify related requirements.
// Assert the SyncState is not null
Site.Assert.IsNotNull(responseMessage.SyncState, "The synchronization should not be null.");
request.SyncState = responseMessage.SyncState;
response = this.SYNCAdapter.SyncFolderHierarchy(request);
responseMessage = TestSuiteHelper.EnsureResponse<SyncFolderHierarchyResponseMessageType>(response);
// Assert the changes in response is not null
Site.Assert.IsNotNull(responseMessage.Changes, "There is one folder updated on server, so the changes between server and client should not be null");
changes = responseMessage.Changes;
// Assert both the Items and ItemsElementName are not null
Site.Assert.IsNotNull(changes.ItemsElementName, "There should be changes information returned in SyncFolderHierarchy response since there is one folder updated on server.");
Site.Assert.IsNotNull(changes.Items, "There should be folders information returned in SyncFolderHierarchy response since there is one folder updated on server.");
bool isIdOnly = Common.IsIdOnly((XmlElement)this.SYNCAdapter.LastRawResponseXml, "t:CalendarFolder", "t:FolderId");
// If there is only one FolderId element in the item of changes, then requirement MS-OXWSSYNC_R2573 can be captured.
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSSYNC_R2573");
// Verify MS-OXWSSYNC requirement: MS-OXWSSYNC_R2573
Site.CaptureRequirementIfIsTrue(
isIdOnly,
2573,
@"[In m:SyncFolderHierarchyType Complex Type] FolderShape element BaseShape, value=IdOnly, specifies only the item or folder ID.");
Site.Assert.AreEqual<int>(1, changes.Items.Length, "Just one CalendarFolderType folder was updated in previous step, so the count of Items array in SyncFolderHierarchy responseMessage.Changes should be 1.");
Site.Assert.AreEqual<int>(1, changes.ItemsElementName.Length, "Just one CalendarFolderType folder was updated in previous step, so the count of ItemsElementName array in SyncFolderHierarchy responseMessage.Changes should be 1.");
// If the type of item in SyncFolderHierarchy response is CalendarFolderType, then requirement MS-OXWSSYNC_R101 can be captured.
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSSYNC_R101");
// Verify MS-OXWSSYNC requirement: MS-OXWSSYNC_R101
Site.CaptureRequirementIfIsInstanceOfType(
(changes.Items[0] as SyncFolderHierarchyCreateOrUpdateType).Item,
typeof(CalendarFolderType),
101,
@"[In t:SyncFolderHierarchyCreateOrUpdateType Complex Type] The type of CalendarFolder element is t:CalendarFolderType ([MS-OXWSMTGS] section 2.2.4.8).");
bool isCalendarFolderUpdated = (changes.ItemsElementName[0] == ItemsChoiceType.Update) &&
((changes.Items[0] as SyncFolderHierarchyCreateOrUpdateType).Item.GetType() == typeof(CalendarFolderType));
// If the ItemsElementName of Changes is Update and the type of Item is CalendarFolderType, it indicates a calendar folder has been updated on server and synced on client,
// then requirement MS-OXWSSYNC_R1022 can be captured.
// Add the debug information
Site.Log.Add(
LogEntryKind.Debug,
"Verify MS-OXWSSYNC_R1022. Expected value: ItemsElementName: {0}, folder type: {1}; actual value: ItemsElementName: {2}, folder type: {3}",
ItemsChoiceType.Update,
typeof(CalendarFolderType),
changes.ItemsElementName[0],
(changes.Items[0] as SyncFolderHierarchyCreateOrUpdateType).Item.GetType());
// Verify MS-OXWSSYNC requirement: MS-OXWSSYNC_R1022
Site.CaptureRequirementIfIsTrue(
isCalendarFolderUpdated,
1022,
@"[In t:SyncFolderHierarchyCreateOrUpdateType Complex Type] [The element CalendarFolder] specifies a calendar folder to update in the client message store.");
#endregion
#region Step 6. Client invokes DeleteFolder operation to delete the second level folder that created in step 2.
// Delete the second level sub folder
bool isDeleted = this.SYNCSUTControlAdapter.FindAndDeleteSubFolder(
Common.GetConfigurationPropertyValue("User1Name", this.Site),
Common.GetConfigurationPropertyValue("User1Password", this.Site),
Common.GetConfigurationPropertyValue("Domain", this.Site),
calendarFolder.ToString(),
newFolderName);
Site.Assert.IsTrue(isDeleted, string.Format("The folder named '{0}' should be deleted from '{1}' successfully.", newFolderName, calendarFolder));
#endregion
#region Step 7. Client invokes SyncFolderHierarchy operation with previous syncState to sync the operation result of Step 6 and verify related requirements.
// Assert the SyncState is not null
Site.Assert.IsNotNull(responseMessage.SyncState, "The synchronization should not be null.");
request.SyncState = responseMessage.SyncState;
response = this.SYNCAdapter.SyncFolderHierarchy(request);
responseMessage = TestSuiteHelper.EnsureResponse<SyncFolderHierarchyResponseMessageType>(response);
// Assert the changes in response is not null
Site.Assert.IsNotNull(responseMessage.Changes, "There is one folder deleted on server, so the changes between server and client should not be null");
changes = responseMessage.Changes;
// Assert ItemsElementName is not null
Site.Assert.IsNotNull(changes.ItemsElementName, "There should be changes information returned in SyncFolderHierarchy response since there is one folder deleted on server.");
Site.Assert.AreEqual<int>(1, changes.ItemsElementName.Length, "Just one CalendarFolderType folder was deleted in previous step, so the count of ItemsElementName array in SyncFolderHierarchy responseMessage.Changes should be 1.");
bool isIncrementalSync = changes.ItemsElementName[0] == ItemsChoiceType.Delete && responseMessage.SyncState != null;
// If the ItemsElementName is Delete and the SyncState element is not null, then requirement MS-OXWSSYNC_R503 can be captured.
// Add the debug information
Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSSYNC_R503. Expected value: ItemsElementName:{0}; actual value: ItemsElementName: {1}", ItemsChoiceType.Delete, changes.ItemsElementName[0]);
// Verify MS-OXWSSYNC requirement: MS-OXWSSYNC_R503
Site.CaptureRequirementIfIsTrue(
isIncrementalSync,
503,
@"[In Abstract Data Model] If the optional SyncState element of the SyncFolderHierarchyType complex type (section 3.1.4.1.3.6) is included in a SyncFolderHierarchy operation (section 3.1.4.1) request, the server MUST return incremental synchronization information from the last synchronization request.");
#endregion
}