Microsoft.Protocols.TestSuites.MS_ASAIRS.TestSuiteHelper.CreateSyncRequest C# (CSharp) Method

CreateSyncRequest() static private method

Build a generic Sync request without command references by using the specified sync key, folder collection ID and body preference option. If syncKey is In general, returns the XML formatted Sync request as follows:
static private CreateSyncRequest ( string syncKey, string collectionId, Request bodyPreference ) : SyncRequest
syncKey string Specify the sync key obtained from the last sync response(Refer to [MS-ASCMD]2.2.3.166.4)
collectionId string Specify the server ID of the folder to be synchronized, which can be returned by ActiveSync FolderSync command(Refer to [MS-ASCMD]2.2.3.30.5)
bodyPreference Microsoft.Protocols.TestSuites.Common.Request Sets preference information related to the type and size of information for body (Refer to [MS-ASAIRS] 2.2.2.7)
return SyncRequest
        internal static SyncRequest CreateSyncRequest(string syncKey, string collectionId, Request.BodyPreference bodyPreference)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                SyncKey = syncKey,
                CollectionId = collectionId
            };

            if (syncKey != "0")
            {
                syncCollection.GetChanges = true;
                syncCollection.GetChangesSpecified = true;
            }

            syncCollection.WindowSize = "100";

            Request.Options syncOptions = new Request.Options();
            List<object> syncOptionItems = new List<object>();
            List<Request.ItemsChoiceType1> syncOptionItemsName = new List<Request.ItemsChoiceType1>();

            if (null != bodyPreference)
            {
                syncOptionItemsName.Add(Request.ItemsChoiceType1.BodyPreference);
                syncOptionItems.Add(bodyPreference);

                // when body format is mime (Refer to [MS-ASAIRS] 2.2.2.22 Type)
                if (bodyPreference.Type == 0x4)
                {
                    syncOptionItemsName.Add(Request.ItemsChoiceType1.MIMESupport);

                    // Magic number '2' indicate server send MIME data for all messages but not S/MIME messages only
                    syncOptionItems.Add((byte)0x2);
                }
            }

            syncOptions.Items = syncOptionItems.ToArray();
            syncOptions.ItemsElementName = syncOptionItemsName.ToArray();
            syncCollection.Options = new Request.Options[] { syncOptions };

            return Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection });
        }

Same methods

TestSuiteHelper::CreateSyncRequest ( string syncKey, string collectionId, object commands, Request bodyPreferences, Request bodyPartPreferences ) : SyncRequest

Usage Example

Example #1
0
        /// <summary>
        /// Synchronize item with specified subject.
        /// </summary>
        /// <param name="subject">The subject of the item.</param>
        /// <param name="collectionId">The collection id which to sync with.</param>
        /// <param name="commands">The sync commands.</param>
        /// <param name="bodyPreferences">The bodyPreference in the options element.</param>
        /// <param name="bodyPartPreferences">The bodyPartPreference in the options element.</param>
        /// <returns>The item with specified subject.</returns>
        protected DataStructures.Sync GetSyncResult(string subject, string collectionId, object[] commands, Request.BodyPreference[] bodyPreferences, Request.BodyPartPreference[] bodyPartPreferences)
        {
            DataStructures.SyncStore syncStore;
            DataStructures.Sync      item = null;
            SyncRequest request           = TestSuiteHelper.CreateSyncRequest(this.GetInitialSyncKey(collectionId), collectionId, commands, bodyPreferences, bodyPartPreferences);

            int counter    = 0;
            int waitTime   = int.Parse(Common.GetConfigurationPropertyValue("WaitTime", this.Site));
            int retryCount = int.Parse(Common.GetConfigurationPropertyValue("RetryCount", this.Site));

            do
            {
                Thread.Sleep(waitTime);
                syncStore = this.ASAIRSAdapter.Sync(request);
                if (syncStore != null && syncStore.CollectionStatus == 1)
                {
                    item = TestSuiteHelper.GetSyncAddItem(syncStore, subject);
                }

                counter++;
            }while ((syncStore == null || item == null) && counter < retryCount);

            this.Site.Assert.IsNotNull(item, "The email item with subject {0} should be found, retry count: {1}.", subject, counter);

            this.SyncKey = syncStore.SyncKey;

            return(item);
        }
All Usage Examples Of Microsoft.Protocols.TestSuites.MS_ASAIRS.TestSuiteHelper::CreateSyncRequest