Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        /// <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;
        }
Exemplo n.º 3
0
        public void MSASCON_S01_TC08_Sync_Status164()
        {
            this.CheckActiveSyncVersionIsNot140();

            #region User2 sends an email to User1
            this.SwitchUser(this.User2Information, true);

            string subject             = Common.GenerateResourceName(Site, "Subject");
            string user1MailboxAddress = Common.GetMailAddress(User1Information.UserName, User1Information.UserDomain);
            string user2MailboxAddress = Common.GetMailAddress(User2Information.UserName, User2Information.UserDomain);
            this.CallSendMailCommand(user2MailboxAddress, user1MailboxAddress, subject, null);
            TestSuiteBase.RecordCaseRelativeItems(this.User1Information, User1Information.InboxCollectionId, subject, false);
            #endregion

            #region Call sync command with BodyPartPreference element and set the Type element to 3
            this.SwitchUser(this.User1Information, false);

            // Check whether the mail has been received.
            this.SyncEmail(subject, User1Information.InboxCollectionId, true, null, null);

            Request.BodyPartPreference bodyPartPreference = new Request.BodyPartPreference()
            {
                Type = 3,
            };

            // Call initial Sync command.
            SyncRequest syncRequest = Common.CreateInitialSyncRequest(User1Information.InboxCollectionId);
            SyncStore   syncStore   = this.CONAdapter.Sync(syncRequest);

            syncRequest = TestSuiteHelper.GetSyncRequest(User1Information.InboxCollectionId, syncStore.SyncKey, bodyPartPreference, null, false);
            syncStore   = this.CONAdapter.Sync(syncRequest);
            this.VerifyMessagePartStatus164(syncStore.Status);
            #endregion
        }
Exemplo n.º 4
0
        public async Task Delete(T item)
        {
            Items.Remove(item);
            await SyncStore.DeleteItemAsync(item);

            await LoadItems();
        }
        /// <summary>
        /// This method is used to check the Sync Change commands.
        /// </summary>
        /// <param name="result">The sync result which is returned from server</param>
        /// <param name="subject">The expected note's subject</param>
        /// <param name="site">An instance of interface ITestSite which provides logging, assertions, and adapters for test code onto its execution context.</param>
        /// <returns>The boolean value which represents whether the note with expected subject is found or not in sync result</returns>
        internal static bool CheckSyncChangeCommands(SyncStore result, string subject, ITestSite site)
        {
            site.Assert.AreEqual <byte>(
                1,
                result.CollectionStatus,
                "The server should return a Status 1 in the Sync command response indicate sync command succeed.");

            bool isNoteFound = false;

            foreach (Sync sync in result.ChangeElements)
            {
                site.Assert.IsNotNull(
                    sync,
                    @"The Change element in response should not be null.");

                site.Assert.IsNotNull(
                    sync.Note,
                    @"The note class in response should not be null.");

                if (sync.Note.Subject.Equals(subject))
                {
                    isNoteFound = true;
                }
            }

            return(isNoteFound);
        }
Exemplo n.º 6
0
        public void MSASCON_S01_TC04_Sync_Filter()
        {
            #region Create a conversation and sync to get the created conversation item.
            string           conversationSubject   = Common.GenerateResourceName(Site, "Conversation");
            ConversationItem inboxConversationItem = this.CreateConversation(conversationSubject);
            #endregion

            #region Call Sync command with setting ConversationMode element to true.
            SyncStore syncStore = this.CallSyncCommand(User1Information.InboxCollectionId, true);

            int itemCount = 0;
            foreach (Sync item in syncStore.AddElements)
            {
                if (item.Email.Subject.Contains(conversationSubject))
                {
                    itemCount++;
                }
            }
            #endregion

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

            // Verify MS-ASCON requirement: MS-ASCON_R180
            // If the count of the items got from Sync command is equal to the count of the item in the conversation, then this requirement can be captured.
            Site.CaptureRequirementIfAreEqual <int>(
                inboxConversationItem.ServerId.Count,
                itemCount,
                180,
                @"[In Synchronizing a Conversation] When a conversation is synchronized, all e-mail messages that are part of the conversation and that are in the specified folder are synchronized.");
        }
Exemplo n.º 7
0
        /// <summary>
        /// Get the specified email item.
        /// </summary>
        /// <param name="emailSubject">The subject of the email item.</param>
        /// <param name="folderCollectionId">The serverId of the default folder.</param>
        /// <param name="bodyPreference">The preference information related to the type and size of information that is returned from fetching.</param>
        /// <returns>The result of getting the specified email item.</returns>
        protected SyncStore GetSyncResult(string emailSubject, string folderCollectionId, Request.BodyPreference bodyPreference)
        {
            SyncStore syncItemResult;
            Sync      item       = null;
            int       counter    = 0;
            int       waitTime   = int.Parse(Common.GetConfigurationPropertyValue("WaitTime", this.Site));
            int       retryCount = int.Parse(Common.GetConfigurationPropertyValue("RetryCount", this.Site));

            do
            {
                Thread.Sleep(waitTime);

                // Get the new added email item
                SyncStore initSyncResult = this.InitializeSync(folderCollectionId);
                syncItemResult = this.SyncChanges(initSyncResult.SyncKey, folderCollectionId, bodyPreference);
                if (syncItemResult != null && syncItemResult.CollectionStatus == 1)
                {
                    item = TestSuiteHelper.GetSyncAddItem(syncItemResult, emailSubject);
                }

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

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

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

            return(syncItemResult);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Sync changes between client and server
        /// </summary>
        /// <param name="syncKey">The synchronization key returned by last request.</param>
        /// <param name="collectionId">Identify the folder as the collection being synchronized.</param>
        /// <param name="bodyPreference">Sets preference information related to the type and size of information for body</param>
        /// <returns>Return change result</returns>
        private SyncStore SyncChanges(string syncKey, string collectionId, Request.BodyPreference bodyPreference)
        {
            // Get changes from server use initial syncKey
            SyncRequest syncRequest = TestSuiteHelper.CreateSyncRequest(syncKey, collectionId, bodyPreference);
            SyncStore   syncResult  = this.ASAIRSAdapter.Sync(syncRequest);

            return(syncResult);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Create a conversation.
        /// </summary>
        /// <param name="subject">The subject of the emails in the conversation.</param>
        /// <returns>The created conversation item.</returns>
        protected ConversationItem CreateConversation(string subject)
        {
            #region Send email from User2 to User1
            this.SwitchUser(this.User2Information, true);
            string user1MailboxAddress = Common.GetMailAddress(this.User1Information.UserName, this.User1Information.UserDomain);
            string user2MailboxAddress = Common.GetMailAddress(this.User2Information.UserName, this.User2Information.UserDomain);
            this.CallSendMailCommand(user2MailboxAddress, user1MailboxAddress, subject, null);
            RecordCaseRelativeItems(this.User1Information, this.User1Information.InboxCollectionId, subject, false);
            #endregion

            #region SmartReply the received email from User1 to User2.
            this.SwitchUser(this.User1Information, false);
            Sync syncResult = this.SyncEmail(subject, this.User1Information.InboxCollectionId, true, null, null);

            this.CallSmartReplyCommand(syncResult.ServerId, this.User1Information.InboxCollectionId, user1MailboxAddress, user2MailboxAddress, subject);
            RecordCaseRelativeItems(this.User2Information, this.User2Information.InboxCollectionId, subject, false);
            #endregion

            #region SmartReply the received email from User2 to User1.
            this.SwitchUser(this.User2Information, false);
            syncResult = this.SyncEmail(subject, this.User2Information.InboxCollectionId, true, null, null);
            this.CallSmartReplyCommand(syncResult.ServerId, this.User2Information.InboxCollectionId, user2MailboxAddress, user1MailboxAddress, subject);
            #endregion

            #region Switch current user to User1 and get the conversation item.
            this.SwitchUser(this.User1Information, false);

            int counter = 0;
            int itemsCount;
            int retryLimit = int.Parse(Common.GetConfigurationPropertyValue("RetryCount", Site));
            int waitTime   = int.Parse(Common.GetConfigurationPropertyValue("WaitTime", Site));
            do
            {
                System.Threading.Thread.Sleep(waitTime);
                SyncStore syncStore = this.CallSyncCommand(this.User1Information.InboxCollectionId, false);

                // Reset the item count.
                itemsCount = 0;

                foreach (Sync item in syncStore.AddElements)
                {
                    if (item.Email.Subject.Contains(subject))
                    {
                        syncResult = item;
                        itemsCount++;
                    }
                }

                counter++;
            }while (itemsCount < 2 && counter < retryLimit);

            Site.Assert.AreEqual <int>(2, itemsCount, "There should be 2 emails with subject {0} in the Inbox folder, actual {1}.", subject, itemsCount);

            return(this.GetConversationItem(this.User1Information.InboxCollectionId, syncResult.Email.ConversationId));

            #endregion
        }
Exemplo n.º 10
0
        /// <summary>
        /// Sync data from the server.
        /// </summary>
        /// <param name="syncRequest">The request for Sync command.</param>
        /// <returns>The sync result which is returned from server.</returns>
        public SyncStore Sync(SyncRequest syncRequest)
        {
            SyncResponse response = this.activeSyncClient.Sync(syncRequest, true);

            Site.Assert.IsNotNull(response, "If the command is successful, the response should not be null.");
            SyncStore result = Common.LoadSyncResponse(response);

            return(result);
        }
Exemplo 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.");
                }
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Call Sync command to fetch the change of the notes from previous syncKey
        /// </summary>
        /// <param name="syncKey">The sync key</param>
        /// <param name="bodyType">The type of the body</param>
        /// <returns>Return change result</returns>
        protected SyncStore SyncChanges(string syncKey, byte bodyType)
        {
            Request.BodyPreference bodyPreference = new Request.BodyPreference {
                Type = bodyType
            };

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

            return(syncResult);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Call Sync command to fetch all notes
        /// </summary>
        /// <param name="bodyType">The type of the body</param>
        /// <returns>Return change result</returns>
        protected SyncStore SyncChanges(byte bodyType)
        {
            SyncRequest syncInitialRequest = TestSuiteHelper.CreateInitialSyncRequest(this.UserInformation.NotesCollectionId);
            SyncStore   syncInitialResult  = this.NOTEAdapter.Sync(syncInitialRequest, false);

            // Verify sync change result
            this.Site.Assert.AreEqual <byte>(
                1,
                syncInitialResult.CollectionStatus,
                "The server returns a Status 1 in the Sync command response indicate sync command success.",
                syncInitialResult.Status);

            SyncStore syncResult = this.SyncChanges(syncInitialResult.SyncKey, bodyType);

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

            this.Site.Assert.IsNotNull(
                syncResult.AddElements,
                "The server should return Add elements in response");

            Collection <Sync> expectedCommands = new Collection <Sync>();

            foreach (Sync sync in syncResult.AddElements)
            {
                this.Site.Assert.IsNotNull(
                    sync,
                    @"The Add element in response should not be null.");

                this.Site.Assert.IsNotNull(
                    sync.Note,
                    @"The note class in response should not be null.");

                if (this.ExistingNoteSubjects.Contains(sync.Note.Subject))
                {
                    expectedCommands.Add(sync);
                }
            }

            this.Site.Assert.AreEqual <int>(
                this.ExistingNoteSubjects.Count,
                expectedCommands.Count,
                @"The number of Add elements returned in response should be equal to the number of expected notes' subjects");

            syncResult.AddElements.Clear();
            foreach (Sync sync in expectedCommands)
            {
                syncResult.AddElements.Add(sync);
            }

            return(syncResult);
        }
        /// <summary>
        /// Sync data from the server.
        /// </summary>
        /// <param name="syncRequest">The request for sync operation.</param>
        /// <returns>The sync result which is returned from server.</returns>
        public SyncStore Sync(SyncRequest syncRequest)
        {
            SyncResponse response = this.activeSyncClient.Sync(syncRequest, true);

            Site.Assert.IsNotNull(response, "If the operation is successful, the response should not be null.");
            SyncStore result = Common.LoadSyncResponse(response);

            this.VerifyTransport();
            this.VerifySyncCommand(result);
            this.VerifyWBXMLCapture();
            return(result);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Sync data from the server
        /// </summary>
        /// <param name="syncRequest">Sync command request.</param>
        /// <param name="isResyncNeeded">A bool value indicates whether need to re-sync when the response contains MoreAvailable element.</param>
        /// <returns>The sync result which is returned from server</returns>
        public SyncStore Sync(SyncRequest syncRequest, bool isResyncNeeded)
        {
            SyncResponse response = this.activeSyncClient.Sync(syncRequest, isResyncNeeded);

            this.VerifySyncResponse(response);
            SyncStore result = Common.LoadSyncResponse(response);

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

            return(result);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Synchronizes the changes in a collection between the client and the server by sending SyncRequest object.
        /// </summary>
        /// <param name="request">A SyncRequest object that contains the request information.</param>
        /// <returns>A SyncStore object.</returns>
        public SyncStore Sync(SyncRequest request)
        {
            SyncResponse response = this.activeSyncClient.Sync(request, true);

            Site.Assert.IsNotNull(response, "If the Sync command executes successfully, the response from server should not be null.");
            SyncStore syncStore = Common.LoadSyncResponse(response);

            this.VerifySyncResponse(response, syncStore);
            this.VerifyWBXMLCapture();

            return(syncStore);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Initialize the sync with server
        /// </summary>
        /// <param name="collectionId">Specify the folder collection Id which needs to be synced.</param>
        /// <returns>Return change result</returns>
        protected SyncStore InitializeSync(string collectionId)
        {
            // Obtains the key by sending an initial Sync request with a SyncKey element value of zero and the CollectionId element
            SyncRequest syncRequest = Common.CreateInitialSyncRequest(collectionId);
            SyncStore   syncResult  = this.EMAILAdapter.Sync(syncRequest);

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

            return(syncResult);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Find the specified email.
        /// </summary>
        /// <param name="subject">The subject of the email to find.</param>
        /// <param name="collectionId">The folder collectionId which needs to be synchronized.</param>
        /// <param name="isRetryNeeded">A Boolean value indicates whether need retry.</param>
        /// <param name="bodyPartPreference">The bodyPartPreference in the options element.</param>
        /// <param name="bodyPreference">The bodyPreference in the options element.</param>
        /// <returns>The found email object.</returns>
        protected Sync SyncEmail(string subject, string collectionId, bool isRetryNeeded, Request.BodyPartPreference bodyPartPreference, Request.BodyPreference bodyPreference)
        {
            // Call initial Sync command.
            SyncRequest syncRequest = Common.CreateInitialSyncRequest(collectionId);
            SyncStore   syncStore   = this.CONAdapter.Sync(syncRequest);

            // Find the specific email.
            syncRequest = TestSuiteHelper.GetSyncRequest(collectionId, syncStore.SyncKey, bodyPartPreference, bodyPreference, false);
            Sync syncResult = this.CONAdapter.SyncEmail(syncRequest, subject, isRetryNeeded);

            this.LatestSyncKey = syncStore.SyncKey;

            return(syncResult);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Update email
        /// </summary>
        /// <param name="collectionId">The collectionId of the folder which contains the item to be updated.</param>
        /// <param name="syncKey">The syncKey which is returned from server</param>
        /// <param name="read">The value is TRUE indicates the email has been read; a value of FALSE indicates the email has not been read</param>
        /// <param name="serverId">The server id of the email</param>
        /// <param name="flag">The flag instance</param>
        /// <param name="categories">The array of categories</param>
        /// <returns>Return update email result</returns>
        protected SyncStore UpdateEmail(string collectionId, string syncKey, bool?read, string serverId, Request.Flag flag, Collection <string> categories)
        {
            Request.SyncCollectionChange changeData = new Request.SyncCollectionChange
            {
                ServerId        = serverId,
                ApplicationData = new Request.SyncCollectionChangeApplicationData()
            };

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

            if (null != read)
            {
                items.Add(read);
                itemsElementName.Add(Request.ItemsChoiceType7.Read);
            }

            if (null != flag)
            {
                items.Add(flag);
                itemsElementName.Add(Request.ItemsChoiceType7.Flag);
            }

            if (null != categories)
            {
                Request.Categories2 mailCategories = new Request.Categories2 {
                    Category = new string[categories.Count]
                };
                categories.CopyTo(mailCategories.Category, 0);
                items.Add(mailCategories);
                itemsElementName.Add(Request.ItemsChoiceType7.Categories2);
            }

            changeData.ApplicationData.Items            = items.ToArray();
            changeData.ApplicationData.ItemsElementName = itemsElementName.ToArray();

            SyncRequest syncRequest = TestSuiteHelper.CreateSyncChangeRequest(syncKey, collectionId, changeData);
            SyncStore   result      = this.EMAILAdapter.Sync(syncRequest);

            Site.Assert.AreEqual <byte>(
                1,
                result.CollectionStatus,
                "The server returns a Status 1 in the Sync command response indicate sync command success.");

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

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

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

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

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

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

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

            #endregion
        }
Exemplo n.º 22
0
        /// <summary>
        /// Call SendMail command to send one voice email
        /// </summary>
        /// <param name="emailSubject">Email subject</param>
        /// <param name="firstVoiceFilePath">First voice attachment file name</param>
        /// <param name="secondVoiceFilePath">Second voice attachment file name</param>
        /// <returns>Email item</returns>
        private Sync SendVoiceMail(string emailSubject, string firstVoiceFilePath, string secondVoiceFilePath)
        {
            // Create mail content
            string senderEmail   = Common.GetMailAddress(this.User1Information.UserName, this.User1Information.UserDomain);
            string receiverEmail = Common.GetMailAddress(this.User2Information.UserName, this.User2Information.UserDomain);
            string emailBody     = Common.GenerateResourceName(Site, "content");
            string callNumber    = "7125550123";

            // Create voice mail content mime
            string voiceMailMime = TestSuiteHelper.CreateVoiceAttachmentMime(
                senderEmail,
                receiverEmail,
                emailSubject,
                emailBody,
                callNumber,
                firstVoiceFilePath,
                secondVoiceFilePath);

            string           clientId        = TestSuiteHelper.GetClientId();
            SendMailRequest  sendMailRequest = TestSuiteHelper.CreateSendMailRequest(clientId, false, voiceMailMime);
            SendMailResponse response        = this.EMAILAdapter.SendMail(sendMailRequest);

            // Verify send voice mail success
            Site.Assert.AreEqual <string>(
                string.Empty,
                response.ResponseDataXML,
                "The server should return an empty xml response data to indicate SendMail command executes successfully.",
                response.ResponseDataXML);

            #region Record user name, folder collectionId and item subject that are used in this case.
            this.SwitchUser(this.User2Information, true);
            this.RecordCaseRelativeItems(this.User2Information.UserName, this.User2Information.InboxCollectionId, emailSubject);
            #endregion

            #region Sync changes in user2 mailbox .
            // Sync changes
            SyncStore result    = this.GetSyncResult(emailSubject, this.User2Information.InboxCollectionId, null);
            Sync      emailItem = TestSuiteHelper.GetSyncAddItem(result, emailSubject);
            #endregion

            return(emailItem);
        }
Exemplo n.º 23
0
        /// <summary>
        /// This method is used to verify the Sync response related requirements.
        /// </summary>
        /// <param name="syncResponse">Specified the SyncStore result returned from the server</param>
        private void VerifySyncResult(SyncStore syncResponse)
        {
            if (syncResponse.AddElements != null)
            {
                foreach (Sync sync in syncResponse.AddElements)
                {
                    this.VerifyNote(sync.Note, false);
                }
            }

            if (syncResponse.ChangeElements != null)
            {
                foreach (Sync sync in syncResponse.ChangeElements)
                {
                    this.VerifyNote(sync.Note, false);
                }
            }

            this.VerifyMessageSyntax();
        }
Exemplo n.º 24
0
        public void MSASCON_S02_TC01_GetItemEstimate_Filter()
        {
            #region Create a conversation and sync to get the created conversation item.
            string conversationSubject = Common.GenerateResourceName(Site, "Conversation");
            this.CreateConversation(conversationSubject);
            #endregion

            #region Initial Sync on Inbox folder.
            // Call Initial Sync command to get the latest SyncKey.
            SyncStore syncStore = this.CONAdapter.Sync(Common.CreateInitialSyncRequest(User1Information.InboxCollectionId));
            #endregion

            #region Send GetItemEstimate request and get response.
            GetItemEstimateResponse getItemEstimateResponse = this.CallGetItemEstimateCommand(syncStore.SyncKey, User1Information.InboxCollectionId);

            // Verify GetItemEstimate command response.
            bool isVerifyR211 = getItemEstimateResponse.ResponseData.Response.Length == 1 && getItemEstimateResponse.ResponseData.Response[0].Status == "1";

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCON_R211");
            Site.Log.Add(LogEntryKind.Debug, "The length of the Response element from GetItemEstimate command response is {0}.", getItemEstimateResponse.ResponseData.Response.Length);
            Site.Log.Add(LogEntryKind.Debug, "The value of the Status element from GetItemEstimate command response is {0}.", getItemEstimateResponse.ResponseData.Response[0].Status);

            // Verify MS-ASCON requirement: MS-ASCON_R211
            // If the GetItemEstimate command executed successfully, this requirement can be captured.
            Site.CaptureRequirementIfIsTrue(
                isVerifyR211,
                211,
                @"[In Processing a GetItemEstimate Command] When a conversation-based filter is applied to the GetItemEstimate command request, as specified in section 3.1.4.9, the server sends a GetItemEstimate command response ([MS-ASCMD] section 2.2.1.9) that specifies an estimate of the items that meet the filter criteria and need to be synchronized.");

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

            // Verify MS-ASCON requirement: MS-ASCON_R332
            // If the GetItemEstimate command executed successfully, this requirement can be captured.
            Site.CaptureRequirementIfIsTrue(
                isVerifyR211,
                332,
                @"[In Applying a Conversation-based Filter] A conversation-based filter can also be applied to the GetItemEstimate command request ([MS-ASCMD] section 2.2.1.9) to get an estimate of the items that both meet the filter criteria and need to be synchronized.");
            #endregion
        }
Exemplo n.º 25
0
        /// <summary>
        /// Sync data from the server.
        /// </summary>
        /// <param name="syncRequest">A Sync command request.</param>
        /// <returns>A Sync command response returned from the server.</returns>
        public SyncStore Sync(SyncRequest syncRequest)
        {
            SyncResponse response = this.activeSyncClient.Sync(syncRequest, true);

            Site.Assert.IsNotNull(response, "The Sync response should be returned.");
            this.VerifyTransport();
            this.VerifyWBXMLRequirements();

            SyncStore syncResponse = Common.LoadSyncResponse(response);

            foreach (Request.SyncCollection collection in syncRequest.RequestData.Collections)
            {
                if (collection.SyncKey != "0")
                {
                    this.VerifyMessageSyntax();
                    this.VerifySyncCommandResponse(syncResponse);
                }
            }

            return(syncResponse);
        }
Exemplo n.º 26
0
        /// <summary>
        /// Gets the created ConversationItem.
        /// </summary>
        /// <param name="collectionId">The CollectionId of the parent folder which has the conversation.</param>
        /// <param name="conversationId">The ConversationId of the conversation.</param>
        /// <returns>A ConversationItem object.</returns>
        protected ConversationItem GetConversationItem(string collectionId, string conversationId)
        {
            // Call Sync command to get the emails in Inbox folder.
            SyncStore syncStore = this.CallSyncCommand(collectionId, false);

            // Get the emails from Sync response according to the ConversationId.
            ConversationItem conversationItem = new ConversationItem {
                ConversationId = conversationId
            };

            foreach (Sync addElement in syncStore.AddElements)
            {
                if (addElement.Email.ConversationId == conversationId)
                {
                    conversationItem.ServerId.Add(addElement.ServerId);
                }
            }

            Site.Assert.AreNotEqual <int>(0, conversationItem.ServerId.Count, "The conversation should have at least one email.");

            return(conversationItem);
        }
Exemplo n.º 27
0
        /// <summary>
        /// Update email with invalid data
        /// </summary>
        /// <param name="invalidElement">invalid element send to server</param>
        /// <returns>Update results status code</returns>
        private string UpdateVoiceEmailWithInvalidData(string invalidElement)
        {
            // Switch to user2 mailbox
            this.SwitchUser(this.User2Information, true);

            // Sync changes
            SyncStore initSyncResult   = this.InitializeSync(this.User2Information.InboxCollectionId);
            SyncStore syncChangeResult = this.SyncChanges(initSyncResult.SyncKey, this.User2Information.InboxCollectionId, null);
            string    syncKey          = syncChangeResult.SyncKey;
            string    serverId         = this.User2Information.InboxCollectionId;

            // Create normal Sync change request
            Request.SyncCollectionChange changeData = TestSuiteHelper.CreateSyncChangeData(true, serverId, null, null);
            SyncRequest syncRequest = TestSuiteHelper.CreateSyncChangeRequest(syncKey, this.User2Information.InboxCollectionId, changeData);

            // Calls Sync command to update email with invalid sync request
            string             insertTag = "</ApplicationData>";
            SendStringResponse result    = this.EMAILAdapter.InvalidSync(syncRequest, invalidElement, insertTag);

            // Get status code
            return(TestSuiteHelper.GetStatusCode(result.ResponseDataXML));
        }
Exemplo n.º 28
0
        /// <summary>
        /// Synchronizes changes in a collection between the client and the server.
        /// </summary>
        /// <param name="syncRequest">A SyncRequest object that contains the request information.</param>
        /// <returns>The SyncStore result which is returned from server.</returns>
        public SyncStore Sync(SyncRequest syncRequest)
        {
            SyncResponse syncResponse = this.activeSyncClient.Sync(syncRequest, true);

            Site.Assert.IsNotNull(syncResponse, "The Sync response returned from server should not be null.");

            SyncStore syncStore = Common.LoadSyncResponse(syncResponse);

            if (1 == syncStore.CollectionStatus && syncStore.AddElements.Count != 0)
            {
                foreach (Sync addElement in syncStore.AddElements)
                {
                    this.VerifySyncCommandResponse(addElement);
                }
            }

            // Verify related requirements.
            this.VerifyCommonRequirements();
            this.VerifyWBXMLCapture();

            return(syncStore);
        }
Exemplo n.º 29
0
        public void MSASCON_S02_TC02_GetItemEstimate_Status4()
        {
            #region Initial Sync on Calendar folder.
            // Call Initial Sync command to get the latest SyncKey.
            SyncStore syncStore = this.CONAdapter.Sync(Common.CreateInitialSyncRequest(User1Information.CalendarCollectionId));
            #endregion

            #region Call GetItemEstimate command on Calendar folder with setting ConversationMode element in the request.
            GetItemEstimateResponse getItemEstimateResponse = this.CallGetItemEstimateCommand(syncStore.SyncKey, User1Information.CalendarCollectionId);

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

            // Verify MS-ASCON requirement: MS-ASCON_R336
            // If the response Status is 4, this requirement can be captured.
            Site.CaptureRequirementIfAreEqual <int>(
                4,
                int.Parse(getItemEstimateResponse.ResponseData.Status),
                336,
                @"[In Processing a GetItemEstimate Command] [The meaning of status code] 4 [is] Protocol error. The conversation-based filter cannot be applied to a folder that is not of the Email class.");
            #endregion
        }
Exemplo n.º 30
0
        /// <summary>
        /// Sync items in the specified folder.
        /// </summary>
        /// <param name="collectionId">The CollectionId of the folder.</param>
        /// <param name="conversationMode">The value of ConversationMode element.</param>
        /// <returns>A SyncStore instance that contains the result.</returns>
        protected SyncStore CallSyncCommand(string collectionId, bool conversationMode)
        {
            // Call initial Sync command.
            SyncRequest syncRequest = Common.CreateInitialSyncRequest(collectionId);

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

            if (conversationMode && Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site) != "12.1")
            {
                syncRequest = TestSuiteHelper.GetSyncRequest(collectionId, syncStore.SyncKey, null, null, true);
            }
            else
            {
                syncRequest = TestSuiteHelper.GetSyncRequest(collectionId, syncStore.SyncKey, null, null, false);
            }

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

            bool checkSyncStore = syncStore.AddElements != null && syncStore.AddElements.Count != 0;

            Site.Assert.IsTrue(checkSyncStore, "The items should be gotten from the Sync command response.");

            this.LatestSyncKey = syncStore.SyncKey;

            return(syncStore);
        }