public void MSOXWSSYNC_S02_TC09_SyncFolderItems_DistributionListType() { // Check whether the DistributionListType item is supported on current server version Site.Assume.IsTrue(Common.IsRequirementEnabled(37811, this.Site), "Exchange 2007 does not support DistributionListType item, for detailed information refer to MS-OXWSDLIST."); #region Step 1. Client invokes SyncFolderItems operation to get initial syncState of contacts folder. DistinguishedFolderIdNameType contactFolder = DistinguishedFolderIdNameType.contacts; SyncFolderItemsType request = this.CreateSyncFolderItemsRequestWithoutOptionalElements(contactFolder, DefaultShapeNamesType.AllProperties); SyncFolderItemsResponseType response = this.SYNCAdapter.SyncFolderItems(request); SyncFolderItemsResponseMessageType responseMessage = TestSuiteHelper.EnsureResponse<SyncFolderItemsResponseMessageType>(response); #endregion #region Step 2. Client invokes CreateItem to create a DistributionListType item and get its ID. DistributionListType distributionList = new DistributionListType(); BaseItemIdType[] itemIds = this.CreateItem(contactFolder, distributionList); #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(contactFolder, 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 DistributionList 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 DistributionListType, then requirement MS-OXWSSYNC_R37811 can be captured. // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSSYNC_R37811"); // Verify MS-OXWSSYNC requirement: MS-OXWSSYNC_R37811 Site.CaptureRequirementIfIsInstanceOfType( (changes.Items[0] as SyncFolderItemsCreateOrUpdateType).Item, typeof(DistributionListType), 37811, @"[In Appendix C: Product Behavior] Implementation does support DistributionList with type t:DistributionListType ([MS-OXWSDLIST] section 2.2.4.3). (Exchange 2010 and above follow this behavior.)"); Site.Assert.AreEqual<int>(1, changes.ItemsElementName.Length, "Just one DistributionListType item was created in previous step, so the count of ItemsElementName array in responseMessage.Changes should be 1."); bool isDistributionListCreated = changes.ItemsElementName[0] == ItemsChoiceType1.Create && (changes.Items[0] as SyncFolderItemsCreateOrUpdateType).Item.GetType() == typeof(DistributionListType); // Add the debug information Site.Log.Add( LogEntryKind.Debug, "Verify MS-OXWSSYNC_R1631. Expected value: ItemsElementName: {0}, item type: {1}; actual value: ItemsElementName: {2}, item type: {3}", ItemsChoiceType1.Create, typeof(DistributionListType), changes.ItemsElementName[0], (changes.Items[0] as SyncFolderItemsCreateOrUpdateType).Item.GetType()); // If the ItemsElementName of Changes is Create and the type of Item is DistributionListType, it indicates a distribution list // has been created on server and synced on client, then requirement MS-OXWSSYNC_R1631 can be captured. // Verify MS-OXWSSYNC requirement: MS-OXWSSYNC_R1631 Site.CaptureRequirementIfIsTrue( isDistributionListCreated, 1631, @"[In t:SyncFolderItemsCreateOrUpdateType Complex Type] [The element DistributionList] specifies a distribution list 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, contactFolder + "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(contactFolder, 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 DistributionList item was updated in previous step, so the count of Items array in responseMessage.Changes should be 1."); Site.Assert.AreEqual<int>(1, changes.ItemsElementName.Length, "Just one DistributionList item was updated in previous step, so the count of ItemsElementName array in responseMessage.Changes should be 1."); bool isDistributionListUpdated = changes.ItemsElementName[0] == ItemsChoiceType1.Update && (changes.Items[0] as SyncFolderItemsCreateOrUpdateType).Item.GetType() == typeof(DistributionListType); // Add the debug information Site.Log.Add( LogEntryKind.Debug, "Verify MS-OXWSSYNC_R1632. Expected value: ItemsElementName: {0}, item type: {1}; actual value: ItemsElementName: {2}, item type: {3}", ItemsChoiceType1.Update, typeof(DistributionListType), changes.ItemsElementName[0], (changes.Items[0] as SyncFolderItemsCreateOrUpdateType).Item.GetType()); // If the ItemsElementName of Changes is Update and the type of Item is DistributionListType, it indicates a distribution list // has been updated on server and synced on client, then requirement MS-OXWSSYNC_R1592 can be captured. // Verify MS-OXWSSYNC requirement: MS-OXWSSYNC_R1632 Site.CaptureRequirementIfIsTrue( isDistributionListUpdated, 1632, @"[In t:SyncFolderItemsCreateOrUpdateType Complex Type] [The element DistributionList] specifies a distribution list to update in the client message store."); #endregion #region Step 6. Client invokes DeleteItem operation to delete the DistributionListType 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(contactFolder, 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."); // Assert both the length of responseMessage.Changes.ItemsElementName and responseMessage.Changes.Items are 1. Site.Assert.AreEqual<int>(1, changes.ItemsElementName.Length, "Just one DistributionList item was deleted in previous step, so the count of ItemsElementName array in responseMessage.Changes should be 1."); // Assert the ItemsElementName is Delete. 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 DistributionList item was deleted in previous step, so the count of Items array in responseMessage.Changes should be 1."); // Assert the Items is an instance of SyncFolderItemsDeleteType. Site.Assert.IsTrue( changes.Items[0].GetType() == typeof(SyncFolderItemsDeleteType), string.Format("The responseMessage.Changes.Items should be an instance of '{0}'.", typeof(SyncFolderItemsDeleteType))); #endregion }