public void MSOXWSSYNC_S02_TC07_SyncFolderItems_PostItemType() { #region Step 1. Client invokes SyncFolderItems operation to get initial syncState of inbox folder and verify related requirements. DistinguishedFolderIdNameType inboxFolder = DistinguishedFolderIdNameType.inbox; // Call SyncFolderItems operation with invalid SyncState to verify the error code: ErrorInvalidSyncStateData SyncFolderItemsType requestWithInvalidSyncState = this.CreateSyncFolderItemsRequestWithoutOptionalElements(inboxFolder, DefaultShapeNamesType.AllProperties); // The SyncState element data, encoded with base64 encoding, is set to an invalid value requestWithInvalidSyncState.SyncState = TestSuiteBase.InvalidSyncState; SyncFolderItemsResponseType responseWithInvalidSyncState = this.SYNCAdapter.SyncFolderItems(requestWithInvalidSyncState); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSSYNC_R518"); // Verify MS-OXWSSYNC requirement: MS-OXWSSYNC_R518 Site.CaptureRequirementIfAreEqual<ResponseCodeType>( ResponseCodeType.ErrorInvalidSyncStateData, responseWithInvalidSyncState.ResponseMessages.Items[0].ResponseCode, "MS-OXWSCDATA", 518, @"[In m:ResponseCodeType Simple Type] [ErrorInvalidSyncStateData: ] This is returned by the SyncFolderItems method if the SyncState property data is invalid."); SyncFolderItemsType request = this.CreateSyncFolderItemsRequestWithoutOptionalElements(inboxFolder, DefaultShapeNamesType.AllProperties); SyncFolderItemsResponseType response = this.SYNCAdapter.SyncFolderItems(request); SyncFolderItemsResponseMessageType responseMessage = TestSuiteHelper.EnsureResponse<SyncFolderItemsResponseMessageType>(response); #endregion #region Step 2. Client invokes CreateItem create a PostItemType item and get its ID. PostItemType postItem = new PostItemType(); BaseItemIdType[] itemIds = this.CreateItem(inboxFolder, postItem); #endregion #region Step 3. Client invokes SyncFolderItems operation with previous SyncState to sync the operation result in Step 2 and verify related requirements. responseMessage = this.GetResponseMessage(inboxFolder, responseMessage, DefaultShapeNamesType.AllProperties); // Assert the changes in response is not null Site.Assert.IsNotNull(responseMessage.Changes, "There is one item created on server, so the changes between server and client should not be null"); SyncFolderItemsChangesType changes = responseMessage.Changes; // Assert both the Items and ItemsElementName are not null Site.Assert.IsNotNull(changes.ItemsElementName, "There should be changes information returned in SyncFolderItems response since there is one item created on server."); Site.Assert.IsNotNull(changes.Items, "There should be item information returned in SyncFolderItems response since there is one item created on server."); Site.Assert.AreEqual<int>(1, changes.Items.Length, "Just one PostItemType item was created in previous step, so the count of Items array in responseMessage.Changes should be 1."); // If the type of item in SyncFolderItems response is PostItemType, then requirement MS-OXWSSYNC_R174 can be captured. // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSSYNC_R174"); // Verify MS-OXWSSYNC requirement: MS-OXWSSYNC_R174 Site.CaptureRequirementIfIsInstanceOfType( (changes.Items[0] as SyncFolderItemsCreateOrUpdateType).Item, typeof(PostItemType), 174, @"[In t:SyncFolderItemsCreateOrUpdateType Complex Type] The type of PostItem is t:PostItemType ([MS-OXWSPOST] section 2.2.4.1)."); // Assert both the length of responseMessage.Changes.ItemsElementName and responseMessage.Changes.Items are 1. Site.Assert.AreEqual<int>(1, changes.ItemsElementName.Length, "Just one PostItemType item was created in previous step, so the count of ItemsElementName array in responseMessage.Changes should be 1."); bool isPostItemCreated = changes.ItemsElementName[0] == ItemsChoiceType1.Create && (changes.Items[0] as SyncFolderItemsCreateOrUpdateType).Item.GetType() == typeof(PostItemType); // Add the debug information Site.Log.Add( LogEntryKind.Debug, "Verify MS-OXWSSYNC_R1751. Expected value: ItemsElementName: {0}, item type: {1}; actual value: ItemsElementName: {2}, item type: {3}", ItemsChoiceType1.Create, typeof(PostItemType), changes.ItemsElementName[0], (changes.Items[0] as SyncFolderItemsCreateOrUpdateType).Item.GetType()); // If the ItemsElementName of Changes is Create and the type of Item is PostItemType, it indicates a post item // has been created on server and synced on client, then requirement MS-OXWSSYNC_R1751 can be captured. // Verify MS-OXWSSYNC requirement: MS-OXWSSYNC_R1751 Site.CaptureRequirementIfIsTrue( isPostItemCreated, 1751, @"[In t:SyncFolderItemsCreateOrUpdateType Complex Type] [The element PostItem] specifies a post item to create in the client message store."); #endregion #region Step 4. Client invokes UpdateItem operation to update the created item which created in Step 2. // Generate a new item subject string newItemSubject = Common.GenerateResourceName(this.Site, inboxFolder + "NewItemSubject"); this.UpdateItemSubject(itemIds, newItemSubject); #endregion #region Step 5. Client invokes SyncFolderItems operation with previous SyncState to sync the operation result in Step 4 and verify related requirements. responseMessage = this.GetResponseMessage(inboxFolder, responseMessage, DefaultShapeNamesType.AllProperties); // Assert the changes in response is not null Site.Assert.IsNotNull(responseMessage.Changes, "There is one item 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 SyncFolderItems response since there is one item updated on server."); Site.Assert.IsNotNull(changes.Items, "There should be item information returned in SyncFolderItems response since there is one item updated on server."); Site.Assert.AreEqual<int>(1, changes.Items.Length, "Just one PostItemType item was updated in previous step, so the count of Items array in responseMessage.Changes should be 1."); bool isLastItemIncluded = responseMessage.IncludesLastItemInRange && ((changes.Items[0] as SyncFolderItemsCreateOrUpdateType).Item.GetType() == typeof(PostItemType)); // Since the last updated item is a post item, if the IncludesLastItemInRange element in SyncFolderItems response is TRUE // and the items in Changes contains PostItemType item, then requirement MS-OXWSSYNC_R6701 can be captured. // Add the debug information Site.Log.Add( LogEntryKind.Debug, "Verify MS-OXWSSYNC_R6701. Expected value: IncludesLastItemInRange: 'true', item type: {0}; actual value: IncludesLastItemInRange: {1}, item type: {2}", typeof(PostItemType), responseMessage.IncludesLastItemInRange, (changes.Items[0] as SyncFolderItemsCreateOrUpdateType).Item.GetType()); // Verify MS-OXWSSYNC requirement: MS-OXWSSYNC_R6701 Site.CaptureRequirementIfIsTrue( isLastItemIncluded, 6701, @"[In m:SyncFolderItemsResponseMessageType Complex Type] [The element IncludesLastItemInRange] True indicates the last item to synchronize is included in the response."); Site.Assert.AreEqual<int>(1, changes.ItemsElementName.Length, "Just one PostItemType item was updated in previous step, so the count of ItemsElementName array in responseMessage.Changes should be 1."); bool isPostItemUpdated = changes.ItemsElementName[0] == ItemsChoiceType1.Update && (changes.Items[0] as SyncFolderItemsCreateOrUpdateType).Item.GetType() == typeof(PostItemType); // Add the debug information Site.Log.Add( LogEntryKind.Debug, "Verify MS-OXWSSYNC_R1752. Expected value: ItemsElementName: {0}, item type: {1}; actual value: ItemsElementName: {2}, item type: {3}", ItemsChoiceType1.Update, typeof(PostItemType), changes.ItemsElementName[0], (changes.Items[0] as SyncFolderItemsCreateOrUpdateType).Item.GetType()); // If the ItemsElementName of Changes is Update and the type of Item is PostItemType, it indicates a post item // has been updated on server and synced on client, then requirement MS-OXWSSYNC_R1752 can be captured. // Verify MS-OXWSSYNC requirement: MS-OXWSSYNC_R1752 Site.CaptureRequirementIfIsTrue( isPostItemUpdated, 1752, @"[In t:SyncFolderItemsCreateOrUpdateType Complex Type] [The element PostItem] specifies a post item to update in the client message store."); #endregion #region Step 6. Client invokes DeleteItem operation to delete the PostItemType item which updated in Step 4. this.DeleteItem(itemIds); #endregion #region Step 7. Client invokes SyncFolderItems operation with previous SyncState to sync the operation result in Step 6. responseMessage = this.GetResponseMessage(inboxFolder, responseMessage, DefaultShapeNamesType.AllProperties); // Assert the changes in response is not null Site.Assert.IsNotNull(responseMessage.Changes, "There is one item deleted 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 SyncFolderItems response since there is one item deleted on server."); Site.Assert.IsNotNull(changes.Items, "There should be item information returned in SyncFolderItems response since there is one item deleted on server."); Site.Assert.AreEqual<int>(1, changes.ItemsElementName.Length, "Just one PostItemType item was deleted in previous step, so the count of ItemsElementName array in responseMessage.Changes should be 1."); Site.Assert.IsTrue( changes.ItemsElementName[0] == ItemsChoiceType1.Delete, string.Format("The responseMessage.Changes.ItemsElementName should be 'Delete', the actual value is '{0}'", changes.ItemsElementName[0])); Site.Assert.AreEqual<int>(1, changes.Items.Length, "Just one PostItemType item was deleted in previous step, so the count of Items array in responseMessage.Changes should be 1."); Site.Assert.IsTrue( changes.Items[0].GetType() == typeof(SyncFolderItemsDeleteType), string.Format("The responseMessage.Changes.Items should be an instance of '{0}'.", typeof(SyncFolderItemsDeleteType))); #endregion }