CreateSyncRequest() статический приватный Метод

Builds a Sync change request by using the specified sync key, folder collection ID and change application data.
static private CreateSyncRequest ( string syncKey, string collectionId, List data ) : SyncRequest
syncKey string Specifies the sync key obtained from the last sync response.
collectionId string Specifies the server ID of the folder to be synchronized.
data List Contains the data used to specify the Change element for Sync command.
Результат SyncRequest
Пример #1
0
        /// <summary>
        /// Call Sync command to fetch the change of the notes from previous syncKey
        /// </summary>
        /// <param name="syncKey">The sync key</param>
        /// <param name="bodyType">The type of the body</param>
        /// <returns>Return change result</returns>
        protected SyncStore SyncChanges(string syncKey, byte bodyType)
        {
            Request.BodyPreference bodyPreference = new Request.BodyPreference {
                Type = bodyType
            };

            SyncRequest syncRequest = TestSuiteHelper.CreateSyncRequest(syncKey, this.UserInformation.NotesCollectionId, bodyPreference);
            SyncStore   syncResult  = this.NOTEAdapter.Sync(syncRequest, true);

            return(syncResult);
        }
Пример #2
0
        /// <summary>
        /// Call Sync command to delete a note
        /// </summary>
        /// <param name="syncKey">The sync key</param>
        /// <param name="serverId">The server id of the note, which is returned by server</param>
        /// <returns>Return the sync delete result</returns>
        private SyncStore SyncDelete(string syncKey, string serverId)
        {
            List <object> deleteData = new List <object> {
                new Request.SyncCollectionDelete {
                    ServerId = serverId
                }
            };
            SyncRequest syncRequest = TestSuiteHelper.CreateSyncRequest(syncKey, this.UserInformation.NotesCollectionId, deleteData);
            SyncStore   result      = this.NOTEAdapter.Sync(syncRequest, false);

            return(result);
        }
Пример #3
0
        public void MSASNOTE_S01_TC05_Sync_InvalidMessageClass()
        {
            #region Call method Sync to add a note to the server
            Dictionary <Request.ItemsChoiceType8, object> addElements = this.CreateNoteElements();
            addElements[Request.ItemsChoiceType8.MessageClass] = "IPM.invalidClass";
            SyncRequest syncRequest = TestSuiteHelper.CreateInitialSyncRequest(this.UserInformation.NotesCollectionId);
            SyncStore   syncResult  = this.NOTEAdapter.Sync(syncRequest, false);

            Site.Assert.AreEqual <byte>(
                1,
                syncResult.CollectionStatus,
                "The server should return a status code 1 in the Sync command response indicate sync command success.");

            List <object>             addData = new List <object>();
            Request.SyncCollectionAdd add     = new Request.SyncCollectionAdd
            {
                ClientId        = System.Guid.NewGuid().ToString(),
                ApplicationData = new Request.SyncCollectionAddApplicationData
                {
                    ItemsElementName = new Request.ItemsChoiceType8[addElements.Count],
                    Items            = new object[addElements.Count]
                }
            };

            addElements.Keys.CopyTo(add.ApplicationData.ItemsElementName, 0);
            addElements.Values.CopyTo(add.ApplicationData.Items, 0);
            addData.Add(add);

            syncRequest = TestSuiteHelper.CreateSyncRequest(syncResult.SyncKey, this.UserInformation.NotesCollectionId, addData);
            SyncStore addResult = this.NOTEAdapter.Sync(syncRequest, false);

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

            // Verify MS-ASNOTE requirement: MS-ASNOTE_R119
            Site.CaptureRequirementIfAreEqual <int>(
                6,
                int.Parse(addResult.AddResponses[0].Status),
                119,
                @"[In MessageClass Element] If a client submits a Sync command request ([MS-ASCMD] section 2.2.2.19) that contains a MessageClass element value that does not conform to the requirements specified in section 2.2.2.5, the server MUST respond with a Status element with a value of 6, as specified in [MS-ASCMD] section 2.2.3.162.16.");

            #endregion
        }
Пример #4
0
        /// <summary>
        /// Call Sync command to change a note
        /// </summary>
        /// <param name="syncKey">The sync key</param>
        /// <param name="serverId">The server Id of the note</param>
        /// <param name="changedElements">The changed elements of the note</param>
        /// <returns>Return the sync change result</returns>
        protected SyncStore SyncChange(string syncKey, string serverId, Dictionary <Request.ItemsChoiceType7, object> changedElements)
        {
            Request.SyncCollectionChange change = new Request.SyncCollectionChange
            {
                ServerId        = serverId,
                ApplicationData = new Request.SyncCollectionChangeApplicationData
                {
                    ItemsElementName = new Request.ItemsChoiceType7[changedElements.Count],
                    Items            = new object[changedElements.Count]
                }
            };

            changedElements.Keys.CopyTo(change.ApplicationData.ItemsElementName, 0);
            changedElements.Values.CopyTo(change.ApplicationData.Items, 0);

            List <object> changeData = new List <object> {
                change
            };
            SyncRequest syncRequest = TestSuiteHelper.CreateSyncRequest(syncKey, this.UserInformation.NotesCollectionId, changeData);

            return(this.NOTEAdapter.Sync(syncRequest, false));
        }
Пример #5
0
        /// <summary>
        /// Call Sync command to add a note
        /// </summary>
        /// <param name="addElements">The elements of a note item to be added</param>
        /// <param name="count">The number of the note</param>
        /// <returns>Return the sync add result</returns>
        protected SyncStore SyncAdd(Dictionary <Request.ItemsChoiceType8, object> addElements, int count)
        {
            SyncRequest syncRequest = TestSuiteHelper.CreateInitialSyncRequest(this.UserInformation.NotesCollectionId);
            SyncStore   syncResult  = this.NOTEAdapter.Sync(syncRequest, false);

            // Verify sync change result
            this.Site.Assert.AreEqual <byte>(
                1,
                syncResult.CollectionStatus,
                "The server should return a status code 1 in the Sync command response indicate sync command success.");

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

            string[] subjects = new string[count];

            // Construct every note
            for (int i = 0; i < count; i++)
            {
                Request.SyncCollectionAdd add = new Request.SyncCollectionAdd
                {
                    ClientId        = System.Guid.NewGuid().ToString(),
                    ApplicationData = new Request.SyncCollectionAddApplicationData
                    {
                        ItemsElementName = new Request.ItemsChoiceType8[addElements.Count],
                        Items            = new object[addElements.Count]
                    }
                };

                // Since only one subject is generated in addElement, if there are multiple notes, generate unique subjects with index for every note.
                if (count > 1)
                {
                    addElements[Request.ItemsChoiceType8.Subject1] = Common.GenerateResourceName(this.Site, "subject", (uint)(i + 1));
                }

                subjects[i] = addElements[Request.ItemsChoiceType8.Subject1].ToString();
                addElements.Keys.CopyTo(add.ApplicationData.ItemsElementName, 0);
                addElements.Values.CopyTo(add.ApplicationData.Items, 0);
                addData.Add(add);
            }

            syncRequest = TestSuiteHelper.CreateSyncRequest(syncResult.SyncKey, this.UserInformation.NotesCollectionId, addData);
            SyncStore addResult = this.NOTEAdapter.Sync(syncRequest, false);

            this.Site.Assert.AreEqual <byte>(
                1,
                addResult.CollectionStatus,
                "The server should return a Status 1 in the Sync command response indicate sync command succeed.");

            this.Site.Assert.IsNotNull(
                addResult.AddResponses,
                @"The Add elements in Responses element of the Sync response should not be null.");

            this.Site.Assert.AreEqual <int>(
                count,
                addResult.AddResponses.Count,
                @"The actual number of note items should be returned in Sync response as the expected number.");

            for (int i = 0; i < count; i++)
            {
                this.Site.Assert.IsNotNull(
                    addResult.AddResponses[i],
                    @"The Add element in response should not be null.");

                this.Site.Assert.AreEqual <int>(
                    1,
                    int.Parse(addResult.AddResponses[i].Status),
                    "The server should return a Status 1 in the Sync command response indicate sync command succeed.");

                this.ExistingNoteSubjects.Add(subjects[i]);
            }

            return(addResult);
        }