public void MSASNOTE_S03_TC02_ItemOperations_SchemaViewFetch()
        {
            #region Call method Sync to add a note to the server
            Dictionary <Request.ItemsChoiceType8, object> addElements = this.CreateNoteElements();
            this.SyncAdd(addElements, 1);
            #endregion

            #region Call method Search to search notes using the given keyword text

            // Search note from server
            SearchStore result = this.NOTEAdapter.Search(this.UserInformation.NotesCollectionId, addElements[Request.ItemsChoiceType8.Subject1].ToString(), true, 1);

            Site.Assert.AreEqual <int>(
                1,
                result.Results.Count,
                @"There should be only one note item returned in sync response.");

            #endregion

            #region Call method ItemOperations to fetch all the information about notes using longIds.
            // longIds:Long id of the created note item.
            List <string> longIds = new List <string> {
                result.Results[0].LongId
            };

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

            // serverIds:null
            ItemOperationsRequest itemOperationRequest = TestSuiteHelper.CreateItemOperationsFetchRequest(null, null, longIds, bodyReference, schema);
            ItemOperationsStore   itemOperationsResult = this.NOTEAdapter.ItemOperations(itemOperationRequest);
            Site.Assert.IsNotNull(itemOperationsResult, "The ItemOperations result must not be null!");

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

            Site.Assert.IsNull(itemOperationsResult.Items[0].Note.Subject, "Subject should be null.");
            Site.Assert.IsNull(itemOperationsResult.Items[0].Note.MessageClass, "MessageClass should be null.");
            Site.Assert.IsNull(itemOperationsResult.Items[0].Note.Categories, "Categories should be null.");
            Site.Assert.IsFalse(itemOperationsResult.Items[0].Note.IsLastModifiedDateSpecified, "LastModifiedSpecified should not be present.");

            // Verify MS-ASNOTE requirement: MS-ASNOTE_R103
            Site.CaptureRequirementIfIsNotNull(
                itemOperationsResult.Items[0].Note.Body,
                103,
                @"[In ItemOperations Command Response] If an itemoperations:Schema element ([MS-ASCMD] section 2.2.3.145) 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.");

            #endregion
        }
        /// <summary>
        /// Fetch all the data about tasks.
        /// </summary>
        /// <param name="itemOperationsRequest">An ItemOperations command request.</param>
        /// <returns>An ItemOperations command response returned from the server.</returns>
        public ItemOperationsStore ItemOperations(ItemOperationsRequest itemOperationsRequest)
        {
            ItemOperationsResponse response = this.activeSyncClient.ItemOperations(itemOperationsRequest, DeliveryMethodForFetch.Inline);

            Site.Assert.IsNotNull(response, "The ItemOperations response should be returned.");
            ItemOperationsStore itemOperationResponse = Common.LoadItemOperationsResponse(response);

            this.VerifyItemOperationsResponse(itemOperationResponse);

            return(itemOperationResponse);
        }
        /// <summary>
        /// Fetch all information about exchange object.
        /// </summary>
        /// <param name="itemOperationsRequest">The request for itemOperations.</param>
        /// <returns>The ItemOperations result which is returned from server.</returns>
        public ItemOperationsStore ItemOperations(ItemOperationsRequest itemOperationsRequest)
        {
            ItemOperationsResponse response = this.activeSyncClient.ItemOperations(itemOperationsRequest, DeliveryMethodForFetch.Inline);

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

            this.VerifyTransport();
            this.VerifyItemOperations(result);
            this.VerifyWBXMLCapture();
            return(result);
        }
        /// <summary>
        /// Retrieves an item from the server by sending ItemOperationsRequest object.
        /// </summary>
        /// <param name="request">An ItemOperationsRequest object which contains the request information.</param>
        /// <param name="deliveryMethod">The delivery method specifies what kind of response is accepted.</param>
        /// <returns>An ItemOperationsStore object.</returns>
        public ItemOperationsStore ItemOperations(ItemOperationsRequest request, DeliveryMethodForFetch deliveryMethod)
        {
            ItemOperationsResponse response = this.activeSyncClient.ItemOperations(request, deliveryMethod);

            Site.Assert.IsNotNull(response, "If the ItemOperations command executes successfully, the response from server should not be null.");
            ItemOperationsStore itemOperationsStore = Common.LoadItemOperationsResponse(response);

            this.VerifyTransport();
            this.VerifyWBXMLCapture();
            this.VerifyItemOperationsResponse(itemOperationsStore);

            return(itemOperationsStore);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Fetch all information about exchange object
        /// </summary>
        /// <param name="itemOperationsRequest">ItemOperations command request.</param>
        /// <returns>The ItemOperations result which is returned from server</returns>
        public ItemOperationsStore ItemOperations(ItemOperationsRequest itemOperationsRequest)
        {
            ItemOperationsResponse response = this.activeSyncClient.ItemOperations(itemOperationsRequest, DeliveryMethodForFetch.Inline);

            this.VerifyItemOperationsResponse(response);
            ItemOperationsStore result = Common.LoadItemOperationsResponse(response);
            bool hasSchemaElement      = AdapterHelper.ContainsSchemaElement(itemOperationsRequest);

            this.VerifyTransport();
            this.VerifyItemOperationResult(result, hasSchemaElement);
            this.VerifyWBXMLCapture();
            return(result);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Call ItemOperations command to fetch an email in the specific folder.
        /// </summary>
        /// <param name="collectionId">The folder collection id to be fetched.</param>
        /// <param name="serverId">The ServerId of the item</param>
        /// <param name="bodyPartPreference">The BodyPartPreference element.</param>
        /// <param name="bodyPreference">The bodyPreference element.</param>
        /// <returns>An Email instance that includes the fetch result.</returns>
        protected Email ItemOperationsFetch(string collectionId, string serverId, Request.BodyPartPreference bodyPartPreference, Request.BodyPreference bodyPreference)
        {
            ItemOperationsRequest  itemOperationsRequest  = TestSuiteHelper.GetItemOperationsRequest(collectionId, serverId, bodyPartPreference, bodyPreference);
            ItemOperationsResponse itemOperationsResponse = this.CONAdapter.ItemOperations(itemOperationsRequest);

            Site.Assert.AreEqual("1", itemOperationsResponse.ResponseData.Status, "The ItemOperations operation should be success.");

            ItemOperationsStore itemOperationsStore = Common.LoadItemOperationsResponse(itemOperationsResponse);

            Site.Assert.AreEqual(1, itemOperationsStore.Items.Count, "Only one email is supposed to be fetched.");
            Site.Assert.AreEqual("1", itemOperationsStore.Items[0].Status, "The fetch result should be success.");
            Site.Assert.IsNotNull(itemOperationsStore.Items[0].Email, "The fetched email should not be null.");

            return(itemOperationsStore.Items[0].Email);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// This method is used to verify the ItemOperation response related requirements.
        /// </summary>
        /// <param name="itemResponse">Specified ItemStore result returned from the server</param>
        /// <param name="isSchemaRestricted">Specified whether the note elements in response are restricted by schema element</param>
        private void VerifyItemOperationResult(ItemOperationsStore itemResponse, bool isSchemaRestricted)
        {
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASNOTE_R104");

            // Verify MS-ASNOTE requirement: MS-ASNOTE_R104
            Site.CaptureRequirementIfIsTrue(
                this.activeSyncClient.ValidationResult,
                104,
                @"[In ItemOperations Command Response] Notes class elements[airsyncbase:Body, Subject,  MessageClass, LastModifiedDate, Categories or Category] are returned as child elements of the itemoperations:Properties element ([MS-ASCMD] section 2.2.3.128) in the ItemOperations command response.");

            foreach (ItemOperations itemOperations in itemResponse.Items)
            {
                if (itemOperations.Note != null)
                {
                    this.VerifyNote(itemOperations.Note, isSchemaRestricted);
                }
            }

            this.VerifyMessageSyntax();
        }
Ejemplo n.º 8
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.");
        }
        public void MSASRM_S02_TC01_ItemOperations_RightsManagedEmailMessages()
        {
            this.CheckPreconditions();

            #region The client logs on User1's account, calls Settings command to get a templateID with all rights allowed.
            string templateID = this.GetTemplateID("MSASRM_AllRights_AllowedTemplate");
            #endregion

            #region The client logs on User1's account, calls SendMail command with the templateID to send a rights-managed e-mail message to User2, switches to User2, and calls FolderSync command.
            string subject = this.SendMailAndFolderSync(templateID, false, null);
            #endregion

            #region The client logs on User2's account, calls Sync command with RightsManagementSupport element set to true to synchronize changes of Inbox folder in User2's mailbox, and gets the decompressed and decrypted rights-managed e-mail message.
            Sync item = this.SyncEmail(subject, this.UserTwoInformation.InboxCollectionId, true, true);
            Site.Assert.IsNotNull(item, "The returned item should not be null.");
            Site.Assert.IsNull(item.Email.Attachments, "The Attachments element in expected rights-managed e-mail message should be null.");
            Site.Assert.IsNotNull(item.Email.RightsManagementLicense, "The RightsManagementLicense element in expected rights-managed e-mail message should not be null.");
            Site.Assert.IsTrue(item.Email.RightsManagementLicense.ExportAllowed, "The ExportAllowed element in expected rights-managed e-mail message should be true.");
            #endregion

            #region The client logs on User2's account, calls ItemOperations command which contains the Fetch element without RemoveRightsManagementProtection element.
            Request.ItemOperationsFetch fetch = new Request.ItemOperationsFetch
            {
                CollectionId = this.UserTwoInformation.InboxCollectionId,
                Store        = SearchName.Mailbox.ToString(),
                ServerId     = item.ServerId,
                Options      = new Request.ItemOperationsFetchOptions
                {
                    Items            = new object[] { true },
                    ItemsElementName = new Request.ItemsChoiceType5[] { Request.ItemsChoiceType5.RightsManagementSupport }
                }
            };
            ItemOperationsRequest itemOperationsRequest = Common.CreateItemOperationsRequest(new object[] { fetch });
            ItemOperationsStore   itemOperationsStore   = this.ASRMAdapter.ItemOperations(itemOperationsRequest);
            Site.Assert.AreEqual <int>(1, itemOperationsStore.Items.Count, "There should be only 1 item fetched in ItemOperations command response.");
            ItemOperations itemOperations = itemOperationsStore.Items[0];
            Site.Assert.IsNotNull(itemOperations, "The returned item should not be null.");
            Site.Assert.IsNotNull(itemOperations.Email, "The expected rights-managed e-mail message should not be null.");
            Site.Assert.IsNull(itemOperations.Email.Attachments, "The Attachments element in expected rights-managed e-mail message should be null.");
            Site.Assert.IsNotNull(itemOperations.Email.RightsManagementLicense, "The RightsManagementLicense element in expected rights-managed e-mail message should not be null.");
            #endregion

            #region The client logs on User2's account, calls ItemOperations command which contains the Fetch element with RemoveRightsManagementProtection element.
            fetch.RemoveRightsManagementProtection = string.Empty;
            itemOperationsRequest = Common.CreateItemOperationsRequest(new object[] { fetch });
            itemOperationsStore   = this.ASRMAdapter.ItemOperations(itemOperationsRequest);
            Site.Assert.AreEqual <int>(1, itemOperationsStore.Items.Count, "There should be only 1 item fetched in ItemOperations command response.");
            itemOperations = itemOperationsStore.Items[0];
            Site.Assert.IsNotNull(itemOperations, "The returned item should not be null.");
            Site.Assert.IsNotNull(itemOperations.Email, "The expected rights-managed e-mail message should not be null.");
            Site.Assert.IsNull(itemOperations.Email.Attachments, "The Attachments element in expected rights-managed e-mail message should be null.");

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

            // Verify MS-ASRM requirement: MS-ASRM_R91
            // If the response contains RightsManagementLicense element as null, represents the rights management protection is removed from the e-mail.
            Site.CaptureRequirementIfIsNull(
                itemOperations.Email.RightsManagementLicense,
                91,
                @"[In RemoveRightsManagementProtection] If present, it[RemoveRightsManagementProtection] indicates that the client is removing the IRM protection from the e-mail.");

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

            // Verify MS-ASRM requirement: MS-ASRM_R94
            // If the response contains RightsManagementLicense element as null, represents the rights management protection is removed from the e-mail.
            Site.CaptureRequirementIfIsNull(
                itemOperations.Email.RightsManagementLicense,
                94,
                @"[In RemoveRightsManagementProtection] IRM protection can only be removed from e-mail messages when the ExportAllowed element is set to TRUE.");
            #endregion
        }
        public void MSASNOTE_S03_TC01_ItemOperations_GetZeroOrMoreNotes()
        {
            #region Call method Sync to add two notes to the server
            Dictionary <Request.ItemsChoiceType8, object> addElements = this.CreateNoteElements();
            this.SyncAdd(addElements, 2);
            #endregion

            #region Call method Sync to synchronize the note item with the server.
            SyncStore result = this.SyncChanges(1);

            #endregion

            #region Call method ItemOperations to fetch all the information about notes using ServerIds
            // serverIds:the server ids of two note items.
            List <string> serverIds = new List <string> {
                result.AddElements[0].ServerId, result.AddElements[1].ServerId
            };
            ItemOperationsRequest itemOperationRequest = TestSuiteHelper.CreateItemOperationsFetchRequest(this.UserInformation.NotesCollectionId, serverIds, null, null, null);
            ItemOperationsStore   itemOperationsResult = this.NOTEAdapter.ItemOperations(itemOperationRequest);

            Site.Assert.AreEqual <int>(
                2,
                itemOperationsResult.Items.Count,
                @"Two results should be returned in ItemOperations response.");

            Site.Assert.IsNotNull(
                itemOperationsResult.Items[0].Note,
                @"The first note class in ItemOperations response should not be null.");

            Site.Assert.IsNotNull(
                itemOperationsResult.Items[1].Note,
                @"The second note class in ItemOperations response should not be null.");

            #endregion

            #region Call method ItemOperations to fetch all the information about notes using a non-existing ServerIds
            serverIds.Clear();
            serverIds.Add(this.UserInformation.NotesCollectionId + ":notExisting");
            itemOperationRequest = TestSuiteHelper.CreateItemOperationsFetchRequest(this.UserInformation.NotesCollectionId, serverIds, null, null, null);
            itemOperationsResult = this.NOTEAdapter.ItemOperations(itemOperationRequest);

            Site.Assert.IsNull(
                itemOperationsResult.Items[0].Note,
                @"zero Notes class XML blocks is returned in its response");

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

            // Verify MS-ASNOTE requirement: MS-ASNOTE_R208
            // Server can return zero or more Notes class blocks which can be seen from two steps above.
            Site.CaptureRequirement(
                208,
                @"[In Abstract Data Model] The server returns a Notes class XML block for every note that matches the criteria specified by the client command request.");

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

            // Verify MS-ASNOTE requirement: MS-ASNOTE_R128
            // Server can return zero or more Notes class blocks which can be seen from two steps above.
            Site.CaptureRequirement(
                128,
                @"[In Abstract Data Model] The server can return zero or more Notes class XML blocks in its response, depending on how many notes match the criteria specified by the client command request.");

            #endregion
        }