Esempio n. 1
0
        /// <summary>
        /// Build a generic Sync request without command references by using the specified sync key, folder collection ID.
        /// </summary>
        /// <param name="syncKey">The current sync key.</param>
        /// <param name="collectionId">The collection id which to sync with.</param>
        /// <returns>A Sync command request.</returns>
        private static SyncRequest CreateSyncRequest(string syncKey, string collectionId)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                SyncKey      = syncKey,
                CollectionId = collectionId
            };

            List <object> items = new List <object>();
            List <Request.ItemsChoiceType1> itemsElementName = new List <Request.ItemsChoiceType1>();

            Request.BodyPreference bodyPreference = new Request.BodyPreference()
            {
                Type                    = 1,
                TruncationSize          = 2000,
                TruncationSizeSpecified = true,
                AllOrNone               = true,
                AllOrNoneSpecified      = true
            };

            items.Add(bodyPreference);
            itemsElementName.Add(Request.ItemsChoiceType1.BodyPreference);

            syncCollection.Options = new Request.Options[]
            {
                new Request.Options()
                {
                    ItemsElementName = itemsElementName.ToArray(),
                    Items            = items.ToArray()
                }
            };

            return(Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection }));
        }
        /// <summary>
        /// Create a generic Sync request without command references by using the specified sync key, folder collectionId and body preference option.
        /// </summary>
        /// <param name="syncKey">Specify the sync key obtained from the last Sync response.</param>
        /// <param name="collectionId">Specify the serverId of the folder to be synchronized.</param>
        /// <param name="bodyPreference">Sets preference information related to the type and size of information for body.</param>
        /// <returns>The SyncRequest instance.</returns>
        internal static SyncRequest CreateSyncRequest(string syncKey, string collectionId, Request.BodyPreference bodyPreference)
        {
            Request.SyncCollection syncCollection = CreateSyncCollection(syncKey, collectionId);

            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);

                    // '2' indicates server sends 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 }));
        }
        /// <summary>
        /// Create a Sync Change request by using the specified sync key, folder collectionId and change application data.
        /// </summary>
        /// <param name="syncKey">Specify the sync key obtained from the last Sync response.</param>
        /// <param name="collectionId">Specify the serverId of the folder to be synchronized.</param>
        /// <param name="changeData">The data used to specify the Change element for Sync command.</param>
        /// <returns>The SyncRequest instance.</returns>
        internal static SyncRequest CreateSyncChangeRequest(string syncKey, string collectionId, Request.SyncCollectionChange changeData)
        {
            Request.SyncCollection syncCollection = CreateSyncCollection(syncKey, collectionId);
            syncCollection.Commands = new object[] { changeData };

            return(Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection }));
        }
        /// <summary>
        /// Call Sync command to add items to the specified folder.
        /// </summary>
        /// <param name="collectionId">The CollectionId of the specified folder.</param>
        /// <param name="subject">Subject of the item to add.</param>
        /// <param name="syncKey">The latest SyncKey.</param>
        protected void SyncAdd(string collectionId, string subject, string syncKey)
        {
            // Create Sync request.
            Request.SyncCollectionAdd add = new Request.SyncCollectionAdd
            {
                ClientId        = Guid.NewGuid().ToString(),
                ApplicationData = new Request.SyncCollectionAddApplicationData
                {
                    Items            = new object[] { subject },
                    ItemsElementName = new Request.ItemsChoiceType8[] { Request.ItemsChoiceType8.Subject2 }
                }
            };

            Request.SyncCollection collection = new Request.SyncCollection
            {
                Commands     = new object[] { add },
                CollectionId = collectionId,
                SyncKey      = syncKey
            };
            SyncRequest syncRequest = Common.CreateSyncRequest(new Request.SyncCollection[] { collection });

            // Call Sync command to add the item.
            SyncStore syncStore = this.CONAdapter.Sync(syncRequest);

            // Verify Sync command response.
            Site.Assert.AreEqual <byte>(
                1,
                syncStore.CollectionStatus,
                "If the Sync command executes successfully, the Status in response should be 1.");

            this.LatestSyncKey = syncStore.SyncKey;
        }
        /// <summary>
        /// Builds a generic Sync request without command references by using the specified sync key, folder collection ID and body preference option.
        /// </summary>
        /// <param name="syncKey">Specifies the sync key obtained from the last sync response.</param>
        /// <param name="collectionId">Specifies the server ID of the folder to be synchronized.</param>
        /// <param name="bodyPreference">Sets preference information related to the type and size of information for body.</param>
        /// <returns>Returns the SyncRequest instance</returns>
        internal static SyncRequest CreateSyncRequest(string syncKey, string collectionId, Request.BodyPreference bodyPreference)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                SyncKey      = syncKey,
                CollectionId = collectionId
            };

            // Sets Getchanges only if SyncKey != 0 since fail response is returned when the SyncKey element value is 0.
            if (syncKey != "0")
            {
                syncCollection.GetChanges          = true;
                syncCollection.GetChangesSpecified = true;
            }

            syncCollection.WindowSize = "512";

            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);
            }

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

            return(Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection }));
        }
        /// <summary>
        /// Builds a Sync change request by using the specified sync key, folder collection ID and change application data.
        /// </summary>
        /// <param name="syncKey">Specifies the sync key obtained from the last sync response.</param>
        /// <param name="collectionId">Specifies the server ID of the folder to be synchronized.</param>
        /// <param name="data">Contains the data used to specify the Change element for Sync command.</param>
        /// <returns>Returns the SyncRequest instance</returns>
        internal static SyncRequest CreateSyncRequest(string syncKey, string collectionId, List <object> data)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                SyncKey                 = syncKey,
                GetChanges              = true,
                GetChangesSpecified     = true,
                DeletesAsMoves          = false,
                DeletesAsMovesSpecified = true,
                CollectionId            = collectionId
            };

            Request.Options        option     = new Request.Options();
            Request.BodyPreference preference = new Request.BodyPreference
            {
                Type             = 2,
                Preview          = 0,
                PreviewSpecified = true
            };

            option.Items            = new object[] { preference };
            option.ItemsElementName = new Request.ItemsChoiceType1[]
            {
                Request.ItemsChoiceType1.BodyPreference,
            };

            syncCollection.Options    = new Request.Options[1];
            syncCollection.Options[0] = option;

            syncCollection.WindowSize = "512";
            syncCollection.Commands   = data.ToArray();

            return(Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection }));
        }
        /// <summary>
        /// Call Sync command to delete items.
        /// </summary>
        /// <param name="collectionId">The CollectionId of the folder.</param>
        /// <param name="syncKey">The latest SyncKey.</param>
        /// <param name="serverIds">The ServerId of the items to delete.</param>
        /// <returns>The SyncStore instance returned from Sync command.</returns>
        protected SyncStore SyncDelete(string collectionId, string syncKey, string[] serverIds)
        {
            List <Request.SyncCollectionDelete> deleteCollection = new List <Request.SyncCollectionDelete>();

            foreach (string itemId in serverIds)
            {
                Request.SyncCollectionDelete delete = new Request.SyncCollectionDelete {
                    ServerId = itemId
                };
                deleteCollection.Add(delete);
            }

            Request.SyncCollection collection = new Request.SyncCollection
            {
                Commands                = deleteCollection.ToArray(),
                DeletesAsMoves          = true,
                DeletesAsMovesSpecified = true,
                CollectionId            = collectionId,
                SyncKey = syncKey
            };

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

            SyncStore syncStore = this.CONAdapter.Sync(syncRequest);

            // Verify Sync command response.
            Site.Assert.AreEqual <byte>(
                1,
                syncStore.CollectionStatus,
                "If the Sync command executes successfully, the Status in response should be 1.");

            return(syncStore);
        }
Esempio n. 8
0
        /// <summary>
        /// Delete all the items in a folder.
        /// </summary>
        /// <param name="createdItemsCollection">The created items collection which should be deleted.</param>
        private void DeleteItemsInFolder(Collection <CreatedItems> createdItemsCollection)
        {
            foreach (CreatedItems createdItems in createdItemsCollection)
            {
                string      syncKey             = this.GetInitialSyncKey(createdItems.CollectionId);
                SyncRequest request             = TestSuiteHelper.CreateSyncRequest(syncKey, createdItems.CollectionId, null, null, null);
                DataStructures.SyncStore result = this.ASAIRSAdapter.Sync(request);

                List <Request.SyncCollectionDelete> deleteData = new List <Request.SyncCollectionDelete>();
                foreach (string subject in createdItems.ItemSubject)
                {
                    string serverId = null;
                    if (result != null)
                    {
                        foreach (DataStructures.Sync item in result.AddElements)
                        {
                            if (item.Email.Subject != null && item.Email.Subject.Equals(subject, StringComparison.CurrentCulture))
                            {
                                serverId = item.ServerId;
                                break;
                            }

                            if (item.Contact.FileAs != null && item.Contact.FileAs.Equals(subject, StringComparison.CurrentCulture))
                            {
                                serverId = item.ServerId;
                                break;
                            }

                            if (item.Calendar.Subject != null && item.Calendar.Subject.Equals(subject, StringComparison.CurrentCulture))
                            {
                                serverId = item.ServerId;
                                break;
                            }
                        }
                    }

                    this.Site.Assert.IsNotNull(serverId, "The item with subject '{0}' should be found!", subject);
                    deleteData.Add(new Request.SyncCollectionDelete()
                    {
                        ServerId = serverId
                    });
                }

                Request.SyncCollection syncCollection = TestSuiteHelper.CreateSyncCollection(result.SyncKey, createdItems.CollectionId);
                syncCollection.Commands                = deleteData.ToArray();
                syncCollection.DeletesAsMoves          = false;
                syncCollection.DeletesAsMovesSpecified = true;

                SyncRequest syncRequest = Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection });
                DataStructures.SyncStore deleteResult = this.ASAIRSAdapter.Sync(syncRequest);
                this.Site.Assert.AreEqual <byte>(
                    1,
                    deleteResult.CollectionStatus,
                    "The value of Status should be 1 to indicate the Sync command executes successfully.");
            }
        }
        /// <summary>
        /// Builds a initial Sync request by using the specified collection Id.
        /// </summary>
        /// <param name="collectionId">Folder collection Id to be synchronized.</param>
        /// <returns>Returns the SyncRequest instance</returns>
        internal static SyncRequest CreateInitialSyncRequest(string collectionId)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                CollectionId = collectionId,
                SyncKey      = "0"
            };

            return(Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection }));
        }
        /// <summary>
        /// Builds a initial Sync request by using the specified collection Id.
        /// </summary>
        /// <param name="collectionId">Folder collection Id to be synchronized.</param>
        /// <returns>Returns the SyncRequest instance</returns>
        internal static SyncRequest CreateInitialSyncRequest(string collectionId)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                CollectionId = collectionId,
                SyncKey = "0"
            };

            return Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection });
        }
Esempio n. 11
0
        /// <summary>
        /// Delete all the items in a folder.
        /// </summary>
        /// <param name="createdItems">The created items which should be deleted.</param>
        private void DeleteItemsInFolder(Collection <CreatedItems> createdItems)
        {
            foreach (CreatedItems createdItem in createdItems)
            {
                SyncStore syncResult = this.CallSyncCommand(createdItem.CollectionId, false);
                List <Request.SyncCollectionDelete> deleteData = new List <Request.SyncCollectionDelete>();
                List <string> serverIds = new List <string>();

                foreach (string subject in createdItem.ItemSubject)
                {
                    if (syncResult != null)
                    {
                        foreach (Sync item in syncResult.AddElements)
                        {
                            if (item.Email.Subject != null && item.Email.Subject.Equals(subject, StringComparison.CurrentCulture))
                            {
                                serverIds.Add(item.ServerId);
                            }

                            if (item.Calendar.Subject != null && item.Calendar.Subject.Equals(subject, StringComparison.CurrentCulture))
                            {
                                serverIds.Add(item.ServerId);
                            }
                        }
                    }

                    Site.Assert.AreNotEqual <int>(0, serverIds.Count, "The items with subject '{0}' should be found!", subject);

                    foreach (string serverId in serverIds)
                    {
                        deleteData.Add(new Request.SyncCollectionDelete()
                        {
                            ServerId = serverId
                        });
                    }

                    Request.SyncCollection syncCollection = new Request.SyncCollection
                    {
                        Commands                = deleteData.ToArray(),
                        DeletesAsMoves          = false,
                        DeletesAsMovesSpecified = true,
                        CollectionId            = createdItem.CollectionId,
                        SyncKey = syncResult.SyncKey
                    };

                    SyncRequest syncRequest  = Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection });
                    SyncStore   deleteResult = this.CONAdapter.Sync(syncRequest);

                    Site.Assert.AreEqual <byte>(
                        1,
                        deleteResult.CollectionStatus,
                        "The value of Status should be 1 to indicate the Sync command executed successfully.");
                }
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Get the request of Sync command.
        /// </summary>
        /// <param name="collectionId">The CollectionId of the folder to sync.</param>
        /// <param name="syncKey">The SyncKey of the latest sync.</param>
        /// <returns>The request of Sync command.</returns>
        public static SyncRequest GetSyncRequest(string collectionId, string syncKey)
        {
            // Create the Sync command request.
            Request.SyncCollection[] synCollections = new Request.SyncCollection[1];
            synCollections[0] = new Request.SyncCollection {
                SyncKey = syncKey, CollectionId = collectionId
            };
            SyncRequest syncRequest = Common.CreateSyncRequest(synCollections);

            return(syncRequest);
        }
        /// <summary>
        /// Create an initial Sync request by using the specified collection Id.
        /// </summary>
        /// <param name="collectionId">Identify the folder as the collection being synchronized.</param>
        /// <param name="supportedElements">The elements in Supported element.</param>
        /// <returns>The SyncRequest instance.</returns>
        internal static SyncRequest CreateInitialSyncRequest(string collectionId, Request.Supported supportedElements)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                CollectionId = collectionId,
                SyncKey      = "0",
                Supported    = supportedElements
            };

            return(Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection }));
        }
        /// <summary>
        /// Create an initial Sync request by using the specified collection Id.
        /// </summary>
        /// <param name="collectionId">Identify the folder as the collection being synchronized.</param>
        /// <param name="supportedElements">The elements in Supported element.</param>
        /// <returns>The SyncRequest instance.</returns>
        internal static SyncRequest CreateInitialSyncRequest(string collectionId, Request.Supported supportedElements)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                CollectionId = collectionId,
                SyncKey = "0",
                Supported = supportedElements
            };

            return Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection });
        }
Esempio n. 15
0
        /// <summary>
        /// Create an instance of SyncCollection.
        /// </summary>
        /// <param name="syncKey">Specify the synchronization key obtained from the last sync command response.</param>
        /// <param name="collectionId">Specify the serverId of the folder to be synchronized, which can be returned by ActiveSync FolderSync command.</param>
        /// <returns>An instance of SyncCollection.</returns>
        internal static Request.SyncCollection CreateSyncCollection(string syncKey, string collectionId)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                SyncKey             = syncKey,
                GetChanges          = true,
                GetChangesSpecified = true,
                CollectionId        = collectionId,
                WindowSize          = "100"
            };

            return(syncCollection);
        }
        /// <summary>
        /// Get the request of Sync command.
        /// </summary>
        /// <param name="collectionId">The collection id of the folder to sync.</param>
        /// <param name="syncKey">The SyncKey of the latest sync.</param>
        /// <param name="bodyPartPreference">The bodyPartPreference in the options element.</param>
        /// <param name="bodyPreference">The bodyPreference in the options element.</param>
        /// <param name="conversationMode">The value of ConversationMode element.</param>
        /// <returns>The request of Sync command.</returns>
        internal static SyncRequest GetSyncRequest(string collectionId, string syncKey, Request.BodyPartPreference bodyPartPreference, Request.BodyPreference bodyPreference, bool conversationMode)
        {
            // Create the Sync command request.
            Request.SyncCollection[] synCollections = new Request.SyncCollection[1];
            synCollections[0] = new Request.SyncCollection {
                SyncKey = syncKey, CollectionId = collectionId
            };

            List <object> items = new List <object>();
            List <Request.ItemsChoiceType1> itemsElementName = new List <Request.ItemsChoiceType1>();

            if (bodyPartPreference != null)
            {
                items.Add(bodyPartPreference);
                itemsElementName.Add(Request.ItemsChoiceType1.BodyPartPreference);
            }

            if (bodyPreference != null)
            {
                items.Add(bodyPreference);
                itemsElementName.Add(Request.ItemsChoiceType1.BodyPreference);
            }

            if (conversationMode)
            {
                synCollections[0].ConversationMode          = true;
                synCollections[0].ConversationModeSpecified = true;
                synCollections[0].Options    = new Request.Options[1];
                synCollections[0].Options[0] = new Request.Options
                {
                    ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.FilterType },
                    Items            = new object[] { (byte)1 }
                };
            }

            if (items.Count > 0)
            {
                synCollections[0].Options = new Request.Options[]
                {
                    new Request.Options()
                    {
                        ItemsElementName = itemsElementName.ToArray(),
                        Items            = items.ToArray()
                    }
                };
            }

            return(Common.CreateSyncRequest(synCollections));
        }
        /// <summary>
        /// Get the request of Sync command.
        /// </summary>
        /// <param name="collectionId">The collection id of the folder to sync.</param>
        /// <param name="syncKey">The SyncKey of the latest sync.</param>
        /// <param name="bodyPartPreference">The bodyPartPreference in the options element.</param>
        /// <param name="bodyPreference">The bodyPreference in the options element.</param>
        /// <param name="conversationMode">The value of ConversationMode element.</param>
        /// <returns>The request of Sync command.</returns>
        internal static SyncRequest GetSyncRequest(string collectionId, string syncKey, Request.BodyPartPreference bodyPartPreference, Request.BodyPreference bodyPreference, bool conversationMode)
        {
            // Create the Sync command request.
            Request.SyncCollection[] synCollections = new Request.SyncCollection[1];
            synCollections[0] = new Request.SyncCollection { SyncKey = syncKey, CollectionId = collectionId };

            List<object> items = new List<object>();
            List<Request.ItemsChoiceType1> itemsElementName = new List<Request.ItemsChoiceType1>();

            if (bodyPartPreference != null)
            {
                items.Add(bodyPartPreference);
                itemsElementName.Add(Request.ItemsChoiceType1.BodyPartPreference);
            }

            if (bodyPreference != null)
            {
                items.Add(bodyPreference);
                itemsElementName.Add(Request.ItemsChoiceType1.BodyPreference);
            }

            if (conversationMode)
            {
                synCollections[0].ConversationMode = true;
                synCollections[0].ConversationModeSpecified = true;
                synCollections[0].Options = new Request.Options[1];
                synCollections[0].Options[0] = new Request.Options
                {
                    ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.FilterType },
                    Items = new object[] { (byte)1 }
                };
            }

            if (items.Count > 0)
            {
                synCollections[0].Options = new Request.Options[]
                {
                    new Request.Options()
                    {
                        ItemsElementName = itemsElementName.ToArray(),
                        Items = items.ToArray()
                    }
                };
            }

            return Common.CreateSyncRequest(synCollections);
        }
        /// <summary>
        /// Create a Sync delete operation request which would be used to delete items permanently.
        /// </summary>
        /// <param name="syncKey">The synchronization state of a collection.</param>
        /// <param name="collectionId">The server ID of the folder.</param>
        /// <param name="serverId">The server ID of the item which will be deleted.</param>
        /// <returns>The Sync delete operation request.</returns>
        protected static SyncRequest CreateSyncPermanentDeleteRequest(string syncKey, string collectionId, string serverId)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                SyncKey = syncKey,
                CollectionId = collectionId,
                WindowSize = "100",
                DeletesAsMoves = false,
                DeletesAsMovesSpecified = true
            };

            Request.SyncCollectionDelete deleteData = new Request.SyncCollectionDelete { ServerId = serverId };

            syncCollection.Commands = new object[] { deleteData };

            return Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection });
        }
        /// <summary>
        /// Builds a Sync delete request by using the specified sync key, folder collection ID, item serverID and deletesAsMoves option.
        /// In general, returns the XML formatted Sync request as follows:
        /// <!--
        /// <?xml version="1.0" encoding="utf-8"?>
        /// <Sync xmlns="AirSync">
        ///   <Collections>
        ///     <Collection>
        ///       <SyncKey>0</SyncKey>
        ///       <CollectionId>5</CollectionId>
        ///       <GetChanges>1</GetChanges>
        ///       <DeletesAsMoves>1</DeletesAsMoves>
        ///       <WindowSize>100</WindowSize>
        ///       <Commands>
        ///         <Delete>
        ///           <ServerId>5:1</ServerId>
        ///         </Delete>
        ///       </Commands>
        ///     </Collection>
        ///   </Collections>
        /// </Sync>
        /// -->
        /// </summary>
        /// <param name="collectionId">Specify the serverId of the folder to be synchronized, which can be returned by ActiveSync FolderSync command(Refer to [MS-ASCMD]2.2.3.30.5)</param>
        /// <param name="syncKey">Specify the sync key obtained from the last sync response(Refer to [MS-ASCMD]2.2.3.166.4)</param>
        /// <param name="serverId">Specify a unique identifier that was assigned by the server for a mailItem, which can be returned by ActiveSync Sync command</param>
        /// <returns>Returns the SyncRequest instance</returns>
        internal static SyncRequest CreateSyncDeleteRequest(string collectionId, string syncKey, string serverId)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                SyncKey                 = syncKey,
                CollectionId            = collectionId,
                WindowSize              = "100",
                DeletesAsMoves          = false,
                DeletesAsMovesSpecified = true
            };

            Request.SyncCollectionDelete deleteData = new Request.SyncCollectionDelete {
                ServerId = serverId
            };

            syncCollection.Commands = new object[] { deleteData };

            return(Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection }));
        }
        /// <summary>
        /// Builds a generic Sync request without command references by using the specified sync key, folder collection ID and body preference option.
        /// </summary>
        /// <param name="syncKey">Specify the sync key obtained from the last sync response</param>
        /// <param name="collectionId">Specify the server ID of the folder to be synchronized, which can be returned by ActiveSync FolderSync command</param>
        /// <param name="rightsManagementSupport">A boolean value specifies whether the server will decompress and decrypt rights-managed email messages before sending them to the client or not</param>
        /// <returns>Returns the Sync request instance</returns>
        internal static SyncRequest CreateSyncRequest(string syncKey, string collectionId, bool?rightsManagementSupport)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                SyncKey      = syncKey,
                CollectionId = collectionId
            };

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

            syncCollection.WindowSize = "100";

            Request.BodyPreference bodyPreference = new Request.BodyPreference {
                Type = 1
            };

            Request.Options syncOptions     = new Request.Options();
            List <object>   syncOptionItems = new List <object> {
                bodyPreference
            };

            List <Request.ItemsChoiceType1> syncOptionItemsName = new List <Request.ItemsChoiceType1>
            {
                Request.ItemsChoiceType1.BodyPreference
            };

            if (rightsManagementSupport != null)
            {
                syncOptionItems.Add(rightsManagementSupport);
                syncOptionItemsName.Add(Request.ItemsChoiceType1.RightsManagementSupport);
            }

            syncOptions.Items            = syncOptionItems.ToArray();
            syncOptions.ItemsElementName = syncOptionItemsName.ToArray();
            syncCollection.Options       = new Request.Options[] { syncOptions };
            return(Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection }));
        }
Esempio n. 21
0
        /// <summary>
        /// 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:
        /// <!--
        /// <?xml version="1.0" encoding="utf-8"?>
        /// <Sync xmlns="AirSync">
        ///   <Collections>
        ///     <Collection>
        ///       <SyncKey>0</SyncKey>
        ///       <CollectionId>5</CollectionId>
        ///       <DeletesAsMoves>1</DeletesAsMoves>
        ///       <GetChanges>1</GetChanges>
        ///       <WindowSize>100</WindowSize>
        ///       <Options>
        ///         <MIMESupport>0</MIMESupport>
        ///         <airsyncbase:BodyPreference>
        ///           <airsyncbase:Type>2</airsyncbase:Type>
        ///           <airsyncbase:TruncationSize>5120</airsyncbase:TruncationSize>
        ///         </airsyncbase:BodyPreference>
        ///       </Options>
        ///     </Collection>
        ///   </Collections>
        /// </Sync>
        /// -->
        /// </summary>
        /// <param name="syncKey">Specify the sync key obtained from the last sync response(Refer to [MS-ASCMD]2.2.3.166.4)</param>
        /// <param name="collectionId">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)</param>
        /// <param name="bodyPreference">Sets preference information related to the type and size of information for body (Refer to [MS-ASAIRS] 2.2.2.7)</param>
        /// <returns>Returns the SyncRequest instance</returns>
        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 }));
        }
Esempio n. 22
0
        /// <summary>
        /// Delete the specified item.
        /// </summary>
        /// <param name="itemsToDelete">The collection of the items to delete.</param>
        private void DeleteCreatedItems(Collection <CreatedItems> itemsToDelete)
        {
            foreach (CreatedItems itemToDelete in itemsToDelete)
            {
                SyncRequest syncRequest = Common.CreateInitialSyncRequest(itemToDelete.CollectionId);
                DataStructures.SyncStore initSyncResult = this.ASRMAdapter.Sync(syncRequest);
                DataStructures.SyncStore result         = this.SyncChanges(initSyncResult.SyncKey, itemToDelete.CollectionId, false);
                int i = 0;
                if (result.AddElements != null)
                {
                    Request.SyncCollectionDelete[] deletes = new Request.SyncCollectionDelete[result.AddElements.Count];
                    foreach (DataStructures.Sync item in result.AddElements)
                    {
                        foreach (string subject in itemToDelete.ItemSubject)
                        {
                            if (item.Email.Subject.Equals(subject))
                            {
                                Request.SyncCollectionDelete delete = new Request.SyncCollectionDelete
                                {
                                    ServerId = item.ServerId
                                };
                                deletes[i] = delete;
                            }
                        }

                        i++;
                    }

                    Request.SyncCollection syncCollection = TestSuiteHelper.CreateSyncCollection(result.SyncKey, itemToDelete.CollectionId);
                    syncCollection.Commands = deletes;

                    syncRequest = Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection });
                    DataStructures.SyncStore deleteResult = this.ASRMAdapter.Sync(syncRequest);
                    this.Site.Assert.AreEqual <byte>(
                        1,
                        deleteResult.CollectionStatus,
                        "The value of 'Status' should be 1 which indicates the Sync command executes successfully.");
                }
            }
        }
        /// <summary>
        /// Build a generic Sync request without command references by using the specified sync key, folder collection ID and body preference option.
        /// In general, returns the XML formatted Sync request as follows:
        /// <!--
        /// <?xml version="1.0" encoding="utf-8"?>
        /// <Sync xmlns="AirSync">
        ///   <Collections>
        ///     <Collection>
        ///       <SyncKey>0</SyncKey>
        ///       <CollectionId>5</CollectionId>
        ///       <DeletesAsMoves>1</DeletesAsMoves>
        ///       <GetChanges>1</GetChanges>
        ///       <WindowSize>152</WindowSize>
        ///       <Options>
        ///         <MIMESupport>0</MIMESupport>
        ///         <airsyncbase:BodyPreference>
        ///           <airsyncbase:Type>2</airsyncbase:Type>
        ///         </airsyncbase:BodyPreference>
        ///       </Options>
        ///     </Collection>
        ///   </Collections>
        /// </Sync>
        /// -->
        /// </summary>
        /// <param name="collectionId">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)</param>
        /// <param name="syncKey">Specify the sync key obtained from the last sync response(Refer to [MS-ASCMD]2.2.3.166.4)</param>
        /// <param name="getChanges">Sets sync collection information related to the GetChanges</param>
        /// <returns>Returns the SyncRequest instance</returns>
        internal static SyncRequest CreateSyncRequest(string collectionId, string syncKey, bool getChanges)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                WindowSize   = "512",
                SyncKey      = syncKey,
                CollectionId = collectionId,
                Supported    = null
            };

            if (getChanges)
            {
                syncCollection.GetChanges          = true;
                syncCollection.GetChangesSpecified = true;
            }

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

            syncOptionItems.Add(
                new Request.BodyPreference()
            {
                Type                    = 2,
                TruncationSize          = 0,
                TruncationSizeSpecified = false,
                Preview                 = 0,
                PreviewSpecified        = false
            });
            syncOptions.Items            = syncOptionItems.ToArray();
            syncOptions.ItemsElementName = syncOptionItemsName.ToArray();
            syncCollection.Options       = new Request.Options[] { syncOptions };

            return(Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection }));
        }
        /// <summary>
        /// Creates a Sync change request by using the specified sync key, folder collection ID and change application data.
        /// </summary>
        /// <param name="syncKey">Specify the sync key obtained from the last sync response.</param>
        /// <param name="collectionId">Specify the server ID of the folder to be synchronized.</param>
        /// <param name="data">Contains the data used to specify the Change element for Sync command.</param>
        /// <returns>Returns the SyncRequest instance.</returns>
        internal static SyncRequest CreateSyncRequest(string syncKey, string collectionId, List<object> data)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                SyncKey = syncKey,
                GetChanges = true,
                GetChangesSpecified = true,
                DeletesAsMoves = false,
                DeletesAsMovesSpecified = true,
                CollectionId = collectionId
            };

            Request.Options option = new Request.Options();
            Request.BodyPreference preference = new Request.BodyPreference
            {
                Type = 2,
                Preview = 0,
                PreviewSpecified = false
            };

            option.Items = new object[] { preference };
            option.ItemsElementName = new Request.ItemsChoiceType1[]
            {
                Request.ItemsChoiceType1.BodyPreference,
            };

            syncCollection.Options = new Request.Options[1];
            syncCollection.Options[0] = option;

            syncCollection.WindowSize = "512";

            if (data != null)
            {
                syncCollection.Commands = data.ToArray();
            }

            return Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection });
        }
        /// <summary>
        /// Builds a initial Sync request by using the specified collection Id.
        /// In order to sync the content of a folder, an initial sync key for the folder MUST be obtained from the server.
        /// The client obtains the key by sending an initial Sync request with a SyncKey element value of zero and the CollectionId element
        /// In general, returns the XML formatted Sync request as follows:
        /// <!--
        /// <?xml version="1.0" encoding="utf-8"?>
        /// <Sync xmlns="AirSync">
        ///   <Collections>
        ///     <Collection>
        ///       <SyncKey>0</SyncKey>
        ///       <CollectionId>5</CollectionId>
        ///     </Collection>
        ///   </Collections>
        /// </Sync>
        /// -->
        /// </summary>
        /// <param name="collectionId">Identify the folder as the collection being synchronized, which can be returned by ActiveSync FolderSync command(Refer to [MS-ASCMD]2.2.3.30.5)</param>
        /// <param name="supported">Specifies which contact and calendar elements in a Sync request are managed by the client and therefore not ghosted.</param>
        /// <returns>Returns the SyncRequest instance</returns>
        internal static SyncRequest InitializeSyncRequest(string collectionId, Request.Supported supported)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                Supported    = supported,
                WindowSize   = "512",
                CollectionId = collectionId,
                SyncKey      = "0"
            };

            List <object> items = new List <object>();
            List <Request.ItemsChoiceType1> itemsElementName = new List <Request.ItemsChoiceType1>
            {
                Request.ItemsChoiceType1.BodyPreference
            };

            items.Add(
                new Request.BodyPreference()
            {
                TruncationSize          = 0,
                TruncationSizeSpecified = false,
                Type             = 2,
                Preview          = 0,
                PreviewSpecified = false,
            });

            Request.Options option = new Request.Options
            {
                Items            = items.ToArray(),
                ItemsElementName = itemsElementName.ToArray()
            };

            syncCollection.Options = new Request.Options[] { option };

            SyncRequest request = Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection });

            return(request);
        }
        /// <summary>
        /// Builds a generic Sync request without command references by using the specified sync key, folder collection ID and body preference option.
        /// </summary>
        /// <param name="syncKey">Specify the sync key obtained from the last sync response</param>
        /// <param name="collectionId">Specify the server ID of the folder to be synchronized, which can be returned by ActiveSync FolderSync command</param>
        /// <param name="rightsManagementSupport">A boolean value specifies whether the server will decompress and decrypt rights-managed email messages before sending them to the client or not</param>
        /// <returns>Returns the Sync request instance</returns>
        internal static SyncRequest CreateSyncRequest(string syncKey, string collectionId, bool? rightsManagementSupport)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                SyncKey = syncKey,
                CollectionId = collectionId
            };

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

            syncCollection.WindowSize = "100";

            Request.BodyPreference bodyPreference = new Request.BodyPreference { Type = 1 };

            Request.Options syncOptions = new Request.Options();
            List<object> syncOptionItems = new List<object> { bodyPreference };

            List<Request.ItemsChoiceType1> syncOptionItemsName = new List<Request.ItemsChoiceType1>
            {
                Request.ItemsChoiceType1.BodyPreference
            };

            if (rightsManagementSupport != null)
            {
                syncOptionItems.Add(rightsManagementSupport);
                syncOptionItemsName.Add(Request.ItemsChoiceType1.RightsManagementSupport);
            }

            syncOptions.Items = syncOptionItems.ToArray();
            syncOptions.ItemsElementName = syncOptionItemsName.ToArray();
            syncCollection.Options = new Request.Options[] { syncOptions };
            return Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection });
        }
Esempio n. 27
0
        /// <summary>
        /// Get the initial syncKey of the specified folder.
        /// </summary>
        /// <param name="collectionId">The collection id of the specified folder.</param>
        /// <returns>The initial syncKey of the specified folder.</returns>
        protected string GetInitialSyncKey(string collectionId)
        {
            // Obtains the key by sending an initial Sync request with a SyncKey element value of zero and the CollectionId element
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                CollectionId = collectionId,
                SyncKey      = "0"
            };

            SyncRequest syncRequest = Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection });
            SyncStore   syncResult  = this.PROVAdapter.Sync(syncRequest);

            Site.Assert.IsNotNull(
                syncResult,
                "The result for an initial synchronize should not null.");

            // Verify sync result.
            Site.Assert.AreEqual <byte>(
                1,
                syncResult.CollectionStatus,
                "If the Sync command executes successfully, the Status in response should be 1.");

            return(syncResult.SyncKey);
        }
Esempio n. 28
0
        public void MSASNOTE_S01_TC04_Sync_SupportedError()
        {
            #region Call an initial method Sync including the Supported option.
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                CollectionId = this.UserInformation.NotesCollectionId,
                SyncKey      = "0",
                Supported    = new Request.Supported()
            };
            SyncRequest syncRequest = Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection });
            SyncStore   syncResult  = this.NOTEAdapter.Sync(syncRequest, false);

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

            // Verify MS-ASNOTE requirement: MS-ASNOTE_R114
            Site.CaptureRequirementIfAreEqual <int>(
                4,
                syncResult.Status,
                114,
                @"[In Sync Command Response] If the airsync:Supported element ([MS-ASCMD] section 2.2.3.164) is included in a Sync command request for Notes class data, the server returns a Status element with a value of 4, as specified in [MS-ASCMD] section 2.2.3.162.16.");

            #endregion
        }
Esempio n. 29
0
        /// <summary>
        /// Delete the specified item.
        /// </summary>
        /// <param name="itemsToDelete">The collection of the items to delete.</param>
        private void DeleteCreatedItems(Collection <CreatedItems> itemsToDelete)
        {
            foreach (CreatedItems itemToDelete in itemsToDelete)
            {
                Collection <string> itemsToDeleteServerIds = this.SyncCaseRelativeItems(itemToDelete.CollectionId, itemToDelete.ItemSubject[0], true);

                SyncRequest syncRequest  = CreateSyncRequest(this.GetInitialSyncKey(itemToDelete.CollectionId), itemToDelete.CollectionId);
                SyncStore   syncResponse = this.PROVAdapter.Sync(syncRequest);
                Site.Assert.AreNotEqual <int>(0, syncResponse.AddElements.Count, "There is not items added in {0} folder.", itemToDelete.CollectionId);

                List <Request.SyncCollectionDelete> deleteData = new List <Request.SyncCollectionDelete>();
                Request.SyncCollection syncCollection          = new Request.SyncCollection();

                foreach (string serverId in itemsToDeleteServerIds)
                {
                    deleteData.Add(new Request.SyncCollectionDelete()
                    {
                        ServerId = serverId
                    });
                }

                syncCollection.Commands                = deleteData.ToArray();
                syncCollection.SyncKey                 = syncResponse.SyncKey;
                syncCollection.CollectionId            = itemToDelete.CollectionId;
                syncCollection.DeletesAsMoves          = false;
                syncCollection.DeletesAsMovesSpecified = true;

                syncRequest = Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection });
                SyncStore deleteResult = this.PROVAdapter.Sync(syncRequest);

                Site.Assert.AreEqual <byte>(
                    1,
                    deleteResult.CollectionStatus,
                    "The value of Status should be 1 to indicate the Sync command executes successfully.");
            }
        }
        /// <summary>
        /// Build a generic Sync request without command references by using the specified sync key, folder collection ID and body preference option.
        /// In general, returns the XML formatted Sync request as follows:
        /// <!--
        /// <?xml version="1.0" encoding="utf-8"?>
        /// <Sync xmlns="AirSync">
        ///   <Collections>
        ///     <Collection>
        ///       <SyncKey>0</SyncKey>
        ///       <CollectionId>5</CollectionId>
        ///       <DeletesAsMoves>1</DeletesAsMoves>
        ///       <GetChanges>1</GetChanges>
        ///       <WindowSize>152</WindowSize>
        ///       <Options>
        ///         <MIMESupport>0</MIMESupport>
        ///         <airsyncbase:BodyPreference>
        ///           <airsyncbase:Type>2</airsyncbase:Type>
        ///         </airsyncbase:BodyPreference>
        ///       </Options>
        ///     </Collection>
        ///   </Collections>
        /// </Sync>
        /// -->
        /// </summary>
        /// <param name="collectionId">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)</param>
        /// <param name="syncKey">Specify the sync key obtained from the last sync response(Refer to [MS-ASCMD]2.2.3.166.4)</param>
        /// <param name="getChanges">Sets sync collection information related to the GetChanges</param>
        /// <returns>Returns the SyncRequest instance</returns>
        internal static SyncRequest CreateSyncRequest(string collectionId, string syncKey, bool getChanges)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                WindowSize = "512",
                SyncKey = syncKey,
                CollectionId = collectionId,
                Supported = null
            };

            if (getChanges)
            {
                syncCollection.GetChanges = true;
                syncCollection.GetChangesSpecified = true;
            }

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

            syncOptionItems.Add(
                new Request.BodyPreference()
                {
                    Type = 2,
                    TruncationSize = 0,
                    TruncationSizeSpecified = false,
                    Preview = 0,
                    PreviewSpecified = false
                });
            syncOptions.Items = syncOptionItems.ToArray();
            syncOptions.ItemsElementName = syncOptionItemsName.ToArray();
            syncCollection.Options = new Request.Options[] { syncOptions };

            return Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection });
        }
Esempio n. 31
0
        public void MSASCMD_S19_TC41_Sync_MoreThanOneConflicts()
        {
            Request.Options option = new Request.Options
            {
                Items = new object[] { (byte)1, (byte)1 },
                ItemsElementName =
                    new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.Conflict, Request.ItemsChoiceType1.Conflict }
            };

            Request.SyncCollection collection = new Request.SyncCollection
            {
                Options = new Request.Options[] { option },
                SyncKey = "0",
                CollectionId = this.User1Information.ContactsCollectionId
            };

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

            SyncRequest syncRequest = new SyncRequest { RequestData = syncRequestData };
            SyncResponse syncResponse = this.Sync(syncRequest);

            if (Common.IsRequirementEnabled(2075, this.Site))
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R2075");

                // Verify MS-ASCMD requirement: MS-ASCMD_R2075
                Site.CaptureRequirementIfAreEqual<uint>(
                    1,
                    Convert.ToUInt32(TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Status)),
                    2075,
                    @"[In Appendix A: Product Behavior] The implementation does not return a protocol status error in response to such a command request [more than one Conflict element as the child of an Options element]. (Exchange 2007 and above follow this behavior.)");
            }
        }
Esempio n. 32
0
        public void MSASCMD_S19_TC45_Sync_ConversationMode()
        {
            Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The airsync:ConversationMode element is not supported when the MS-ASProtocolVersion header is set to 12.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #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

            #region Switch current user to User2
            this.SwitchUser(this.User2Information);
            TestSuiteBase.RecordCaseRelativeItems(this.User2Information, this.User2Information.InboxCollectionId, emailSubject);
            this.CheckEmail(this.User2Information.InboxCollectionId, emailSubject, null);
            #endregion

            #region Call Sync command with ConversationMode set to true.
            Request.SyncCollection collection = new Request.SyncCollection
            {
                SyncKey = this.LastSyncKey,
                Options = new Request.Options[]
                {
                    new Request.Options
                    {
                        Items = new object[] { (byte)1 },
                        ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.FilterType }
                    }
                },
                CollectionId = this.User2Information.InboxCollectionId,
                Commands = null,
                GetChanges = true,
                GetChangesSpecified = true,
                ConversationMode = true,
                ConversationModeSpecified = true
            };

            SyncRequest syncRequest = TestSuiteBase.CreateEmptySyncRequest(this.User2Information.InboxCollectionId);
            this.Sync(syncRequest);
            collection.SyncKey = this.LastSyncKey;
            syncRequest.RequestData.Collections = new Request.SyncCollection[] { collection };
            SyncResponse syncResponse = this.Sync(syncRequest);
            Site.Assert.IsNotNull(syncResponse.ResponseData.Item, "The items returned in the Sync command response should not be null.");
            string serverId = TestSuiteBase.FindServerId(syncResponse, "Subject", emailSubject);
            Site.Assert.IsTrue(!string.IsNullOrEmpty(serverId), "The new email should be included in the response of the Sync command with ConversationMode.");

            Response.SyncCollectionsCollectionCommands commandsByConversationMode = TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Commands) as Response.SyncCollectionsCollectionCommands;
            Site.Assert.IsNotNull(commandsByConversationMode.Add, "The Add element returned in the Sync command response should not be null.");
            List<string> serverIdsByConversationMode = new List<string>();

            foreach (Response.SyncCollectionsCollectionCommandsAdd add in commandsByConversationMode.Add)
            {
                serverIdsByConversationMode.Add(add.ServerId);
            }

            // Call Sync with FilterType set to 1 to get items that are dated within 1 day in Inbox folder.
            syncRequest = TestSuiteBase.CreateEmptySyncRequest(this.User2Information.InboxCollectionId, (byte)1);
            this.Sync(syncRequest);
            syncRequest.RequestData.Collections[0].SyncKey = this.LastSyncKey;
            syncResponse = this.Sync(syncRequest);
            Site.Assert.IsNotNull(syncResponse.ResponseData.Item, "The items returned in the Sync command response should not be null.");
            Response.SyncCollectionsCollectionCommands commands = TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Commands) as Response.SyncCollectionsCollectionCommands;
            Site.Assert.IsNotNull(commands.Add, "The Add element returned in the Sync command response should not be null.");
            List<string> serverIds = new List<string>();

            foreach (Response.SyncCollectionsCollectionCommandsAdd add in commands.Add)
            {
                serverIds.Add(add.ServerId);
            }

            Site.Assert.IsTrue(serverIdsByConversationMode.Count > 0, "There should be one item in serverIdsByConversationMode at least.");

            bool isVerifyR2107 = true;
            foreach (string item in serverIdsByConversationMode)
            {
                if (!serverIds.Contains(item))
                {
                    isVerifyR2107 = false;
                    break;
                }
            }

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R2107
            Site.CaptureRequirementIfIsTrue(
                isVerifyR2107,
                2107,
                @"[In ConversationMode(Sync)] Setting the ConversationMode element value to 1 (TRUE) results in retrieving all emails that match the conversations received within the date filter specified.");
            #endregion
        }
        /// <summary>
        /// Get the initial syncKey of the specified folder.
        /// </summary>
        /// <param name="collectionId">The collection id of the specified folder.</param>
        /// <returns>The initial syncKey of the specified folder.</returns>
        protected string GetInitialSyncKey(string collectionId)
        {
            // Obtains the key by sending an initial Sync request with a SyncKey element value of zero and the CollectionId element
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                CollectionId = collectionId,
                SyncKey = "0"
            };

            SyncRequest syncRequest = Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection });
            SyncStore syncResult = this.PROVAdapter.Sync(syncRequest);

            Site.Assert.IsNotNull(
                syncResult,
                "The result for an initial synchronize should not null.");

            // Verify sync result.
            Site.Assert.AreEqual<byte>(
                1,
                syncResult.CollectionStatus,
                "If the Sync command executes successfully, the Status in response should be 1.");

            return syncResult.SyncKey;
        }
Esempio n. 34
0
        public void MSASAIRS_S05_TC01_Location()
        {
            Site.Assume.AreNotEqual <string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Location element is supported when the MS-ASProtocolVersion header is set to 16.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");
            Site.Assume.AreNotEqual <string>("14.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Location element is supported when the MS-ASProtocolVersion header is set to 16.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");
            Site.Assume.AreNotEqual <string>("14.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Location element is supported when the MS-ASProtocolVersion header is set to 16.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region Call Sync command with Add element to add an appointment to the server
            Request.SyncCollectionAddApplicationData applicationData = new Request.SyncCollectionAddApplicationData();

            List <object> items = new List <object>();
            List <Request.ItemsChoiceType8> itemsElementName = new List <Request.ItemsChoiceType8>();

            string subject = Common.GenerateResourceName(Site, "Subject");
            items.Add(subject);
            itemsElementName.Add(Request.ItemsChoiceType8.Subject);

            // MeetingStauts is set to 0, which means it is an appointment with no attendees.
            byte meetingStatus = 0;
            items.Add(meetingStatus);
            itemsElementName.Add(Request.ItemsChoiceType8.MeetingStatus);

            Request.Location location = new Request.Location();
            location.Accuracy                  = (double)1;
            location.AccuracySpecified         = true;
            location.Altitude                  = (double)55.46;
            location.AltitudeAccuracy          = (double)1;
            location.AltitudeAccuracySpecified = true;
            location.AltitudeSpecified         = true;
            location.Annotation                = "Location sample annotation";
            location.City               = "Location sample city";
            location.Country            = "Location sample country";
            location.DisplayName        = "Location sample dislay name";
            location.Latitude           = (double)11.56;
            location.LatitudeSpecified  = true;
            location.LocationUri        = "Location Uri";
            location.Longitude          = (double)1.9;
            location.LongitudeSpecified = true;
            location.PostalCode         = "Location sample postal code";
            location.State              = "Location sample state";
            location.Street             = "Location sample street";
            items.Add(location);
            itemsElementName.Add(Request.ItemsChoiceType8.Location);

            applicationData.Items            = items.ToArray();
            applicationData.ItemsElementName = itemsElementName.ToArray();
            SyncRequest syncAddRequest = TestSuiteHelper.CreateSyncAddRequest(this.GetInitialSyncKey(this.User1Information.CalendarCollectionId), this.User1Information.CalendarCollectionId, applicationData);

            DataStructures.SyncStore syncAddResponse = this.ASAIRSAdapter.Sync(syncAddRequest);
            Site.Assert.IsTrue(syncAddResponse.AddResponses[0].Status.Equals("1"), "The sync add operation should be success; It is:{0} actually", syncAddResponse.AddResponses[0].Status);

            // Add the appointment to clean up list.
            this.RecordCaseRelativeItems(this.User1Information.UserName, this.User1Information.CalendarCollectionId, subject);
            #endregion

            #region Call Sync command to get the new added calendar item.
            DataStructures.Sync syncItem = this.GetSyncResult(subject, this.User1Information.CalendarCollectionId, null, null, null);
            #endregion

            #region Call ItemOperations command to reterive the added calendar item.
            this.GetItemOperationsResult(this.User1Information.CalendarCollectionId, syncItem.ServerId, null, null, null, null);
            #endregion

            #region Call Sync command to remove the location of the added calender item.
            // Create empty change items list.
            List <object> changeItems = new List <object>();
            List <Request.ItemsChoiceType7> changeItemsElementName = new List <Request.ItemsChoiceType7>();

            // Create an empty location.
            location = new Request.Location();

            // Add the location field name into the change items element name list.
            changeItemsElementName.Add(Request.ItemsChoiceType7.Location);
            // Add the empty location value to the change items value list.
            changeItems.Add(location);

            // Create sync collection change.
            Request.SyncCollectionChange collectionChange = new Request.SyncCollectionChange
            {
                ServerId        = syncItem.ServerId,
                ApplicationData = new Request.SyncCollectionChangeApplicationData
                {
                    ItemsElementName = changeItemsElementName.ToArray(),
                    Items            = changeItems.ToArray()
                }
            };

            // Create change sync collection
            Request.SyncCollection collection = new Request.SyncCollection
            {
                SyncKey      = this.SyncKey,
                CollectionId = this.User1Information.CalendarCollectionId,
                Commands     = new object[] { collectionChange }
            };

            // Create change sync request.
            SyncRequest syncChangeRequest = Common.CreateSyncRequest(new Request.SyncCollection[] { collection });

            // Change the location of the added calender by Sync request.
            DataStructures.SyncStore syncChangeResponse = this.ASAIRSAdapter.Sync(syncChangeRequest);
            Site.Assert.IsTrue(syncChangeResponse.CollectionStatus.Equals(1), "The sync change operation should be success; It is:{0} actually", syncChangeResponse.CollectionStatus);

            #region Call Sync command to get the new changed calendar item that removed the location.
            syncItem = this.GetSyncResult(subject, this.User1Information.CalendarCollectionId, null, null, null);
            #endregion

            #region Call ItemOperations command to reterive the changed calendar item that removed the location.
            DataStructures.ItemOperations itemOperations = this.GetItemOperationsResult(this.User1Information.CalendarCollectionId, syncItem.ServerId, null, null, null, null);
            #endregion
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASAIRS_R1001013");

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R1001013
            Site.CaptureRequirementIfIsNull(
                itemOperations.Calendar.Location1.DisplayName,
                1001013,
                @"[In Location] The client's request can include an empty Location element to remove the location from an item.");
            #endregion

            if (Common.IsRequirementEnabled(53, this.Site))
            {
                #region Call Search command to search the added calendar item.
                this.GetSearchResult(subject, this.User1Information.CalendarCollectionId, null, null, null);
                #endregion
            }
        }
Esempio n. 35
0
        public void MSASCMD_S19_TC35_Sync_DeletesAsMovesIsFalse()
        {
            #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.SyncChanges(this.User2Information.DeletedItemsCollectionId);
            Site.Assert.IsNull(TestSuiteBase.FindServerId(syncResponse, "Subject", emailSubject), "The email should not be found in the DeletedItems folder.");

            syncResponse = this.GetMailItem(this.User2Information.InboxCollectionId, emailSubject);
            Site.Assert.IsNotNull(syncResponse.ResponseData.Item, "The items returned in the Sync command response should not be null.");

            string serverId = TestSuiteBase.FindServerId(syncResponse, "Subject", emailSubject);
            Site.Assert.IsTrue(!string.IsNullOrEmpty(serverId), "The email should be found in the Inbox folder.");

            #region Delete the added email item.
            Request.SyncCollectionDelete appDataDelete = new Request.SyncCollectionDelete { ServerId = serverId };

            Request.SyncCollection collection = new Request.SyncCollection
            {
                SyncKey = this.LastSyncKey,
                GetChanges = true,
                CollectionId = this.User2Information.InboxCollectionId,
                Commands = new object[] { appDataDelete },
                DeletesAsMoves = false,
                DeletesAsMovesSpecified = true
            };

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

            SyncRequest syncRequestDelete = new SyncRequest { RequestData = syncRequestData };
            this.Sync(syncRequestDelete);
            #endregion

            #region Verify if the email has been deleted from the Inbox folder and not placed into the DeletedItems folder.
            syncResponse = this.SyncChanges(this.User2Information.InboxCollectionId);
            Site.Assert.IsNull(TestSuiteBase.FindServerId(syncResponse, "Subject", emailSubject), "The email deleted should not be found in the Inbox folder.");
            TestSuiteBase.RemoveRecordCaseRelativeItems(this.User2Information, this.User2Information.InboxCollectionId, emailSubject);

            syncResponse = this.SyncChanges(this.User2Information.DeletedItemsCollectionId);
            Site.Assert.IsNull(TestSuiteBase.FindServerId(syncResponse, "Subject", emailSubject), "The email deleted should not be found in the DeletedItems folder.");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R2158
            // If the deleted email can not be found in both Inbox and Deleted Items folder, this requirement can be captured directly.
            Site.CaptureRequirement(
                2158,
                @"[In DeletesAsMoves] If the DeletesAsMoves element is set to false, the deletion is permanent.");
            #endregion
        }
Esempio n. 36
0
        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
        }
        /// <summary>
        /// Create a Sync delete operation request which would be used to move deleted items to the Deleted Items folder.
        /// </summary>
        /// <param name="syncKey">The synchronization state of a collection.</param>
        /// <param name="collectionId">The server ID of the folder.</param>
        /// <param name="serverId">An server ID of the item which will be deleted.</param>
        /// <returns>The Sync delete operation request.</returns>
        protected static SyncRequest CreateSyncDeleteRequest(string syncKey, string collectionId, string serverId)
        {
            Request.SyncCollection collection = new Request.SyncCollection
            {
                SyncKey = syncKey,
                GetChanges = true,
                CollectionId = collectionId,
                Commands = new object[] { new Request.SyncCollectionDelete { ServerId = serverId } }
            };

            return Common.CreateSyncRequest(new Request.SyncCollection[] { collection });
        }
        /// <summary>
        /// Creates an instance of SyncCollection
        /// </summary>
        /// <param name="syncKey">Specify the synchronization key obtained from the last sync command response.</param>
        /// <param name="collectionId">Specify the serverId of the folder to be synchronized, which can be returned by ActiveSync FolderSync command</param>
        /// <returns>An instance of SyncCollection</returns>
        internal static Request.SyncCollection CreateSyncCollection(string syncKey, string collectionId)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                SyncKey = syncKey,
                GetChanges = true,
                GetChangesSpecified = true,
                CollectionId = collectionId,
                DeletesAsMoves = false,
                DeletesAsMovesSpecified = true,
                WindowSize = "100"
            };

            return syncCollection;
        }
Esempio n. 39
0
        public void MSASCMD_S19_TC08_Sync_ConversationMode_Status4()
        {
            Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The ConversationMode element is not supported when the MS-ASProtocolVersion header is set to 12.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            SyncRequest syncRequest = TestSuiteBase.CreateEmptySyncRequest(this.User1Information.ContactsCollectionId);
            this.Sync(syncRequest);

            Request.Options option = new Request.Options
            {
                Items = new object[] { (byte)1 },
                ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.FilterType }
            };

            Request.SyncCollection collection = new Request.SyncCollection
            {
                SyncKey = this.LastSyncKey,
                Options = new Request.Options[] { option },
                CollectionId = this.User1Information.ContactsCollectionId,
                Commands = null,
                GetChanges = true,
                GetChangesSpecified = true,
                ConversationMode = true,
                ConversationModeSpecified = true
            };

            syncRequest.RequestData.Collections = new Request.SyncCollection[] { collection };
            SyncResponse syncResponse = this.Sync(syncRequest);

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R2117
            Site.CaptureRequirementIfAreEqual<int>(
                4,
                int.Parse(syncResponse.ResponseData.Status),
                2117,
                @"[In ConversationMode(Sync)] Specifying the ConversationMode element for collections that do not store emails results in an invalid XML error, Status element (section 2.2.3.162.16) value 4.");
        }
        /// <summary>
        /// Delete the specified item.
        /// </summary>
        /// <param name="itemsToDelete">The collection of the items to delete.</param>
        private void DeleteCreatedItems(Collection<CreatedItems> itemsToDelete)
        {
            foreach (CreatedItems itemToDelete in itemsToDelete)
            {
                SyncStore syncResponse = this.CallSyncCommand(itemToDelete.CollectionId);
                Site.Assert.AreNotEqual<int>(0, syncResponse.AddCommands.Count, "There is not items added in {0} folder.", itemToDelete.CollectionId);
                List<Request.SyncCollectionDelete> deleteList = new List<Request.SyncCollectionDelete>();
                foreach (string itemSubject in itemToDelete.ItemSubject)
                {
                    Request.SyncCollectionDelete appData = new Request.SyncCollectionDelete
                    {
                        ServerId = TestSuiteHelper.GetServerIdFromSyncResponse(syncResponse, itemSubject)
                    };

                    Site.Assert.IsNotNull(appData.ServerId, "The item with subject {0} in {1} folder is not found.", itemSubject, itemToDelete.CollectionId);
                    deleteList.Add(appData);
                }

                // Create the Sync command request.
                Request.SyncCollection[] syncCollections = new Request.SyncCollection[1];
                syncCollections[0] = new Request.SyncCollection
                {
                    CollectionId = itemToDelete.CollectionId,
                    SyncKey = syncResponse.SyncKey,
                    Commands = deleteList.ToArray(),
                    DeletesAsMoves = false,
                    DeletesAsMovesSpecified = true
                };
                SyncRequest syncRequest = Common.CreateSyncRequest(syncCollections);

                // Call Sync command to delete the specified item.
                SendStringResponse syncResponseString = this.HTTPAdapter.HTTPPOST(CommandName.Sync, null, syncRequest.GetRequestDataSerializedXML());

                // Check the command is executed successfully.
                this.CheckResponseStatus(syncResponseString.ResponseDataXML);
            }
        }
        /// <summary>
        /// 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:
        /// <!--
        /// <?xml version="1.0" encoding="utf-8"?>
        /// <Sync xmlns="AirSync">
        ///   <Collections>
        ///     <Collection>
        ///       <SyncKey>0</SyncKey>
        ///       <CollectionId>5</CollectionId>
        ///       <DeletesAsMoves>1</DeletesAsMoves>
        ///       <GetChanges>1</GetChanges>
        ///       <WindowSize>100</WindowSize>
        ///       <Options>
        ///         <MIMESupport>0</MIMESupport>
        ///         <airsyncbase:BodyPreference>
        ///           <airsyncbase:Type>2</airsyncbase:Type>
        ///           <airsyncbase:TruncationSize>5120</airsyncbase:TruncationSize>
        ///         </airsyncbase:BodyPreference>
        ///       </Options>
        ///     </Collection>
        ///   </Collections>
        /// </Sync>
        /// -->
        /// </summary>
        /// <param name="syncKey">Specify the sync key obtained from the last sync response(Refer to [MS-ASCMD]2.2.3.166.4)</param>
        /// <param name="collectionId">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)</param>
        /// <param name="bodyPreference">Sets preference information related to the type and size of information for body (Refer to [MS-ASAIRS] 2.2.2.7)</param>
        /// <returns>Returns the SyncRequest instance</returns>
        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 });
        }
        /// <summary>
        /// Builds a initial Sync request by using the specified collection Id.
        /// In order to sync the content of a folder, an initial sync key for the folder MUST be obtained from the server.
        /// The client obtains the key by sending an initial Sync request with a SyncKey element value of zero and the CollectionId element
        /// In general, returns the XML formatted Sync request as follows:
        /// <!--
        /// <?xml version="1.0" encoding="utf-8"?>
        /// <Sync xmlns="AirSync">
        ///   <Collections>
        ///     <Collection>
        ///       <SyncKey>0</SyncKey>
        ///       <CollectionId>5</CollectionId>
        ///     </Collection>
        ///   </Collections>
        /// </Sync>
        /// -->
        /// </summary>
        /// <param name="collectionId">Identify the folder as the collection being synchronized, which can be returned by ActiveSync FolderSync command(Refer to [MS-ASCMD]2.2.3.30.5)</param>
        /// <param name="supported">Specifies which contact and calendar elements in a Sync request are managed by the client and therefore not ghosted.</param>
        /// <returns>Returns the SyncRequest instance</returns>
        internal static SyncRequest InitializeSyncRequest(string collectionId, Request.Supported supported)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                Supported = supported,
                WindowSize = "512",
                CollectionId = collectionId,
                SyncKey = "0"
            };

            List<object> items = new List<object>();
            List<Request.ItemsChoiceType1> itemsElementName = new List<Request.ItemsChoiceType1>
            {
                Request.ItemsChoiceType1.BodyPreference
            };

            items.Add(
                new Request.BodyPreference()
                {
                    TruncationSize = 0,
                    TruncationSizeSpecified = false,
                    Type = 2,
                    Preview = 0,
                    PreviewSpecified = false,
                });

            Request.Options option = new Request.Options
            {
                Items = items.ToArray(),
                ItemsElementName = itemsElementName.ToArray()
            };

            syncCollection.Options = new Request.Options[] { option };

            SyncRequest request = Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection });

            return request;
        }
Esempio n. 43
0
        /// <summary>
        /// Delete all the items in a folder.
        /// </summary>
        /// <param name="userInformation">The user information which contains user created items</param>
        private void DeleteItemsInFolder(UserInformation userInformation)
        {
            foreach (CreatedItems createdItems in userInformation.UserCreatedItems)
            {
                SyncStore syncStore  = this.InitializeSync(createdItems.CollectionId);
                SyncStore result     = this.SyncChanges(syncStore.SyncKey, createdItems.CollectionId, null);
                string    syncKey    = result.SyncKey;
                int       retryCount = int.Parse(Common.GetConfigurationPropertyValue("RetryCount", this.Site));
                int       waitTime   = int.Parse(Common.GetConfigurationPropertyValue("WaitTime", this.Site));
                int       counter    = 0;
                do
                {
                    Thread.Sleep(waitTime);
                    if (result != null)
                    {
                        if (result.CollectionStatus == 1)
                        {
                            break;
                        }
                    }

                    counter++;
                }while (counter < retryCount / 10);
                if (result.AddElements != null)
                {
                    SyncRequest deleteRequest;
                    foreach (Sync syncItem in result.AddElements)
                    {
                        if (createdItems.CollectionId == userInformation.CalendarCollectionId)
                        {
                            foreach (string subject in createdItems.ItemSubject)
                            {
                                if (syncItem.Calendar != null && syncItem.Calendar.Subject != null)
                                {
                                    if (syncItem.Calendar.Subject.Equals(subject, StringComparison.CurrentCultureIgnoreCase))
                                    {
                                        deleteRequest = CreateSyncPermanentDeleteRequest(syncKey, createdItems.CollectionId, syncItem.ServerId);
                                        SyncStore deleteSyncResult = this.EMAILAdapter.Sync(deleteRequest);
                                        syncKey = deleteSyncResult.SyncKey;
                                        Site.Assert.AreEqual <byte>(1, deleteSyncResult.CollectionStatus, "Item should be deleted.");
                                    }
                                }
                            }
                        }
                        else
                        {
                            List <Request.SyncCollectionDelete> deleteData = new List <Request.SyncCollectionDelete>();
                            foreach (string subject in createdItems.ItemSubject)
                            {
                                string serverId = null;
                                if (result != null)
                                {
                                    foreach (Sync item in result.AddElements)
                                    {
                                        if (item.Email.Subject != null && item.Email.Subject.Contains(subject))
                                        {
                                            serverId = item.ServerId;
                                            break;
                                        }

                                        if (item.Calendar.Subject != null && item.Calendar.Subject.Contains(subject))
                                        {
                                            serverId = item.ServerId;
                                            break;
                                        }
                                    }
                                }

                                if (serverId != null)
                                {
                                    deleteData.Add(new Request.SyncCollectionDelete()
                                    {
                                        ServerId = serverId
                                    });
                                }
                            }

                            if (deleteData.Count > 0)
                            {
                                Request.SyncCollection syncCollection = TestSuiteHelper.CreateSyncCollection(syncKey, createdItems.CollectionId);
                                syncCollection.Commands                = deleteData.ToArray();
                                syncCollection.DeletesAsMoves          = false;
                                syncCollection.DeletesAsMovesSpecified = true;

                                SyncRequest syncRequest  = Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection });
                                SyncStore   deleteResult = this.EMAILAdapter.Sync(syncRequest);
                                syncKey = deleteResult.SyncKey;
                                Site.Assert.AreEqual <byte>(
                                    1,
                                    deleteResult.CollectionStatus,
                                    "The value of Status should be 1 to indicate the Sync command executes successfully.");
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Build a generic Sync request without command references by using the specified sync key, folder collection ID.
        /// </summary>
        /// <param name="syncKey">The current sync key.</param>
        /// <param name="collectionId">The collection id which to sync with.</param>
        /// <returns>A Sync command request.</returns>
        private static SyncRequest CreateSyncRequest(string syncKey, string collectionId)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                SyncKey = syncKey,
                CollectionId = collectionId
            };

            List<object> items = new List<object>();
            List<Request.ItemsChoiceType1> itemsElementName = new List<Request.ItemsChoiceType1>();

            Request.BodyPreference bodyPreference = new Request.BodyPreference()
            {
                Type = 1,
                TruncationSize = 2000,
                TruncationSizeSpecified = true,
                AllOrNone = true,
                AllOrNoneSpecified = true
            };

            items.Add(bodyPreference);
            itemsElementName.Add(Request.ItemsChoiceType1.BodyPreference);

            syncCollection.Options = new Request.Options[]
                {
                    new Request.Options()
                    {
                        ItemsElementName = itemsElementName.ToArray(),
                        Items = items.ToArray()
                    }
                };

            return Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection });
        }
Esempio n. 45
0
        /// <summary>
        /// Call Sync command to change the status of the emails in Inbox folder.
        /// </summary>
        /// <param name="syncKey">The latest SyncKey.</param>
        /// <param name="serverIds">The collection of ServerIds.</param>
        /// <param name="collectionId">The folder collectionId which needs to be sychronized.</param>
        /// <param name="read">Read element of the item.</param>
        /// <param name="status">Flag status of the item.</param>
        /// <returns>The SyncStore instance returned from Sync command.</returns>
        protected SyncStore SyncChange(string syncKey, Collection <string> serverIds, string collectionId, bool?read, string status)
        {
            List <Request.SyncCollectionChange> changes = new List <Request.SyncCollectionChange>();

            foreach (string serverId in serverIds)
            {
                Request.SyncCollectionChange change = new Request.SyncCollectionChange
                {
                    ServerId        = serverId,
                    ApplicationData = new Request.SyncCollectionChangeApplicationData()
                };

                List <object> changeItems = new List <object>();
                List <Request.ItemsChoiceType7> changeItemsElementName = new List <Request.ItemsChoiceType7>();

                if (read != null)
                {
                    changeItems.Add(read);
                    changeItemsElementName.Add(Request.ItemsChoiceType7.Read);
                }

                if (!string.IsNullOrEmpty(status))
                {
                    Request.Flag flag = new Request.Flag();
                    if (status == "1")
                    {
                        // The Complete Time format is yyyy-MM-ddThh:mm:ss.fffZ.
                        flag.CompleteTime           = System.DateTime.Now.ToUniversalTime();
                        flag.CompleteTimeSpecified  = true;
                        flag.DateCompleted          = System.DateTime.Now.ToUniversalTime();
                        flag.DateCompletedSpecified = true;
                    }

                    flag.Status   = status;
                    flag.FlagType = "Flag for follow up";

                    changeItems.Add(flag);
                    changeItemsElementName.Add(Request.ItemsChoiceType7.Flag);
                }

                change.ApplicationData.Items            = changeItems.ToArray();
                change.ApplicationData.ItemsElementName = changeItemsElementName.ToArray();

                changes.Add(change);
            }

            Request.SyncCollection collection = new Request.SyncCollection
            {
                CollectionId = collectionId,
                SyncKey      = syncKey,
                Commands     = changes.ToArray()
            };

            SyncRequest syncRequest = Common.CreateSyncRequest(new Request.SyncCollection[] { collection });
            SyncStore   syncStore   = this.CONAdapter.Sync(syncRequest);

            // Verify Sync command response.
            Site.Assert.AreEqual <byte>(
                1,
                syncStore.CollectionStatus,
                "If the Sync command executes successfully, the Status in response should be 1.");

            this.LatestSyncKey = syncStore.SyncKey;

            return(syncStore);
        }
        /// <summary>
        /// Delete the specified item.
        /// </summary>
        /// <param name="itemsToDelete">The collection of the items to delete.</param>
        private void DeleteCreatedItems(Collection<CreatedItems> itemsToDelete)
        {
            foreach (CreatedItems itemToDelete in itemsToDelete)
            {
                Collection<string> itemsToDeleteServerIds = this.SyncCaseRelativeItems(itemToDelete.CollectionId, itemToDelete.ItemSubject[0], true);

                SyncRequest syncRequest = CreateSyncRequest(this.GetInitialSyncKey(itemToDelete.CollectionId), itemToDelete.CollectionId);
                SyncStore syncResponse = this.PROVAdapter.Sync(syncRequest);
                Site.Assert.AreNotEqual<int>(0, syncResponse.AddElements.Count, "There is not items added in {0} folder.", itemToDelete.CollectionId);

                List<Request.SyncCollectionDelete> deleteData = new List<Request.SyncCollectionDelete>();
                Request.SyncCollection syncCollection = new Request.SyncCollection();

                foreach (string serverId in itemsToDeleteServerIds)
                {
                    deleteData.Add(new Request.SyncCollectionDelete() { ServerId = serverId });
                }

                syncCollection.Commands = deleteData.ToArray();
                syncCollection.SyncKey = syncResponse.SyncKey;
                syncCollection.CollectionId = itemToDelete.CollectionId;
                syncCollection.DeletesAsMoves = false;
                syncCollection.DeletesAsMovesSpecified = true;

                syncRequest = Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection });
                SyncStore deleteResult = this.PROVAdapter.Sync(syncRequest);

                Site.Assert.AreEqual<byte>(
                    1,
                    deleteResult.CollectionStatus,
                    "The value of Status should be 1 to indicate the Sync command executes successfully.");
            }
        }
Esempio n. 47
0
        public void MSASCMD_S19_TC34_Sync_DeletesAsMovesIsTrue()
        {
            #region Send a MIME-formatted email to User2.
            string emailSubject1 = Common.GenerateResourceName(Site, "subject");
            this.SendPlainTextEmail(null, emailSubject1, this.User1Information.UserName, this.User2Information.UserName, null);
            #endregion

            this.SwitchUser(this.User2Information);
            TestSuiteBase.RecordCaseRelativeItems(this.User2Information, this.User2Information.InboxCollectionId, emailSubject1);

            // Check DeletedItems folder
            SyncRequest syncRequest = TestSuiteBase.CreateEmptySyncRequest(this.User2Information.DeletedItemsCollectionId);
            this.Sync(syncRequest);
            syncRequest.RequestData.Collections[0].SyncKey = this.LastSyncKey;
            SyncResponse syncResponse = this.Sync(syncRequest);
            Site.Assert.IsNull(TestSuiteBase.FindServerId(syncResponse, "Subject", emailSubject1), "The email should not be found in the DeletedItems folder.");

            // Check Inbox folder
            syncResponse = this.CheckEmail(this.User2Information.InboxCollectionId, emailSubject1, null);
            string serverId = TestSuiteBase.FindServerId(syncResponse, "Subject", emailSubject1);
            Site.Assert.IsNotNull(serverId, "The email should be found in the inbox folder.");

            #region Delete the email with DeletesAsMoves set to true from the Inbox folder.
            Request.SyncCollection collection = new Request.SyncCollection
            {
                SyncKey = this.LastSyncKey,
                CollectionId = this.User2Information.InboxCollectionId,
                Commands = new object[] { new Request.SyncCollectionDelete { ServerId = serverId } },
                DeletesAsMoves = true,
                DeletesAsMovesSpecified = true
            };

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

            SyncRequest syncRequestDelete = new SyncRequest { RequestData = syncRequestData };
            syncResponse = this.Sync(syncRequestDelete);
            Site.Assert.AreEqual<uint>(1, Convert.ToUInt32(TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Status)), "The Sync delete operation should be successful.");
            #endregion

            #region Verify if the email has been deleted from the Inbox folder and placed into the DeletedItems folder.
            // Check Inbox folder.
            syncResponse = this.SyncChanges(this.User2Information.InboxCollectionId, false);
            Site.Assert.IsNull(TestSuiteBase.FindServerId(syncResponse, "Subject", emailSubject1), "The email deleted should not be found in the Inbox folder.");
            TestSuiteBase.RemoveRecordCaseRelativeItems(this.User2Information, this.User2Information.InboxCollectionId, emailSubject1);

            // Check DeletedItems folder
            this.CheckEmail(this.User2Information.DeletedItemsCollectionId, emailSubject1, null);
            TestSuiteBase.RecordCaseRelativeItems(this.User2Information, this.User2Information.DeletedItemsCollectionId, emailSubject1);

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R2160
            // When the Assert statements above are passed, it means the deleted email is moved from the inbox folder to Deleted Items folder, then this requirement can be  captured directly.
            Site.CaptureRequirement(
                2160,
                @"[In DeletesAsMoves] A value of 1 (TRUE), which is the default, indicates that any deleted items are moved to the Deleted Items folder.");
            #endregion

            #region Send a MIME-formatted email to User2.
            this.SwitchUser(this.User1Information);
            string emailSubject2 = Common.GenerateResourceName(Site, "subject");
            this.SendPlainTextEmail(null, emailSubject2, this.User1Information.UserName, this.User2Information.UserName, null);
            #endregion

            this.SwitchUser(this.User2Information);
            TestSuiteBase.RecordCaseRelativeItems(this.User2Information, this.User2Information.InboxCollectionId, emailSubject1);

            // Check DeletedItems folder
            syncResponse = this.SyncChanges(this.User2Information.DeletedItemsCollectionId);
            Site.Assert.IsNull(TestSuiteBase.FindServerId(syncResponse, "Subject", emailSubject2), "The email should not be found in the DeletedItems folder.");

            // Check Inbox folder
            syncResponse = this.CheckEmail(this.User2Information.InboxCollectionId, emailSubject2, null);
            serverId = TestSuiteBase.FindServerId(syncResponse, "Subject", emailSubject2);
            Site.Assert.IsNotNull(serverId, "The email should be found in the inbox folder.");

            #region Delete the email and DeletesAsMoves is not present in the request
            collection = new Request.SyncCollection
            {
                SyncKey = this.LastSyncKey,
                CollectionId = this.User2Information.InboxCollectionId,
                Commands = new object[] { new Request.SyncCollectionDelete { ServerId = serverId } }
            };

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

            syncRequestDelete = new SyncRequest { RequestData = syncRequestData };
            syncResponse = this.Sync(syncRequestDelete);
            Site.Assert.AreEqual<uint>(1, Convert.ToUInt32(TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Status)), "The Sync delete operation should be successful.");

            TestSuiteBase.RemoveRecordCaseRelativeItems(this.User2Information, this.User2Information.InboxCollectionId, emailSubject1);
            #endregion

            #region Verify if the second email has been deleted from the Inbox folder and placed into the DeletedItems folder.
            // Check Inbox folder
            syncResponse = this.SyncChanges(this.User2Information.InboxCollectionId);
            Site.Assert.IsNull(TestSuiteBase.FindServerId(syncResponse, "Subject", emailSubject2), "The deleted email should not be found in the Inbox folder.");

            // Check DeletedItems folder
            syncResponse = this.SyncChanges(this.User2Information.DeletedItemsCollectionId);
            Site.Assert.IsNotNull(TestSuiteBase.FindServerId(syncResponse, "Subject", emailSubject2), "The deleted email should be found in the DeletedItems folder.");

            TestSuiteBase.RemoveRecordCaseRelativeItems(this.User2Information, this.User2Information.InboxCollectionId, emailSubject1);
            TestSuiteBase.RecordCaseRelativeItems(this.User2Information, this.User2Information.DeletedItemsCollectionId, emailSubject1, emailSubject2);

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R5874
            // When the Assert statements above are passed, it means the deleted email is moved from the inbox folder to Deleted Items folder, then this requirement can be  captured directly.
            Site.CaptureRequirement(
                5874,
                @"[In DeletesAsMoves] If element DeleteAsMoves is empty, the delete items are moved to the Deleted Items folder.");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R5875
            // When the Assert statements above are passed, it means the deleted email is moved from the inbox folder to Deleted Items folder, then this requirement can be  captured directly.
            Site.CaptureRequirement(
                5875,
                @"[In DeletesAsMoves] If element DeleteAsMoves is not present, the delete items are moved to the Deleted Items folder.");
            #endregion
        }
        /// <summary>
        /// Create an empty Sync request with filter type.
        /// </summary>
        /// <param name="collectionId">The value of the folder collectionId.</param>
        /// <param name="filterType">The value of the FilterType.</param>
        /// <returns>The empty Sync request.</returns>
        protected static SyncRequest CreateEmptySyncRequest(string collectionId, int filterType)
        {
            Request.SyncCollection collection = new Request.SyncCollection
            {
                SyncKey = "0",
                CollectionId = collectionId,
                Commands = null
            };

            if (0 <= filterType && filterType <= 8)
            {
                Request.Options option = new Request.Options
                {
                    Items = new object[] { (byte)filterType },
                    ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.FilterType }
                };
                collection.Options = new Request.Options[] { option };
            }

            return Common.CreateSyncRequest(new Request.SyncCollection[] { collection });
        }
        /// <summary>
        /// Builds a generic Sync request without command references by using the specified sync key, folder collection ID and body preference option.
        /// </summary>
        /// <param name="syncKey">Specifies the sync key obtained from the last sync response.</param>
        /// <param name="collectionId">Specifies the server ID of the folder to be synchronized.</param>
        /// <param name="bodyPreference">Sets preference information related to the type and size of information for body.</param>
        /// <returns>Returns the SyncRequest instance</returns>
        internal static SyncRequest CreateSyncRequest(string syncKey, string collectionId, Request.BodyPreference bodyPreference)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                SyncKey = syncKey,
                CollectionId = collectionId
            };

            // Sets Getchanges only if SyncKey != 0 since fail response is returned when the SyncKey element value is 0.
            if (syncKey != "0")
            {
                syncCollection.GetChanges = true;
                syncCollection.GetChangesSpecified = true;
            }

            syncCollection.WindowSize = "512";

            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);
            }

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

            return Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection });
        }
        /// <summary>
        /// Delete all the user created items
        /// </summary>
        /// <param name="userInformation">The user information which contains user created items</param>
        private void DeleteItemsInFolder(UserInformation userInformation)
        {
            foreach (CreatedItems userItem in userInformation.UserCreatedItems)
            {
                SyncRequest emptySyncRequest = TestSuiteBase.CreateEmptySyncRequest(userItem.CollectionId);
                SyncResponse emptySyncResult = this.Sync(emptySyncRequest);
                SyncStore emptySyncResponse = Common.LoadSyncResponse(emptySyncResult);
                int retryCount = int.Parse(Common.GetConfigurationPropertyValue("RetryCount", this.Site));
                int waitTime = int.Parse(Common.GetConfigurationPropertyValue("WaitTime", this.Site));
                int counter = 0;

                do
                {
                    Thread.Sleep(waitTime);

                    emptySyncResult = this.Sync(emptySyncRequest);
                    emptySyncResponse = Common.LoadSyncResponse(emptySyncResult);
                    if (emptySyncResponse != null)
                    {
                        if (emptySyncResponse.CollectionStatus == 1)
                        {
                            break;
                        }
                    }

                    counter++;
                }
                while (counter < retryCount / 10);

                if (emptySyncResponse.AddElements != null)
                {
                    SyncRequest deleteRequest;
                    foreach (SyncItem item in emptySyncResponse.AddElements)
                    {
                        deleteRequest = CreateSyncPermanentDeleteRequest(emptySyncResponse.SyncKey, userItem.CollectionId, item.ServerId);
                        SyncResponse resultDelete = this.Sync(deleteRequest);
                        SyncStore deleteResult = Common.LoadSyncResponse(resultDelete);
                        Site.Assert.AreEqual<byte>(1, deleteResult.CollectionStatus, "Item should be deleted.");
                    }
                }

                SyncResponse result = this.SyncChanges(userItem.CollectionId);
                string syncKey = this.LastSyncKey;
                if (result.ResponseData != null && result.ResponseData.Item != null)
                {
                    List<Request.SyncCollectionDelete> deleteData = new List<Request.SyncCollectionDelete>();
                    foreach (string subject in userItem.ItemSubject)
                    {
                        if (userItem.CollectionId == userInformation.ContactsCollectionId)
                        {
                            foreach (string itemServerID in TestSuiteBase.FindServerIdList(result, "FileAs", subject))
                            {
                                Request.SyncCollectionDelete deleteItem = new Request.SyncCollectionDelete
                                {
                                    ServerId = itemServerID
                                };

                                deleteData.Add(deleteItem);
                            }
                        }
                        else
                        {
                            foreach (string itemServerID in TestSuiteBase.FindServerIdList(result, "Subject", subject))
                            {
                                Request.SyncCollectionDelete deleteItem = new Request.SyncCollectionDelete
                                {
                                    ServerId = itemServerID
                                };

                                deleteData.Add(deleteItem);
                            }
                        }
                    }

                    if (deleteData.Count > 0)
                    {
                        Request.SyncCollection syncCollection = new Request.SyncCollection
                        {
                            SyncKey = syncKey,
                            GetChanges = true,
                            GetChangesSpecified = true,
                            CollectionId = userItem.CollectionId,
                            Commands = deleteData.ToArray(),
                            DeletesAsMoves = false,
                            DeletesAsMovesSpecified = true
                        };

                        SyncRequest syncRequest = Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection });
                        SyncResponse deleteResult = this.Sync(syncRequest);
                        string deleteResultStatus = this.GetStatusCode(deleteResult.ResponseDataXML);

                        Site.Assert.AreEqual<string>(
                            "1",
                            deleteResultStatus,
                            "The value of 'Status' should be 1 which indicates the Sync command executes successfully.",
                            deleteResultStatus);
                    }
                }
            }
        }
Esempio n. 51
0
        /// <summary>
        /// Create a Sync change operation request.
        /// </summary>
        /// <param name="syncKey">The synchronization state of a collection.</param>
        /// <param name="collectionId">The server ID of the folder.</param>
        /// <param name="syncCollectionChange">An instance of the SyncCollectionChange.</param>
        /// <returns>The Sync change operation request.</returns>
        private static SyncRequest CreateSyncChangeRequest(string syncKey, string collectionId, Request.SyncCollectionChange syncCollectionChange)
        {
            Request.SyncCollection collection = new Request.SyncCollection
            {
                SyncKey = syncKey,
                GetChanges = true,
                CollectionId = collectionId,
                Commands = new object[] { syncCollectionChange }
            };

            return Common.CreateSyncRequest(new Request.SyncCollection[] { collection });
        }
        /// <summary>
        /// This method is used to create a Sync add request
        /// </summary>
        /// <param name="syncKey">The value of the SyncKey element.</param>
        /// <param name="collectionId">The value of the CollectionID element.</param>
        /// <param name="syncCollectionAdd">An instance of the SyncCollectionAdd.</param>
        /// <returns>The value of the SyncRequest.</returns>
        protected static SyncRequest CreateSyncAddRequest(string syncKey, string collectionId, Request.SyncCollectionAdd syncCollectionAdd)
        {
            Request.SyncCollection collection = new Request.SyncCollection
            {
                SyncKey = syncKey,
                GetChanges = true,
                CollectionId = collectionId,
                Commands = new object[] { syncCollectionAdd }
            };

            return Common.CreateSyncRequest(new Request.SyncCollection[] { collection });
        }
Esempio n. 53
0
        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
        }
Esempio n. 54
0
        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 MSASNOTE_S01_TC04_Sync_SupportedError()
        {
            #region Call an initial method Sync including the Supported option.
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                CollectionId = this.UserInformation.NotesCollectionId,
                SyncKey = "0",
                Supported = new Request.Supported()
            };
            SyncRequest syncRequest = Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection });
            SyncStore syncResult = this.NOTEAdapter.Sync(syncRequest, false);

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

            // Verify MS-ASNOTE requirement: MS-ASNOTE_R114
            Site.CaptureRequirementIfAreEqual<int>(
                4,
                syncResult.Status,
                114,
                @"[In Sync Command Response] If the airsync:Supported element ([MS-ASCMD] section 2.2.3.164) is included in a Sync command request for Notes class data, the server returns a Status element with a value of 4, as specified in [MS-ASCMD] section 2.2.3.162.16.");

            #endregion
        }
 /// <summary>
 /// Get the request of Sync command.
 /// </summary>
 /// <param name="collectionId">The CollectionId of the folder to sync.</param>
 /// <param name="syncKey">The SyncKey of the latest sync.</param>
 /// <returns>The request of Sync command.</returns>
 public static SyncRequest GetSyncRequest(string collectionId, string syncKey)
 {
     // Create the Sync command request.
     Request.SyncCollection[] synCollections = new Request.SyncCollection[1];
     synCollections[0] = new Request.SyncCollection { SyncKey = syncKey, CollectionId = collectionId };
     SyncRequest syncRequest = Common.CreateSyncRequest(synCollections);
     return syncRequest;
 }