public void MSASCMD_S19_TC48_Sync_Collection_LimitValue()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(5671, this.Site) || Common.IsRequirementEnabled(5673, this.Site), "Update Rollup 6 for Exchange 2010 SP2 and Exchange 2013 use the specified limit values by default.");

            #region Create 51 Add elements, 50 Change elements, 50 Delete elements and 50 Fetch elements for the Commands element of Sync command.
            this.Sync(TestSuiteBase.CreateEmptySyncRequest(this.User1Information.ContactsCollectionId));

            List<object> commands = new List<object>();

            for (int i = 0; i < 50; i++)
            {
                string contactFileAS = Common.GenerateResourceName(Site, "FileAS");
                Request.SyncCollectionAdd addData = this.CreateAddContactCommand("FirstName", "MiddleName", "LastName", contactFileAS, null);
                commands.Add(addData);

                string serverId = this.User1Information.ContactsCollectionId + ":" + Guid.NewGuid().ToString();
                string updatedContactFileAS = Common.GenerateResourceName(Site, "UpdatedFileAS");
                Request.SyncCollectionChange changeData = CreateChangedContact(serverId, new Request.ItemsChoiceType7[] { Request.ItemsChoiceType7.FileAs }, new object[] { updatedContactFileAS });
                commands.Add(changeData);

                Request.SyncCollectionDelete deleteData = new Request.SyncCollectionDelete { ServerId = serverId };
                commands.Add(deleteData);

                Request.SyncCollectionFetch fetchData = new Request.SyncCollectionFetch { ServerId = serverId };
                commands.Add(fetchData);
            }

            string contactFileASFor51Add = Common.GenerateResourceName(Site, "FileAS");
            Request.SyncCollectionAdd addDataFor51Add = this.CreateAddContactCommand("FirstName", "MiddleName", "LastName", contactFileASFor51Add, null);
            commands.Add(addDataFor51Add);
            #endregion

            #region Call Sync command on the Contacts folder
            Request.SyncCollection collection = new Request.SyncCollection
            {
                SyncKey = this.LastSyncKey,
                GetChanges = true,
                CollectionId = this.User1Information.ContactsCollectionId,
                Commands = commands.ToArray()
            };

            SyncRequest syncRequest = Common.CreateSyncRequest(new Request.SyncCollection[] { collection });
            SyncResponse syncResponse = this.Sync(syncRequest);

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R5659");

            // Verify MS-ASCMD requirement: MS-ASCMD_R5659
            Site.CaptureRequirementIfAreEqual<int>(
                4,
                int.Parse(syncResponse.ResponseData.Status),
                5659,
                @"[In Limiting Size of Command Requests] In Sync (section 2.2.2.19) command request, when the limit value of Add, Change, Delete and Fetch elements is bigger than 200 (minimum 1, maximum 2,147,483,647), the error returned by server is Status element (section 2.2.3.162.16) value of 4.");
            #endregion
        }
        public void MSASCMD_S19_TC52_Sync_Status8()
        {
            #region Send a MIME-formatted email to User2.
            string emailSubject = Common.GenerateResourceName(Site, "subject");
            this.SendPlainTextEmail(null, emailSubject, this.User1Information.UserName, this.User2Information.UserName, null);
            #endregion

            this.SwitchUser(this.User2Information);
            TestSuiteBase.RecordCaseRelativeItems(this.User2Information, this.User2Information.InboxCollectionId, emailSubject);
            SyncResponse syncResponse = this.CheckEmail(this.User2Information.InboxCollectionId, emailSubject, null);
            string itemServerId = TestSuiteBase.FindServerId(syncResponse, "Subject", emailSubject);

            #region Delete the email form Inbox of User2.
            SyncRequest syncRequest = TestSuiteBase.CreateSyncDeleteRequest(this.LastSyncKey, this.User2Information.InboxCollectionId, itemServerId);
            syncRequest.RequestData.Collections[0].DeletesAsMoves = false;
            syncRequest.RequestData.Collections[0].DeletesAsMovesSpecified = true;
            syncResponse = this.Sync(syncRequest);
            #endregion

            #region Fetch the email.
            Request.SyncCollectionFetch appDataFetch = new Request.SyncCollectionFetch
            {
                ServerId = itemServerId
            };

            Request.SyncCollection collection = new Request.SyncCollection
            {
                SyncKey = this.LastSyncKey,
                GetChanges = true,
                GetChangesSpecified = true,
                CollectionId = this.User2Information.InboxCollectionId,
                Commands = new object[] { appDataFetch }
            };

            Request.Sync syncRequestData = new Request.Sync { Collections = new Request.SyncCollection[] { collection } };

            SyncRequest syncRequestForFetch = new SyncRequest { RequestData = syncRequestData };
            syncResponse = this.Sync(syncRequestForFetch);
            Response.SyncCollectionsCollectionResponses collectionResponse = TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Responses) as Response.SyncCollectionsCollectionResponses;

            this.Site.CaptureRequirementIfAreEqual<int>(
                8,
                int.Parse(collectionResponse.Fetch.Status),
                4447,
                @"[In Status(Sync)] [When the scope is Item], [the cause of the status value 8 is] The client issued a fetch [or change] operation that has a CollectionId (section 2.2.3.30.5) value that is no longer valid on the server (for example, the item was deleted).");

            #endregion
        }
        public void MSASCMD_S19_TC36_Sync_Fetch()
        {
            #region Send a MIME-formatted email to User2.
            string emailSubject = Common.GenerateResourceName(Site, "subject");
            this.SendPlainTextEmail(null, emailSubject, this.User1Information.UserName, this.User2Information.UserName, null);
            #endregion

            this.SwitchUser(this.User2Information);
            TestSuiteBase.RecordCaseRelativeItems(this.User2Information, this.User2Information.InboxCollectionId, emailSubject);
            SyncResponse syncResponse = this.CheckEmail(this.User2Information.InboxCollectionId, emailSubject, null);

            #region Fetch the email.
            Request.SyncCollectionFetch appDataFetch = new Request.SyncCollectionFetch
            {
                ServerId = TestSuiteBase.FindServerId(syncResponse, "Subject", emailSubject)
            };

            Request.SyncCollection collection = new Request.SyncCollection
            {
                SyncKey = this.LastSyncKey,
                GetChanges = true,
                GetChangesSpecified = true,
                CollectionId = this.User2Information.InboxCollectionId,
                Commands = new object[] { appDataFetch }
            };

            Request.Sync syncRequestData = new Request.Sync { Collections = new Request.SyncCollection[] { collection } };

            SyncRequest syncRequestForFetch = new SyncRequest { RequestData = syncRequestData };
            syncResponse = this.Sync(syncRequestForFetch);
            Site.Assert.IsNotNull(syncResponse.ResponseData.Item, "The items returned in the Sync command response should not be null.");

            Response.SyncCollectionsCollectionResponses collectionResponse = TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Responses) as Response.SyncCollectionsCollectionResponses;
            Site.Assert.IsNotNull(collectionResponse, "The responses element should exist in the Sync response.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R5433");

            // Verify MS-ASCMD requirement: MS-ASCMD_R5433
            Site.CaptureRequirementIfIsNotNull(
                collectionResponse.Fetch,
                5433,
                @"[In Responses] Element Responses in Sync command response (section 2.2.2.19), the child elements is [Add (section 2.2.3.7.2),] Fetch (section 2.2.3.63.2) (If the operation succeeded.)");
            #endregion
        }