Microsoft.Protocols.TestSuites.MS_OXWSSYNC.S02_SyncFolderItems.MSOXWSSYNC_S02_TC10_SyncFolderItems_ItemType C# (CSharp) Method

MSOXWSSYNC_S02_TC10_SyncFolderItems_ItemType() private method

private MSOXWSSYNC_S02_TC10_SyncFolderItems_ItemType ( ) : void
return void
        public void MSOXWSSYNC_S02_TC10_SyncFolderItems_ItemType()
        {
            #region Step 1. Client invokes SyncFolderItems operation to get initial syncState of inbox folder.
            DistinguishedFolderIdNameType inboxFolder = DistinguishedFolderIdNameType.inbox;
            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 to create a ItemType item and get its ID.
            ItemType item = new ItemType();
            BaseItemIdType[] itemIds = this.CreateItem(inboxFolder, item);
            #endregion

            #region Step 3. Client invokes SyncFolderItems operation with previous SyncState to sync the operation result in Step 2.
            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.ItemsElementName.Length, "Just one ItemType item was created in previous step, so the count of ItemsElementName array in responseMessage.Changes should be 1.");
            Site.Assert.IsTrue(
                changes.ItemsElementName[0] == ItemsChoiceType1.Create,
                string.Format("The responseMessage.Changes.ItemsElementName should be 'Create', the actual value is '{0}'", changes.ItemsElementName[0]));

            Site.Assert.AreEqual<int>(1, changes.Items.Length, "Just one ItemType item was created in previous step, so the count of Items array in responseMessage.Changes should be 1.");

            // If client creates an item of ItemType, a MessageType complex type is returned.
            Site.Assert.IsTrue(
                changes.Items[0].GetType() == typeof(SyncFolderItemsCreateOrUpdateType) && (changes.Items[0] as SyncFolderItemsCreateOrUpdateType).Item.GetType() == typeof(MessageType),
                string.Format("The responseMessage.Changes.Items should be an instance of '{0}' and the type of Item should be '{1}'.", typeof(SyncFolderItemsCreateOrUpdateType), typeof(MessageType)));
            if (Common.IsRequirementEnabled(37811004, this.Site))
            {
                // Add the debug information
                this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWWSSYNC_R37811004");

                this.Site.CaptureRequirementIfIsInstanceOfType(
                    (changes.Items[0] as SyncFolderItemsCreateOrUpdateType).Item,
                    typeof(MessageType),
                    37811004,
                    @"[In Appendix C: Product Behavior] Implementation does return a MessageType complex type. (If a client creates an item of this type, a MessageType complex type is returned.)");
            }
            #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.
            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.ItemsElementName.Length, "Just one ItemType item was updated in previous step, so the count of ItemsElementName array in responseMessage.Changes should be 1.");
            Site.Assert.IsTrue(
                changes.ItemsElementName[0] == ItemsChoiceType1.Update,
                string.Format("The responseMessage.Changes.ItemsElementName should be 'Update', the actual value is '{0}'", changes.ItemsElementName[0]));

            Site.Assert.AreEqual<int>(1, changes.Items.Length, "Just one ItemType item was updated in previous step, so the count of Items array in responseMessage.Changes should be 1.");

            // If client creates an item of ItemType, a MessageType complex type is returned.
            Site.Assert.IsTrue(
                changes.Items[0].GetType() == typeof(SyncFolderItemsCreateOrUpdateType) && (changes.Items[0] as SyncFolderItemsCreateOrUpdateType).Item.GetType() == typeof(MessageType),
                string.Format("The responseMessage.Changes.Items should be an instance of '{0}' and the type of Item should be '{1}'.", typeof(SyncFolderItemsCreateOrUpdateType), typeof(MessageType)));
            #endregion

            #region Step 6. Client invokes DeleteItem operation to delete the ItemType 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 ItemType 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 ItemType 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
        }