Wrapper class of sync result data for a sync operation
Ejemplo n.º 1
0
        /// <summary>
        /// Clean up the environment.
        /// </summary>
        protected override void TestCleanup()
        {
            if (this.ItemsNeedToDelete.Count > 0)
            {
                SyncStore changesResult = this.SyncChanges(this.UserInformation.TasksCollectionId);

                foreach (string subject in this.ItemsNeedToDelete)
                {
                    string serverId = null;
                    foreach (Sync add in changesResult.AddElements)
                    {
                        if (add.Task.Subject == subject)
                        {
                            serverId = add.ServerId;
                            break;
                        }
                    }

                    Site.Assert.IsNotNull(serverId, "The task with subject {0} should be found.", subject);

                    SyncStore deleteResult = this.SyncDeleteTask(changesResult.SyncKey, serverId);

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

                this.ItemsNeedToDelete.Clear();
            }

            base.TestCleanup();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Call Sync command to change a task.
        /// </summary>
        /// <param name="syncKey">The sync key.</param>
        /// <param name="serverId">The server Id of the task.</param>
        /// <param name="changedElements">The changed elements of the task.</param>
        /// <returns>Return the sync change result.</returns>
        protected SyncStore SyncChangeTask(string syncKey, string serverId, Dictionary <Request.ItemsChoiceType7, object> changedElements)
        {
            Request.SyncCollectionChange change = new Request.SyncCollectionChange
            {
                ServerId        = serverId,
                ApplicationData = new Request.SyncCollectionChangeApplicationData
                {
                    Items            = changedElements.Values.ToArray <object>(),
                    ItemsElementName = changedElements.Keys.ToArray <Request.ItemsChoiceType7>()
                }
            };

            SyncRequest syncRequest = new SyncRequest
            {
                RequestData = new Request.Sync {
                    Collections = new Request.SyncCollection[1]
                }
            };

            syncRequest.RequestData.Collections[0] = new Request.SyncCollection
            {
                Commands     = new object[] { change },
                SyncKey      = syncKey,
                CollectionId = this.UserInformation.TasksCollectionId
            };
            SyncStore syncResponse = this.TASKAdapter.Sync(syncRequest);

            return(syncResponse);
        }
Ejemplo n.º 3
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
            SyncRequest syncRequest = Common.CreateInitialSyncRequest(collectionId);

            DataStructures.SyncStore syncResult = this.ASAIRSAdapter.Sync(syncRequest);

            // Status code '12' means the folder hierarchy has changed
            while (syncResult.Status == 12)
            {
                // Resynchronize the folder hierarchy
                this.FolderSync();

                syncResult = this.ASAIRSAdapter.Sync(syncRequest);
            }

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

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

            return(syncResult.SyncKey);
        }
        /// <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;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Get the specified email item from the sync add response by using the subject.
        /// </summary>
        /// <param name="syncStore">The sync result.</param>
        /// <param name="subject">The email subject.</param>
        /// <returns>Return the specified email item.</returns>
        internal static DataStructures.Sync GetSyncAddItem(DataStructures.SyncStore syncStore, string subject)
        {
            DataStructures.Sync item = null;

            if (syncStore.AddElements != null)
            {
                foreach (DataStructures.Sync syncItem in syncStore.AddElements)
                {
                    if (syncItem.Email.Subject == subject)
                    {
                        item = syncItem;
                        break;
                    }

                    if (syncItem.Calendar.Subject == subject)
                    {
                        item = syncItem;
                        break;
                    }

                    if (syncItem.Contact.FileAs == subject)
                    {
                        item = syncItem;
                        break;
                    }
                }
            }

            return(item);
        }
        public void MSASTASK_S03_TC02_RetrieveInvalidTaskItemWithSearch()
        {
            #region Call Sync command to create a task item

            Dictionary <Request.ItemsChoiceType8, object> taskItem = new Dictionary <Request.ItemsChoiceType8, object>();
            string subject = Common.GenerateResourceName(Site, "subject");
            taskItem.Add(Request.ItemsChoiceType8.Subject2, subject);

            #endregion

            #region Call Sync command to add the task to the server

            // add task
            SyncStore syncResponse = this.SyncAddTask(taskItem);
            Site.Assert.AreEqual <int>(1, int.Parse(syncResponse.AddResponses[0].Status), "Adding a task item to server should success.");
            SyncItem task = this.GetChangeItem(this.UserInformation.TasksCollectionId, subject);
            Site.Assert.IsNotNull(task.Task, "The task which subject is {0} should exist in server.", subject);
            ItemsNeedToDelete.Add(subject);

            #endregion

            #region Call Search command to search task on the server

            // Send a string create task item request without Type element contains in Recurrence.
            SendStringResponse sendStringResponse = this.TASKAdapter.SendStringRequest("<Search xmlns=\"Search\"><Store><Name>Mailbox</Name><Query><And><Class xmlns=\"AirSync\">Tasks</Class><CollectionId xmlns=\"AirSync\">" + this.UserInformation.TasksCollectionId + "</CollectionId><FreeText>FreeText</FreeText><Subject xmlns=\"Tasks\">user</Subject></And></Query><Options><DeepTraversal /></Options></Store></Search>", CommandName.Search);

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(sendStringResponse.ResponseDataXML);
            XmlNamespaceManager xnm = new XmlNamespaceManager(doc.NameTable);
            xnm.AddNamespace("e", "Search");

            int     retryCount   = int.Parse(Common.GetConfigurationPropertyValue("RetryCount", this.Site));
            int     waitTime     = int.Parse(Common.GetConfigurationPropertyValue("WaitTime", this.Site));
            int     counter      = 1;
            XmlNode searchStatus = doc.SelectSingleNode("/e:Search/e:Status", xnm);

            while (counter < retryCount && searchStatus != null && searchStatus.InnerXml.Equals("10"))
            {
                Thread.Sleep(waitTime);
                sendStringResponse = this.TASKAdapter.SendStringRequest("<Search xmlns=\"Search\"><Store><Name>Mailbox</Name><Query><And><Class xmlns=\"AirSync\">Tasks</Class><CollectionId xmlns=\"AirSync\">" + this.UserInformation.TasksCollectionId + "</CollectionId><FreeText>FreeText</FreeText><Subject xmlns=\"Tasks\">user</Subject></And></Query><Options><DeepTraversal /></Options></Store></Search>", CommandName.Search);
                doc.LoadXml(sendStringResponse.ResponseDataXML);
                xnm = new XmlNamespaceManager(doc.NameTable);
                xnm.AddNamespace("e", "Search");
                searchStatus = doc.SelectSingleNode("/e:Search/e:Status", xnm);
                counter++;
            }
            #endregion

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

            // Verify MS-ASTASK requirement: MS-ASTASK_R364
            Site.CaptureRequirementIfAreEqual <string>(
                "2",
                Common.GetSearchStatusCode(sendStringResponse),
                364,
                @"[In Search Command Response] If elements that belong to the Task class are included in a Search command request, the server MUST return a Status value of 2 in the Store element, as specified in [MS-ASCMD] section 2.2.3.162.12.");
        }
Ejemplo n.º 7
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="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>Return change result</returns>
        protected DataStructures.SyncStore SyncChanges(string syncKey, string collectionId, bool rightsManagementSupport)
        {
            // Get changes from server use initial syncKey
            SyncRequest syncRequest = TestSuiteHelper.CreateSyncRequest(syncKey, collectionId, rightsManagementSupport);

            DataStructures.SyncStore syncResult = this.ASRMAdapter.Sync(syncRequest);

            return(syncResult);
        }
Ejemplo 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.");
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Call Sync command to add a task.
        /// </summary>
        /// <param name="addElements">The elements of a task item to be added.</param>
        /// <returns>Return the sync response.</returns>
        protected SyncStore SyncAddTask(Dictionary <Request.ItemsChoiceType8, object> addElements)
        {
            SyncStore initializeSyncResponse = this.TASKAdapter.Sync(Common.CreateInitialSyncRequest(this.UserInformation.TasksCollectionId));

            // Verify sync result
            Site.Assert.AreEqual <byte>(
                1,
                initializeSyncResponse.CollectionStatus,
                "The server should return a status code 1 in the Sync command response to indicate the Sync command executes successfully.");

            Dictionary <Request.ItemsChoiceType8, object> task = TestSuiteHelper.CreateTaskElements();

            // Add elements
            if (addElements != null)
            {
                foreach (KeyValuePair <Request.ItemsChoiceType8, object> item in addElements)
                {
                    if (task.ContainsKey(item.Key))
                    {
                        task[item.Key] = item.Value;
                    }
                    else
                    {
                        task.Add(item.Key, item.Value);
                    }
                }
            }

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

            Request.SyncCollectionAdd add = new Request.SyncCollectionAdd
            {
                ClientId        = System.Guid.NewGuid().ToString(),
                ApplicationData = new Request.SyncCollectionAddApplicationData
                {
                    Items            = task.Values.ToArray <object>(),
                    ItemsElementName = task.Keys.ToArray <Request.ItemsChoiceType8>()
                }
            };
            addData.Add(add);

            SyncRequest syncRequest  = TestSuiteHelper.CreateSyncRequest(initializeSyncResponse.SyncKey, this.UserInformation.TasksCollectionId, addData);
            SyncStore   syncResponse = this.TASKAdapter.Sync(syncRequest);

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

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

            return(syncResponse);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Find an email with specific subject and folder.
        /// </summary>
        /// <param name="subject">The subject of the email item.</param>
        /// <param name="collectionId">Identify the folder as the collection being synchronized.</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>
        /// <param name="isRetryNeeded">A boolean value specifies whether need retry.</param>
        /// <returns>Return change result</returns>
        protected DataStructures.Sync SyncEmail(string subject, string collectionId, bool?rightsManagementSupport, bool isRetryNeeded)
        {
            SyncRequest syncRequest = Common.CreateInitialSyncRequest(collectionId);

            DataStructures.SyncStore initSyncResult = this.ASRMAdapter.Sync(syncRequest);

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

            syncRequest = TestSuiteHelper.CreateSyncRequest(initSyncResult.SyncKey, collectionId, rightsManagementSupport);
            DataStructures.Sync sync = this.ASRMAdapter.SyncEmail(syncRequest, subject, isRetryNeeded);
            return(sync);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Call Sync command to delete a task.
        /// </summary>
        /// <param name="syncKey">The sync key.</param>
        /// <param name="serverId">The server id of the task, which is returned by server.</param>
        /// <returns>Return the sync delete result.</returns>
        protected SyncStore SyncDeleteTask(string syncKey, string serverId)
        {
            List <object> deleteData = new List <object>();

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

            SyncRequest syncRequest  = TestSuiteHelper.CreateSyncRequest(syncKey, this.UserInformation.TasksCollectionId, deleteData);
            SyncStore   syncResponse = this.TASKAdapter.Sync(syncRequest);

            return(syncResponse);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Get the specified email item from the Sync Change response by using the subject.
        /// </summary>
        /// <param name="syncStore">The Sync result.</param>
        /// <param name="fileAs">The contact FileAs.</param>
        /// <returns>Return the specified email item.</returns>
        internal static DataStructures.Sync GetSyncChangeItem(DataStructures.SyncStore syncStore, string fileAs)
        {
            DataStructures.Sync item = null;

            if (syncStore.ChangeElements.Count != 0)
            {
                foreach (DataStructures.Sync syncItem in syncStore.ChangeElements)
                {
                    if (syncItem.Contact.FileAs == fileAs)
                    {
                        item = syncItem;
                        break;
                    }
                }
            }

            return(item);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Get the specified task item from the sync change response.
        /// </summary>
        /// <param name="collectionId">The task folder server id.</param>
        /// <param name="taskSubject">The subject value of task.</param>
        /// <returns>Return the specified task item.</returns>
        public SyncItem GetChangeItem(string collectionId, string taskSubject)
        {
            SyncItem resultItem = null;

            if (collectionId == this.UserInformation.TasksCollectionId)
            {
                // Get the server changes through sync command.
                SyncStore syncResponse = this.SyncChanges(collectionId);

                foreach (SyncItem item in syncResponse.AddElements)
                {
                    if (item.Task.Subject == taskSubject)
                    {
                        resultItem = item;
                        break;
                    }
                }
            }

            return(resultItem);
        }
Ejemplo n.º 14
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.");
                }
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Synchronize changes between client and server.
        /// </summary>
        /// <param name="collectionId">Specify the folder collection Id which needs to be synchronized.</param>
        /// <returns>Return the sync response.</returns>
        public SyncStore SyncChanges(string collectionId)
        {
            SyncStore syncResponse;

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

            // Synchronize to get the SyncKey.
            SyncStore   initializeSyncResponse = this.TASKAdapter.Sync(Common.CreateInitialSyncRequest(collectionId));
            SyncRequest syncRequest            = TestSuiteHelper.CreateSyncRequest(initializeSyncResponse.SyncKey, collectionId, null);

            do
            {
                Thread.Sleep(waitTime);

                // Get the server changes through sync command.
                syncResponse = this.TASKAdapter.Sync(syncRequest);
                if (syncResponse != null)
                {
                    if (syncResponse.CollectionStatus == 1)
                    {
                        break;
                    }
                }

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

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

            return(syncResponse);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Extract Add elements from a Sync string response.
        /// </summary>
        /// <param name="sendStringResponse">The returned SendStringResponse object.</param>
        /// <returns>The extracted SyncStore object.</returns>
        protected SyncStore ExtractSyncStore(SendStringResponse sendStringResponse)
        {
            SyncStore   response = new SyncStore();
            XmlDocument doc      = new XmlDocument();

            doc.LoadXml(sendStringResponse.ResponseDataXML);
            XmlNodeList nodes = doc.DocumentElement.GetElementsByTagName("Collection");

            foreach (XmlNode node in nodes)
            {
                foreach (XmlNode item in node.ChildNodes)
                {
                    if (item.Name == "Responses")
                    {
                        foreach (XmlNode add in item)
                        {
                            if (add.Name == "Add")
                            {
                                Response.SyncCollectionsCollectionResponsesAdd responseData = new Response.SyncCollectionsCollectionResponsesAdd();

                                foreach (XmlNode addItem in add)
                                {
                                    if (addItem.Name == "Status")
                                    {
                                        responseData.Status = addItem.InnerText;
                                    }
                                }

                                response.AddResponses.Add(responseData);
                            }
                        }
                    }
                }
            }

            return(response);
        }
Ejemplo n.º 17
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
            }
        }
Ejemplo n.º 18
0
        public void MSASTASK_S02_TC01_RetrieveTaskItemWithItemOperations()
        {
            #region Call Sync command to create a task item

            Dictionary <Request.ItemsChoiceType8, object> taskItem = new Dictionary <Request.ItemsChoiceType8, object>();
            string subject = Common.GenerateResourceName(Site, "subject");
            taskItem.Add(Request.ItemsChoiceType8.Subject2, subject);

            #endregion

            #region Call Sync command to add the task to the server

            // add task
            SyncStore syncResponse = this.SyncAddTask(taskItem);
            Site.Assert.AreEqual <int>(1, int.Parse(syncResponse.AddResponses[0].Status), "Adding a task item to server should success.");
            SyncItem task = this.GetChangeItem(this.UserInformation.TasksCollectionId, subject);
            Site.Assert.IsNotNull(task.Task, "The task which subject is {0} should exist in server.", subject);
            ItemsNeedToDelete.Add(subject);

            #endregion

            #region Call ItemOperations command to fetch tasks

            syncResponse = this.SyncChanges(this.UserInformation.TasksCollectionId);

            List <string> serverIds = new List <string>();
            for (int i = 0; i < syncResponse.AddElements.Count; i++)
            {
                serverIds.Add(syncResponse.AddElements[i].ServerId);
            }

            Request.Schema schema = new Request.Schema
            {
                ItemsElementName = new Request.ItemsChoiceType4[1],
                Items            = new object[1]
            };
            schema.ItemsElementName[0] = Request.ItemsChoiceType4.Body;
            schema.Items[0]            = new Request.Body();

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

            ItemOperationsRequest itemOperationsRequest  = TestSuiteHelper.CreateItemOperationsFetchRequest(this.UserInformation.TasksCollectionId, serverIds, null, bodyReference, schema);
            ItemOperationsStore   itemOperationsResponse = this.TASKAdapter.ItemOperations(itemOperationsRequest);
            Site.Assert.AreEqual <string>("1", itemOperationsResponse.Status, "The ItemOperations response should be successful.");

            #endregion

            // Get task item that created in this case.
            ItemOperations taskReturnedInItemOperations = null;
            foreach (ItemOperations item in itemOperationsResponse.Items)
            {
                if (task.Task.Body.Data.ToString().Contains(item.Task.Body.Data))
                {
                    taskReturnedInItemOperations = item;
                }
            }

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

            // Verify MS-ASTASK requirement: MS-ASTASK_R356
            // If the Task item in response is not null, this requirement will be captured.
            Site.CaptureRequirementIfIsNotNull(
                taskReturnedInItemOperations.Task,
                356,
                @"[In ItemOperations Command Response] When a client uses an ItemOperations command request ([MS-ASCMD] section 2.2.2.8) to retrieve data from the server for one or more specific Task items, as specified in section 3.1.5.1, the server responds with an ItemOperations command response ([MS-ASCMD] section 2.2.2.8).");

            bool otherPropertiesNull = true;

            // Loop to verify if other properties except "Body" are not returned.
            foreach (System.Reflection.PropertyInfo propertyInfo in typeof(Task).GetProperties())
            {
                if (propertyInfo.Name != "Body")
                {
                    object value = propertyInfo.GetValue(taskReturnedInItemOperations.Task, null);
                    if (value != null)
                    {
                        otherPropertiesNull = false;
                        break;
                    }
                }
            }

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

            // Verify MS-ASTASK requirement: MS-ASTASK_R358
            // If the body of the Task item in response is not null, this requirement can be captured.
            Site.CaptureRequirementIfIsTrue(
                otherPropertiesNull,
                358,
                @"[In ItemOperations Command Response] If an itemoperations:Schema element ([MS-ASCMD] section 2.2.3.135) is included in the ItemOperations command request, then the elements returned in the ItemOperations command response MUST be restricted to the elements that were included as child elements of the itemoperations:Schema element in the command request.");

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

            // Since MS-ASTASK_R358 is captured, this requirement can be captured.
            Site.CaptureRequirement(
                359,
                @"[In ItemOperations Command Response] Top-level Task class elements, as specified in section 2.2, MUST be returned as child elements of the itemoperations:Properties element ([MS-ASCMD] section 2.2.3.128) in the ItemOperations command response.");
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Extract Add elements from a Sync string response.
        /// </summary>
        /// <param name="sendStringResponse">The returned SendStringResponse object.</param>
        /// <returns>The extracted SyncStore object.</returns>        
        protected SyncStore ExtractSyncStore(SendStringResponse sendStringResponse)
        {
            SyncStore response = new SyncStore();
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(sendStringResponse.ResponseDataXML);
            XmlNodeList nodes = doc.DocumentElement.GetElementsByTagName("Collection");

            foreach (XmlNode node in nodes)
            {
                foreach (XmlNode item in node.ChildNodes)
                {
                    if (item.Name == "Responses")
                    {
                        foreach (XmlNode add in item)
                        {
                            if (add.Name == "Add")
                            {
                                Response.SyncCollectionsCollectionResponsesAdd responseData = new Response.SyncCollectionsCollectionResponsesAdd();

                                foreach (XmlNode addItem in add)
                                {
                                    if (addItem.Name == "Status")
                                    {
                                        responseData.Status = addItem.InnerText;
                                    }
                                }

                                response.AddResponses.Add(responseData);
                            }
                        }
                    }
                }
            }

            return response;
        }
Ejemplo n.º 20
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 VerifySyncCommandResponse(SyncStore syncResponse)
        {
            Site.Assert.IsTrue(this.activeSyncClient.ValidationResult, "The schema should be validated.");

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

            // Verify MS-ASTASK requirement: MS-ASTASK_R349
            // If Sync response exists, this requirement will be captured.
            Site.CaptureRequirementIfIsNotNull(
                syncResponse,
                349,
                @"[In Synchronizing Task Data Between Client and Server][If the client sends a Sync command request to the server] The server responds with a Sync command response ([MS-ASCMD] section 2.2.2.19).");

            if (null != syncResponse.AddElements)
            {
                for (int i = syncResponse.AddElements.Count - 1; i >= 0; i--)
                {
                    Task task = syncResponse.AddElements[i].Task;

                    if (null != task)
                    {
                        if (null != task.Body)
                        {
                            // Add the debug information
                            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R74");

                            // Since schema is validated, this requirement can be captured directly.
                            Site.CaptureRequirement(
                                74,
                                @"[In Body (AirSyncBase Namespace)] The airsyncbase:Body element is a container ([MS-ASDTYPE] section 2.2) element that specifies details about the body of a task item.");

                            this.VerifyContainerDataType();
                        }

                        if (null != task.Categories)
                        {
                            // Add the debug information
                            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R106");

                            // Since schema is validated, this requirement can be captured directly.
                            Site.CaptureRequirement(
                                106,
                                @"[In Categories] The Categories element is a container ([MS-ASDTYPE] section 2.2) element that specifies a collection of user-managed labels assigned to the task.");

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

                            // Since schema is validated, this requirement can be captured directly.
                            Site.CaptureRequirement(
                                108,
                                @"[In Categories] A command response has a maximum of one Categories element per command.");

                            if (null != task.Categories.Category)
                            {
                                // Add the debug information
                                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R114");

                                // Since schema is validated, this requirement can be captured directly.
                                Site.CaptureRequirement(
                                    114,
                                    @"[In Category] The value of this element[Category] is a string data type, as specified in [MS-ASDTYPE] section 2.6.");

                                if (Common.IsRequirementEnabled(402, Site))
                                {
                                    // Add the debug information
                                    Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R402, the actual number of category is: {0}", task.Categories.Category.Length);

                                    // Verify MS-ASTASK requirement: MS-ASTASK_R402
                                    // If the number of categories is not more than 300, this requirement will be captured.
                                    Site.CaptureRequirementIfIsTrue(
                                        task.Categories.Category.Length <= 300,
                                        402,
                                        @"[In Appendix B: Product Behavior] A Categories element does contain no more than 300 Category child elements. (Exchange 2007 SP1 and above follow this behavior.)");
                                }

                                this.VerifyStringDataType();
                            }

                            this.VerifyContainerDataType();
                        }

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

                        // Since schema is validated, this requirement can be captured directly.
                        Site.CaptureRequirement(
                            116,
                            @"[In Complete] The Complete element is a required element that specifies whether the task has been completed.");

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

                        // Since schema is validated, this requirement can be captured directly.
                        Site.CaptureRequirement(
                            118,
                            @"[In Complete] The value of this element[Complete] is an unsignedbyte data type, as specified in [MS-ASDTYPE] section 2.7.");

                        // Add the debug information
                        Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R119, the actual value of Complete is: &", task.Complete);

                        // Verify MS-ASTASK requirement: MS-ASTASK_R119
                        Site.CaptureRequirementIfIsTrue(
                            task.Complete == 0 || task.Complete == 1,
                            119,
                            @"[In Complete] The value of the Complete element MUST be one of the following values[The value is 0 or1].");

                        this.VerifyUnsignedByteDataType(task.Complete);

                        if (null != task.DateCompleted)
                        {
                            // Add the debug information
                            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R122");

                            // Since schema is validated, this requirement can be captured directly.
                            Site.CaptureRequirement(
                                122,
                                @"[In DateCompleted] The DateCompleted element specifies the date and time at which the task was completed.");

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

                            // Since schema is validated, this requirement can be captured directly.
                            Site.CaptureRequirement(
                                125,
                                @"[In DateCompleted] The value of this element [DateCompleted] is a dateTime data type, as specified in [MS-ASDTYPE] section 2.3.");

                            this.VerifyDateTimeDataType();
                        }

                        if (null != task.DueDate)
                        {
                            // Add the debug information
                            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R161");

                            // Since schema is validated, this requirement can be captured directly.
                            Site.CaptureRequirement(
                                161,
                                @"[In DueDate] The value of this element [DueDate] is a dateTime data type, as specified in [MS-ASDTYPE] section 2.3.");

                            this.VerifyDateTimeDataType();
                        }

                        if (null != task.Importance)
                        {
                            // Add the debug information
                            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R182");

                            // Since schema is validated, this requirement can be captured directly.
                            Site.CaptureRequirement(
                                182,
                                @"[In Importance] The value of this element [Importance] is an unsignedbyte data type, as specified in [MS-ASDTYPE] section 2.7.");

                            if (Common.IsRequirementEnabled(636, Site))
                            {
                                Site.Log.Add(LogEntryKind.Debug, "The returned value of Importance is: {0}.", task.Importance);
                                if (task.Importance >= 0 && task.Importance <= 2)
                                {
                                    // Add the debug information
                                    Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R636");

                                    // Capture R636 when the value is valid
                                    Site.CaptureRequirement(
                                        636,
                                        @"[In Appendix B: Product Behavior] The value of the Importance element is one of the following:[the value is between 0 to 2] (Exchange 2007 SP1 and above follow this behavior.)");
                                }
                            }

                            this.VerifyUnsignedByteDataType(task.Importance);
                        }

                        if (null != task.Recurrence)
                        {
                            // Add the debug information
                            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R221");

                            // Since schema is validated, this requirement can be captured directly.
                            Site.CaptureRequirement(
                                221,
                                @"[In Recurrence] The Recurrence element is a container ([MS-ASDTYPE] section 2.2) element that specifies when and how often the task recurs.");

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

                            // Since schema is validated, this requirement can be captured directly.
                            Site.CaptureRequirement(
                                223,
                                @"[In Recurrence] A command [request or] response has a maximum of one Recurrence element per command.");

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

                            // Since schema is validated, this requirement can be captured directly.
                            Site.CaptureRequirement(
                                225,
                                @"[In Recurence][The Recurrence element can have the following child elements:] Type (section 2.2.2.25): This element is required.");

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

                            // Since schema is validated, this requirement can be captured directly.
                            Site.CaptureRequirement(
                                226,
                                @"[In Recurence][The Recurrence element can have the following child elements:] Start (section 2.2.2.22): This element is required.");

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

                            // Since schema is validated, this requirement can be captured directly.
                            Site.CaptureRequirement(
                                77,
                                @"[In CalendarType] The CalendarType element<1> is a child element of the Recurrence element (section 2.2.2.18) that specifies the calendar system used by the task recurrence.");

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

                            // Since schema is validated, this requirement can be captured directly.
                            Site.CaptureRequirement(
                                79,
                                @"[In CalendarType] The value of this element[CalendarType] is an unsignedbyte data type, as specified in [MS-ASDTYPE] section 2.7.");

                            string[] expectedCalendarTypeValues = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "14", "15", "20" };

                            Common.VerifyActualValues("CalendarType", expectedCalendarTypeValues, task.Recurrence.CalendarType.ToString(), Site);

                            // Add the debug information
                            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R84, the actual value of CalendarType is: &", task.Recurrence.CalendarType);

                            // Since Common.VerifyActualValues runs successfully, this requirement can be captured.
                            Site.CaptureRequirement(
                                84,
                                @"[In CalendarType] The value of the CalendarType element MUST be one of the values listed in the following table[The value is among 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15 and 20].");

                            this.VerifyUnsignedByteDataType(task.Recurrence.CalendarType);

                            if (task.Recurrence.DayOfMonthSpecified)
                            {
                                // Add the debug information
                                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R128");

                                // Since schema is validated, this requirement can be captured directly.
                                Site.CaptureRequirement(
                                    128,
                                    @"[In DayOfMonth] The value of this element[DayOfMonth] is an unsignedbyte data type, as specified in [MS-ASDTYPE] section 2.7.");

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

                                // Since schema is validated, this requirement can be captured directly.
                                Site.CaptureRequirement(
                                    130,
                                    @"[In DayOfMonth] A command [request or] response has a maximum of one DayOfMonth element per Recurrence element.");

                                // Add the debug information
                                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R525, the actual value of DayOfMonth is: &", task.Recurrence.DayOfMonth);

                                // Verify MS-ASTASK requirement: MS-ASTASK_R525
                                Site.CaptureRequirementIfIsTrue(
                                    task.Recurrence.DayOfMonth >= 1 && task.Recurrence.DayOfMonth <= 31,
                                    525,
                                    @"[In DayOfMonth] The value of the DayOfMonth element MUST be between 1 and 31.");

                                this.VerifyUnsignedByteDataType(task.Recurrence.DayOfMonth);
                            }

                            if (task.Recurrence.DayOfWeekSpecified)
                            {
                                // Add the debug information
                                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R139");

                                // Since schema is validated, this requirement can be captured directly.
                                Site.CaptureRequirement(
                                    139,
                                    @"[In DayOfWeek] A command response has a maximum of one DayOfWeek element per Recurrence element.");

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

                                // Since schema is validated, this requirement can be captured directly.
                                Site.CaptureRequirement(
                                    140,
                                    @"[In DayOfWeek] The value of this element [DayOfWeek] is an unsignedbyte data type, as specified in [MS-ASDTYPE] section 2.7.");

                                // Add the debug information
                                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R141, the actual value of DayOfWeek is: &", task.Recurrence.DayOfWeek);

                                // Verify MS-ASTASK requirement: MS-ASTASK_R141
                                // After calculation, the range of the numbers possible is between 1 to 254. 
                                Site.CaptureRequirementIfIsTrue(
                                    task.Recurrence.DayOfWeek >= 1 && task.Recurrence.DayOfWeek <= 254,
                                    141,
                                    @"[In DayOfWeek] The value of the DayOfWeek element MUST be either one of the following values[the value is 1,2,4,8,16,32,64 or 127], or the sum of more than one of the following values (in which case this task recurs on more than one day).");

                                this.VerifyUnsignedByteDataType(task.Recurrence.DayOfWeek);
                            }

                            if (task.Recurrence.DeadOccurSpecified)
                            {
                                // Add the debug information
                                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R154");

                                // Since schema is validated, this requirement can be captured directly.
                                Site.CaptureRequirement(
                                    154,
                                    @"[In DeadOccur] The value of this element [DeadOccur] is an unsignedbyte data type, as specified in [MS-ASDTYPE] section 2.7.");

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

                                // Since schema is validated, this requirement can be captured directly.
                                Site.CaptureRequirement(
                                    155,
                                    @"[In DeadOccur] A command [request or] response has a maximum of one DeadOccur child element per Recurrence element.");

                                this.VerifyUnsignedByteDataType(task.Recurrence.DeadOccur);
                            }

                            if (task.Recurrence.FirstDayOfWeekSpecified)
                            {
                                // Add the debug information
                                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R162");

                                // Since schema is validated, this requirement can be captured directly.
                                Site.CaptureRequirement(
                                    162,
                                    @"[In FirstDayOfWeek] The FirstDayOfWeek element is a child element of the Recurrence element (section 2.2.2.18) that specifies which day is considered the first day of the calendar week for this recurrence.");

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

                                // Since schema is validated, this requirement can be captured directly.
                                Site.CaptureRequirement(
                                    164,
                                    @"[In FirstDayOfWeek] The value of this element[FirstDayOfWeek] is an unsignedbyte data type, as specified in [MS-ASDTYPE] section 2.7.");

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

                                // Since schema is validated, this requirement can be captured directly.
                                Site.CaptureRequirement(
                                    166,
                                    @"[In FirstDayOfWeek] A command [request or] response has a maximum of one FirstDayOfWeek child element per Recurrence element.");

                                // Add the debug information
                                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R170, the actual value of FirstDayOfWeek is: &", task.Recurrence.FirstDayOfWeek);

                                // Verify MS-ASTASK requirement: MS-ASTASK_R170
                                Site.CaptureRequirementIfIsTrue(
                                    task.Recurrence.FirstDayOfWeek <= 6,
                                    170,
                                    @"[In FirstDayOfWeek] The value of the FirstDayOfWeek element MUST be one of the values defined in the following table[the value is between 0 to 6].");

                                this.VerifyUnsignedByteDataType(task.Recurrence.FirstDayOfWeek);
                            }

                            if (task.Recurrence.IntervalSpecified)
                            {
                                // Add the debug information
                                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R190");

                                // Since schema is validated, this requirement can be captured directly.
                                Site.CaptureRequirement(
                                    190,
                                    @"[In Interval] A command [request or] response has a maximum of one Interval element per Recurrence element.");

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

                                // Since schema is validated, this requirement can be captured directly.
                                Site.CaptureRequirement(
                                    191,
                                    @"[In Interval] The value of the Interval element is an unsignedShort, as specified in [XMLSCHEMA2/2] section 3.3.23. ");

                                // Add the debug information
                                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R192, the actual value of Interval is: &", task.Recurrence.Interval);

                                // Verify MS-ASTASK requirement: MS-ASTASK_R192
                                Site.CaptureRequirementIfIsTrue(
                                    task.Recurrence.Interval <= 999,
                                    192,
                                    @"[In Interval] The maximum value of this element[Interval] is 999.");
                            }

                            if (task.Recurrence.IsLeapMonthSpecified)
                            {
                                // Add the debug information
                                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R195");

                                // Since schema is validated, this requirement can be captured directly.
                                Site.CaptureRequirement(
                                    195,
                                    @"[In IsLeapMonth] The value of this element[IsLeapMonth] is an unsignedbyte data type, as specified in [MS-ASDTYPE] section 2.7.");

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

                                // Since schema is validated, this requirement can be captured directly.
                                Site.CaptureRequirement(
                                    197,
                                    @"[In IsLeapMonth] A command [request or] response has a maximum of one IsLeapMonth child element per Recurrence element.");

                                // Add the debug information
                                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R201, the actual value of IsLeapMonth is: &", task.Recurrence.IsLeapMonth);

                                // Verify MS-ASTASK requirement: MS-ASTASK_R201
                                Site.CaptureRequirementIfIsTrue(
                                    task.Recurrence.IsLeapMonth == 0 || task.Recurrence.IsLeapMonth == 1,
                                    201,
                                    @"[In IsLeapMonth] The value of the IsLeapMonth element MUST be one of the following values[the value is 0 or 1].");

                                this.VerifyUnsignedByteDataType(task.Recurrence.IsLeapMonth);
                            }

                            if (task.Recurrence.MonthOfYearSpecified)
                            {
                                // Add the debug information
                                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R207");

                                // Since schema is validated, this requirement can be captured directly.
                                Site.CaptureRequirement(
                                    207,
                                    @"[In MonthOfYear] The value of this element[MonthOfYear] is an unsignedbyte data type, as specified in [MS-ASDTYPE] section 2.7");

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

                                // Since schema is validated, this requirement can be captured directly.
                                Site.CaptureRequirement(
                                    209,
                                    @"[In MonthOfYear] A command [request or] response has a maximum of one MonthofYear child element per Recurrence element.");

                                // Add the debug information
                                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R210, the actual value of MonthOfYear is: &", task.Recurrence.MonthOfYear);

                                // Verify MS-ASTASK requirement: MS-ASTASK_R210
                                Site.CaptureRequirementIfIsTrue(
                                    task.Recurrence.MonthOfYear >= 1 && task.Recurrence.MonthOfYear <= 12,
                                    210,
                                    @"[In MonthOfYear] The value of the MonthofYear element MUST be between 1 and 12.");

                                this.VerifyUnsignedByteDataType(task.Recurrence.MonthOfYear);
                            }

                            if (task.Recurrence.OccurrencesSpecified)
                            {
                                // Add the debug information
                                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R213");

                                // Since schema is validated, this requirement can be captured directly.
                                Site.CaptureRequirement(
                                    213,
                                    @"[In Occurrences] The value of this element[Occurrences] is an unsignedbyte data type, as specified in [MS-ASDTYPE] section 2.7.");

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

                                // Since schema is validated, this requirement can be captured directly.
                                Site.CaptureRequirement(
                                    214,
                                    @"[In Occurrences] A command [request or] response has a maximum of one Occurrences child element per Recurrence element.");

                                this.VerifyUnsignedByteDataType(task.Recurrence.Occurrences);
                            }

                            if (task.Recurrence.RegenerateSpecified)
                            {
                                // Add the debug information
                                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R241");

                                // Since schema is validated, this requirement can be captured directly.
                                Site.CaptureRequirement(
                                    241,
                                    @"[In Regenerate] The value of this element [Regenerate] is an unsignedbyte data type, as specified in [MS-ASDTYPE] section 2.7.");

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

                                // Since schema is validated, this requirement can be captured directly.
                                Site.CaptureRequirement(
                                    242,
                                    @"[In Regenerate] A command [request or] response has a maximum of one Regenerate child element per Recurrence element.");

                                this.VerifyUnsignedByteDataType(task.Recurrence.Regenerate);
                            }

                            if (Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("14.0"))
                            {
                                if (Common.IsRequirementEnabled(633, Site))
                                {
                                    // Add the debug information
                                    Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R633");

                                    // Verify MS-ASTASK requirement: MS-ASTASK_R633
                                    Site.CaptureRequirementIfIsFalse(
                                        task.Recurrence.StartSpecified,
                                        633,
                                        @"[In Appendix A: Product Behavior] <2> Section 2.2.2.25:  Microsoft Exchange Server 2010 Service Pack 1 (SP1), the initial release version of Exchange 2013, and Exchange 2016 Preview do not return the Start element when protocol version is 14.0.");
                                }
                            }
                            else
                            {
                                // Add the debug information
                                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R267");

                                // Since schema is validated, this requirement can be captured directly.
                                Site.CaptureRequirement(
                                    267,
                                    @"[In Start] A command [request or] response has a minimum of one Start child element per Recurrence element.");

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

                                // Since schema is validated, this requirement can be captured directly.
                                Site.CaptureRequirement(
                                    268,
                                    @"[In Start] A command [request or] response has a maximum of one Start child element per Recurrence element.");

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

                                // Since schema is validated, this requirement can be captured directly.
                                Site.CaptureRequirement(
                                    271,
                                    @"[In Start] The value of this element [Start] is a dateTime data type, as specified in [MS-ASDTYPE] section 2.3.");
                                this.VerifyDateTimeDataType();
                            }

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

                            // Since schema is validated, this requirement can be captured directly.
                            Site.CaptureRequirement(
                                285,
                                @"[In Type] The Type element is a required child element of the Recurrence element (section 2.2.2.18) that specifies the type of the recurrence item.");

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

                            // Since schema is validated, this requirement can be captured directly.
                            Site.CaptureRequirement(
                                287,
                                @"[In Type] A command [request or] response has a minimum of one Type child element per Recurrence element.");

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

                            // Since schema is validated, this requirement can be captured directly.
                            Site.CaptureRequirement(
                                288,
                                @"[In Type] A command [request or] response has a maximum of one Type child element per Recurrence element.");

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

                            // Since schema is validated, this requirement can be captured directly.
                            Site.CaptureRequirement(
                                291,
                                @"[In Type] The value of this element[Type] is an unsignedbyte data type, as specified in [MS-ASDTYPE] section 2.7.");

                            string[] expectedTypeValues = { "0", "1", "2", "3", "5", "6" };

                            Common.VerifyActualValues("Type", expectedTypeValues, task.Recurrence.CalendarType.ToString(), Site);

                            // Add the debug information
                            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R292, the actual value of Type is: &", task.Recurrence.Type);

                            // Since Common.VerifyActualValues runs successfully, this requirement can be captured.
                            Site.CaptureRequirement(
                                292,
                                @"[In Type] The value of the Type element MUST be one of the following values[the value is between 0 to 6, except for 4].");

                            if (task.Recurrence.Type == 1)
                            {
                                // Add the debug information
                                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R238");

                                // Since schema is validated, this requirement can be captured directly.
                                Site.CaptureRequirement(
                                    238,
                                    @"[In Recurence][The Recurrence element can have the following child elements:] FirstDayOfWeek (section 2.2.2.11): This element is required in server's responses for weekly recurrences.");
                            }

                            if (task.Recurrence.UntilSpecified)
                            {
                                // Add the debug information
                                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R301");

                                // Since schema is validated, this requirement can be captured directly.
                                Site.CaptureRequirement(
                                    301,
                                    @"[In Until] A command [request or] response has a maximum of one Until child element per Recurrence element.");

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

                                // Since schema is validated, this requirement can be captured directly.
                                Site.CaptureRequirement(
                                    305,
                                    @"[In Until] The value of this element[Until] is a dateTime data type, as specified in [MS-ASDTYPE] section 2.3.");

                                this.VerifyDateTimeDataType();
                            }

                            if (task.Recurrence.WeekOfMonthSpecified)
                            {
                                // Add the debug information
                                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R314");

                                // Since schema is validated, this requirement can be captured directly.
                                Site.CaptureRequirement(
                                    314,
                                    @"[In WeekOfMonth] The value of this element [WeekOfMonth] is an unsignedbyte data type, as specified in [MS-ASDTYPE] section 2.7.");

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

                                // Since schema is validated, this requirement can be captured directly.
                                Site.CaptureRequirement(
                                    316,
                                    @"[In WeekOfMonth] A command [request or] response has a maximum of one WeekOfMonth child element per Recurrence element.");

                                // Add the debug information
                                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R317, the actual value of WeekOfMonth is: &", task.Recurrence.WeekOfMonth);

                                // Verify MS-ASTASK requirement: MS-ASTASK_R317
                                Site.CaptureRequirementIfIsTrue(
                                    task.Recurrence.WeekOfMonth >= 1 && task.Recurrence.WeekOfMonth <= 5,
                                    317,
                                    @"[In WeekOfMonth] The value of the WeekOfMonth element MUST be between 1 and 5.");

                                this.VerifyUnsignedByteDataType(task.Recurrence.WeekOfMonth);
                            }

                            this.VerifyContainerDataType();
                        }

                        if (null != task.ReminderSet)
                        {
                            // Add the debug information
                            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R248");

                            // Since schema is validated, this requirement can be captured directly.
                            Site.CaptureRequirement(
                                248,
                                @"[In ReminderSet] The value of this element[ReminderSet] is an unsignedbyte data type, as specified in [MS-ASDTYPE] section 2.7.");

                            // Add the debug information
                            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R249, the actual value of ReminderSet is: &", task.ReminderSet);

                            // Verify MS-ASTASK requirement: MS-ASTASK_R249
                            Site.CaptureRequirementIfIsTrue(
                                task.ReminderSet == 0 || task.ReminderSet == 1,
                                249,
                                @"[In ReminderSet] The value of the ReminderSet element MUST be one of the following values[the value is 0 or 1].");

                            this.VerifyUnsignedByteDataType(task.ReminderSet);
                        }

                        if (null != task.ReminderTime)
                        {
                            // Add the debug information
                            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R255");

                            // Since schema is validated, this requirement can be captured directly.
                            Site.CaptureRequirement(
                                255,
                                @"[In ReminderTime] The value of this element [ReminderTime] is a dateTime data type, as specified in [MS-ASDTYPE] section 2.3.");

                            this.VerifyDateTimeDataType();
                        }

                        if (null != task.Sensitivity)
                        {
                            // Add the debug information
                            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R258");

                            // Since schema is validated, this requirement can be captured directly.
                            Site.CaptureRequirement(
                                258,
                                @"[In Sensitivity] The value of this element[Sensitivity] is an unsignedbyte data type, as specified in [MS-ASDTYPE] section 2.7.");

                            // Add the debug information
                            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R259, the actual value of Sensitivity is: &", task.Sensitivity);

                            // Verify MS-ASTASK requirement: MS-ASTASK_R259
                            Site.CaptureRequirementIfIsTrue(
                                task.Sensitivity >= 0 && task.Sensitivity <= 3,
                                259,
                                @"[In Sensitivity] The value of the Sensitivity element MUST be one of the following values[the value is between 0 and 3].");

                            this.VerifyUnsignedByteDataType(task.Sensitivity);
                        }

                        if (null != task.StartDate)
                        {
                            // Add the debug information
                            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R274");

                            // Since schema is validated, this requirement can be captured directly.
                            Site.CaptureRequirement(
                                274,
                                @"[In StartDate] The value of this element[StartDate] is a dateTime data type, as specified in [MS-ASDTYPE] section 2.3.");

                            this.VerifyDateTimeDataType();
                        }

                        if (null != task.Subject)
                        {
                            // Add the debug information
                            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R277");

                            // Since schema is validated, this requirement can be captured directly.
                            Site.CaptureRequirement(
                                277,
                                @"[In Subject] The value of this element [Subject] is a string data type, as specified in [MS-ASDTYPE] section 2.6.");

                            this.VerifyStringDataType();
                        }

                        if (null != task.UtcDueDate)
                        {
                            // Add the debug information
                            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R308");

                            // Since schema is validated, this requirement can be captured directly.
                            Site.CaptureRequirement(
                                308,
                                @"[In UtcDueDate] The value of this element [UtcDueDate] is a dateTime data type, as specified in [MS-ASDTYPE] section 2.3.");

                            this.VerifyDateTimeDataType();
                        }

                        if (null != task.UtcStartDate)
                        {
                            // Add the debug information
                            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R311");

                            // Since schema is validated, this requirement can be captured directly.
                            Site.CaptureRequirement(
                                311,
                                @"[In UtcStartDate] The value of this element [UtcStartDate] is a dateTime data type, as specified in [MS-ASDTYPE] section 2.3.");

                            this.VerifyDateTimeDataType();
                        }
                    }
                }
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// This method is used to verify the Sync command response related requirements.
        /// </summary>
        /// <param name="syncStore">The Sync result returned from the server.</param>
        private void VerifySyncResponse(SyncStore syncStore)
        {
            if (syncStore.AddElements.Count != 0 || syncStore.ChangeElements.Count != 0)
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCNTC_R473");

                // Verify MS-ASCNTC requirement: MS-ASCNTC_R473
                Site.CaptureRequirementIfIsTrue(
                    this.activeSyncClient.ValidationResult,
                    473,
                    @"[In Synchronizing Contact Data Between Client and Server] [If a client sends a Sync command request to the server]The server responds with a Sync command response ([MS-ASCMD] section 2.2.2.19).");

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

                // Verify MS-ASCNTC requirement: MS-ASCNTC_R492
                Site.CaptureRequirementIfIsTrue(
                    this.activeSyncClient.ValidationResult,
                    492,
                    @"[In Sync Command Response] When a client uses the Sync command request ([MS-ASCMD] section 2.2.2.19) to synchronize its Contact class items for a specified user with the contacts currently stored by the server, as specified in section 3.1.5.3, the server responds with a Sync command response ([MS-ASCMD] section 2.2.2.19).");
                
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCNTC_R514");

                // Verify MS-ASCNTC requirement: MS-ASCNTC_R514
                Site.CaptureRequirementIfIsTrue(
                    this.activeSyncClient.ValidationResult,
                    514,
                    @"[In Refreshing the Recipient Information Cache] [If a client sends a Sync command request to the server for refreshing]The server responds with a Sync command response ([MS-ASCMD] section 2.2.2.19) that includes only the following elements from the Contact class:
 Email1Address (section 2.2.2.25)
 FileAs (section 2.2.2.28)
 Alias (section 2.2.2.2)
 WeightedRank (section 2.2.2.62)");
            }

            if (syncStore.AddElements.Count != 0)
            {
                foreach (Sync item in syncStore.AddElements)
                {
                    // Add the debug information
                    Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCNTC_R493");

                    // Verify MS-ASCNTC requirement: MS-ASCNTC_R493
                    Site.CaptureRequirementIfIsTrue(
                        this.activeSyncClient.ValidationResult,
                        493,
                        @"[In Sync Command Response] Any of the elements that belong to the Contact class, as specified in section 2.2.2, can be included in a Sync command response as child elements of the airsync:ApplicationData element ([MS-ASCMD] section 2.2.3.11) within either an airsync:Add element ([MS-ASCMD] section 2.2.3.7.2).");

                    this.VerifyContactClassElements(item.Contact);
                }
            }

            if (syncStore.ChangeElements.Count != 0)
            {
                foreach (Sync item in syncStore.ChangeElements)
                {
                    // Add the debug information
                    Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCNTC_R494");

                    // Verify MS-ASCNTC requirement: MS-ASCNTC_R494
                    Site.CaptureRequirementIfIsTrue(
                        this.activeSyncClient.ValidationResult,
                        494,
                        @"[In Sync Command Response] Any of the elements that belong to the Contact class, as specified in section 2.2.2, can be included in a Sync command response as child elements of the airsync:ApplicationData element ([MS-ASCMD] section 2.2.3.11) within [or] an airsync:Change element ([MS-ASCMD] section 2.2.3.24).");

                    this.VerifyContactClassElements(item.Contact);
                }
            }

            this.VerifyMessageSyntax();
            this.VerifyAbstractDataModel();
        }
        /// <summary>
        /// Get the specified email item from the sync change response by using the subject as the search criteria.
        /// </summary>
        /// <param name="syncResult">The sync result.</param>
        /// <param name="serverId">The email server id.</param>
        /// <returns>Return the specified email item.</returns>
        internal static Sync GetSyncChangeItem(SyncStore syncResult, string serverId)
        {
            Sync item = null;
            if (syncResult.ChangeElements != null)
            {
                foreach (Sync syncItem in syncResult.ChangeElements)
                {
                    if (syncItem.ServerId == serverId)
                    {
                        item = syncItem;
                        break;
                    }
                }
            }

            return item;
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Load SyncResponse to SyncStore.
        /// </summary>
        /// <param name="response">A SyncResponse instance.</param>
        /// <returns>The SyncStore instance.</returns>
        public static DataStructures.SyncStore LoadSyncResponse(SyncResponse response)
        {
            DataStructures.SyncStore result = new DataStructures.SyncStore();
            if (string.IsNullOrEmpty(response.ResponseData.Status))
            {
                result.StatusSpecified = false;
            }
            else
            {
                result.StatusSpecified = true;
            }

            if (result.StatusSpecified)
            {
                result.Status = Convert.ToInt32(response.ResponseData.Status);
            }

            if (response.ResponseData.Item == null)
            {
                return result;
            }

            Response.SyncCollectionsCollection collection = ((Response.SyncCollections)response.ResponseData.Item).Collection[0];
            for (int i = 0; i < collection.ItemsElementName.Length; i++)
            {
                switch (collection.ItemsElementName[i])
                {
                    case Response.ItemsChoiceType10.CollectionId:
                        result.CollectionId = collection.Items[i].ToString();
                        break;
                    case Response.ItemsChoiceType10.SyncKey:
                        result.SyncKey = collection.Items[i].ToString();
                        break;
                    case Response.ItemsChoiceType10.Status:
                        result.CollectionStatus = Convert.ToByte(collection.Items[i]);
                        break;
                    case Response.ItemsChoiceType10.Commands:
                        Response.SyncCollectionsCollectionCommands commands = collection.Items[i] as Response.SyncCollectionsCollectionCommands;
                        if (commands != null)
                        {
                            LoadAddElements(commands, result.AddElements);
                            LoadChangeElements(commands, result.ChangeElements);
                            LoadDeleteElements(commands, result.DeleteElements);
                        }

                        break;
                    case Response.ItemsChoiceType10.Responses:
                        Response.SyncCollectionsCollectionResponses responses = collection.Items[i] as Response.SyncCollectionsCollectionResponses;
                        if (responses != null)
                        {
                            if (responses.Add != null)
                            {
                                foreach (Response.SyncCollectionsCollectionResponsesAdd add in responses.Add)
                                {
                                    result.AddResponses.Add(add);
                                }
                            }

                            if (responses.Change != null)
                            {
                                foreach (Response.SyncCollectionsCollectionResponsesChange change in responses.Change)
                                {
                                    result.ChangeResponses.Add(change);
                                }
                            }
                        }

                        break;
                }
            }

            return result;
        }
Ejemplo n.º 24
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.Location1);

            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 Search command to search the added calendar item.
            this.GetSearchResult(subject, this.User1Information.CalendarCollectionId, null, null, null);
            #endregion
        }
        /// <summary>
        /// Get the specified email item from the sync add response by using the subject as the search criteria.
        /// </summary>
        /// <param name="syncResult">The sync result.</param>
        /// <param name="subject">The email subject.</param>
        /// <returns>Return the specified email item.</returns>
        internal static Sync GetSyncAddItem(SyncStore syncResult, string subject)
        {
            Sync item = null;

            if (syncResult.AddElements != null)
            {
                foreach (Sync syncItem in syncResult.AddElements)
                {
                    if (syncItem.Email.Subject == subject)
                    {
                        item = syncItem;
                        break;
                    }

                    if (syncItem.Calendar.Subject == subject)
                    {
                        item = syncItem;
                        break;
                    }
                }
            }

            return item;
        }
        /// <summary>
        /// Add flag for an email item.
        /// </summary>
        /// <param name="userInformation">The information for user</param>
        /// <param name="getEmailItem">The specified email item which should be added the flag.</param>
        /// <param name="emailSubject">The subject of the specified email item.</param>
        /// <param name="flag">The flag which should be added to the specified email item.</param>
        /// <returns>The result store of adding flag.</returns>
        private SyncStore AddEmailFag(UserInformation userInformation, SyncStore getEmailItem, string emailSubject, Request.Flag flag)
        {
            // Get the new added email item
            Sync emailItem = TestSuiteHelper.GetSyncAddItem(getEmailItem, emailSubject);
            Site.Assert.IsNotNull(emailItem, "The email item with subject '{0}' should be found.", emailSubject);

            // Add flag to the email item
            this.UpdateEmail(userInformation.InboxCollectionId, getEmailItem.SyncKey, null, emailItem.ServerId, flag, null);

            // Get the server changes of adding flag and category
            return this.SyncChanges(getEmailItem.SyncKey, this.User1Information.InboxCollectionId, null);
        }
        public void MSASTASK_S03_TC01_RetrieveTaskItemWithSearch()
        {
            #region Call Sync command to create a task item

            Dictionary <Request.ItemsChoiceType8, object> taskItem = new Dictionary <Request.ItemsChoiceType8, object>();
            string subject = Common.GenerateResourceName(Site, "subject");
            taskItem.Add(Request.ItemsChoiceType8.Subject2, subject);

            #endregion

            #region Call Sync command to add the task to the server

            // add task
            SyncStore syncResponse = this.SyncAddTask(taskItem);
            Site.Assert.AreEqual <int>(1, int.Parse(syncResponse.AddResponses[0].Status), "Adding a task item to server should success.");
            SyncItem task = this.GetChangeItem(this.UserInformation.TasksCollectionId, subject);
            Site.Assert.IsNotNull(task.Task, "The task which subject is {0} should exist in server.", subject);
            ItemsNeedToDelete.Add(subject);

            #endregion

            #region Call Search command to search task on the server

            Request.Options1 option = new Request.Options1();
            Dictionary <Request.ItemsChoiceType6, object> items = new Dictionary <Request.ItemsChoiceType6, object>
            {
                {
                    Request.ItemsChoiceType6.DeepTraversal, string.Empty
                },
                {
                    Request.ItemsChoiceType6.RebuildResults, string.Empty
                },
                {
                    Request.ItemsChoiceType6.Range, "0-9"
                }
            };
            option.Items            = items.Values.ToArray <object>();
            option.ItemsElementName = items.Keys.ToArray <Request.ItemsChoiceType6>();

            Request.queryType queryItem = new Request.queryType
            {
                Items = new object[] { "Tasks", this.UserInformation.TasksCollectionId, subject },

                ItemsElementName = new Request.ItemsChoiceType2[]
                {
                    Request.ItemsChoiceType2.Class,
                    Request.ItemsChoiceType2.CollectionId,
                    Request.ItemsChoiceType2.FreeText
                }
            };

            Request.queryType queryType = new Request.queryType
            {
                Items            = new object[] { queryItem },
                ItemsElementName = new Request.ItemsChoiceType2[] { Request.ItemsChoiceType2.And }
            };

            SearchRequest searchRequest = TestSuiteHelper.CreateSearchRequest(SearchName.Mailbox.ToString(), option, queryType);

            // Search the task
            SearchStore searchResponse = this.TASKAdapter.Search(searchRequest);

            // Verify search response
            Site.Assert.AreNotEqual <int>(0, searchResponse.Range.Length, "The search response should be successful");

            #endregion

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

            // Verify MS-ASTASK requirement: MS-ASTASK_R361
            // If the Task item in response is not null, this requirement can be captured.
            Site.CaptureRequirementIfIsNotNull(
                searchResponse.Results[0].Task,
                361,
                @"[In Search Command Response] When a client uses the Search command request ([MS-ASCMD] section 2.2.2.14) to retrieve Task class items from the server that match the criteria specified by the client, as specified in section 3.1.5.2, the server responds with a Search command response ([MS-ASCMD] section 2.2.2.14).");

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

            // Since MS-ASTASK_R361 is captured, this requirement can be captured too.
            Site.CaptureRequirement(
                363,
                @"[In Search Command Response] Top-level Task class elements, as specified in section 2.2, are returned as child elements of the search:Properties element ([MS-ASCMD] section 2.2.3.128) in the Search command response.");
        }