/// <summary>
        /// This method is used to verify requirements related to ItemOperations command.
        /// </summary>
        /// <param name="itemOperationsResponse">The ItemOperations command response returned from the server.</param>
        private void VerifyItemOperationsCommandResponse(ItemOperationsResponse itemOperationsResponse)
        {
            // If the schema validation is successful, then following requirements can be captured.
            Site.Assert.IsTrue(this.activeSyncClient.ValidationResult, "Schema validation should be successful.");

            if (itemOperationsResponse.ResponseData.Response.Move != null && itemOperationsResponse.ResponseData.Response.Move.Length != 0)
            {
                foreach (Response.ItemOperationsResponseMove move in itemOperationsResponse.ResponseData.Response.Move)
                {
                    bool isVerifiedR126 = move.ConversationId != null && move.Status != null;

                    // Add the debug information
                    Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCON_R126");
                    Site.Log.Add(LogEntryKind.Debug, "The ConversationId element is: {0}.", move.ConversationId);
                    Site.Log.Add(LogEntryKind.Debug, "The Status element is: {0}.", move.Status);

                    // Verify MS-ASCON requirement: MS-ASCON_R126
                    // The ConversationId element and Status element are not null, so this requirement can be captured.
                    Site.CaptureRequirementIfIsTrue(
                        isVerifiedR126,
                        126,
                        @"[In Move] It [itemoperations:Move element ] has the following child elements:
itemoperations:ConversationId (section 2.2.2.3.1)
itemoperations:Status (section 2.2.2.10).");

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

                    // Verify MS-ASCON requirement: MS-ASCON_R69
                    // The ConversationId element is not null, so this requirement can be captured.
                    Site.CaptureRequirementIfIsNotNull(
                        move.ConversationId,
                        69,
                        @"[In ConversationId (ItemOperations)] In an ItemOperations command response, the itemoperations:ConversationId is a required child element of the itemoperations:Move element that specifies the conversation ID of the conversation that was moved.");

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

                    // Verify MS-ASCON requirement: MS-ASCON_R70
                    // The ConversationId element is not null and schema has been validated, so this requirement can be captured.
                    Site.CaptureRequirementIfIsNotNull(
                        move.ConversationId,
                        70,
                        @"[In ConversationId (ItemOperations)] The value of this element [itemoperations:ConversationId] is a byte array, as specified in [MS-ASDTYPE] section 2.6.1.");

                    this.VerifyStringDataType();

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

                    // Verify MS-ASCON requirement: MS-ASCON_R139
                    // The Status element is not null, so this requirement can be captured.
                    Site.CaptureRequirementIfIsNotNull(
                        move.Status,
                        139,
                        @"[In Status] The itemoperations:Status element ([MS-ASCMD] section 2.2.3.162.7) is a required child element of the itemoperations:Move element ([MS-ASCMD] section 2.2.3.107.1) in the ItemOperations command response ([MS-ASCMD] section 2.2.2.8) that specifies the status of the move operation.");

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

                    // Verify MS-ASCON requirement: MS-ASCON_R142
                    // The Status element is not null and schema has been validated, so this requirement can be captured.
                    Site.CaptureRequirementIfIsNotNull(
                        move.Status,
                        142,
                        @"[In Status] The value of this [itemoperations:Status] element is an integer, as specified in [MS-ASDTYPE] section 2.5.");

                    this.VerifyIntegerDataType();
                }
            }
        }
Example #2
0
        /// <summary>
        /// Convert the ItemOperationsResponse to ItemOperationsStore
        /// </summary>
        /// <param name="itemOperations">The returned ItemOperations response.</param>
        /// <returns>An ItemOperationsStore instance</returns>
        public static DataStructures.ItemOperationsStore LoadItemOperationsResponse(ItemOperationsResponse itemOperations)
        {
            DataStructures.ItemOperationsStore store = new DataStructures.ItemOperationsStore
            {
                Status = itemOperations.ResponseData.Status
            };

            if (itemOperations.ResponseData.Response != null && itemOperations.ResponseData.Response.Fetch != null)
            {
                foreach (Response.ItemOperationsResponseFetch item in itemOperations.ResponseData.Response.Fetch)
                {
                    DataStructures.ItemOperations fetchItem = new DataStructures.ItemOperations
                    {
                        Status = item.Status,
                        Class = item.Class,
                        ServerId = item.ServerId,
                        CollectionId = item.CollectionId
                    };

                    if (item.Properties != null)
                    {
                        fetchItem.Calendar = DataStructures.Calendar.DeserializeFromFetchProperties<DataStructures.Calendar>(item.Properties);
                        fetchItem.Email = DataStructures.Email.DeserializeFromFetchProperties<DataStructures.Email>(item.Properties);
                        fetchItem.Note = DataStructures.Note.DeserializeFromFetchProperties<DataStructures.Note>(item.Properties);
                        fetchItem.Contact = DataStructures.Contact.DeserializeFromFetchProperties<DataStructures.Contact>(item.Properties);
                        fetchItem.Task = DataStructures.Task.DeserializeFromFetchProperties<DataStructures.Task>(item.Properties);
                    }

                    store.Items.Add(fetchItem);
                }
            }

            return store;
        }
        /// <summary>
        /// Verify the ItemOperations operation.
        /// </summary>
        /// <param name="response">The response of the ItemOperations command.</param>
        private void VerifyItemOperations(ItemOperationsResponse response)
        {
            Site.Assert.IsTrue(this.activeSyncClient.ValidationResult, "Schema should be verified successfully.");

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

            // Verify MS-ASDOC requirement: MS-ASDOC_R101
            Site.CaptureRequirementIfIsNotNull(
                 response.ResponseData,
                101,
                @"[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 individual documents, as specified in section 3.1.5.1, the server responds with an ItemOperations command response.");

            foreach (Microsoft.Protocols.TestSuites.Common.Response.ItemOperationsResponseFetch fetch in response.ResponseData.Response.Fetch)
            {
                string statusString = fetch.Status;
                if (statusString == "1")
                {
                    // Add the debug information
                    Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASDOC_R121");

                    // Verify MS-ASDOC requirement: MS-ASDOC_R121  
                    Site.CaptureRequirementIfIsNotNull(
                        fetch.LinkId,
                        121,
                        @"[In LinkId] It[LinkId] is a required child element of the itemoperations:Fetch element ([MS-ASCMD] section 2.2.3.63.1) for Document class items in an ItemOperations command response ([MS-ASCMD] section 2.2.2.8).");

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

                    // Verify MS-ASDOC requirement: MS-ASDOC_R104
                    // LinkId is the only Document class element that defined in ItemOperation,if schema is verified this requirement can be captured.
                    Site.CaptureRequirementIfIsNotNull(
                        fetch.LinkId,
                        104,
                        @"[In ItemOperations Command Response] The LinkId element (section 2.2.2.8) is the only Document class element returned in an ItemOperations command response.");

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

                    // Verify MS-ASDOC requirement: MS-ASDOC_R105
                    Site.CaptureRequirementIfIsNotNull(
                        fetch.LinkId,
                        105,
                        @"[In ItemOperations Command Response] The LinkId element is transmitted as a child element of the Itemoperations:Fetch element ([MS-ASCMD] section 2.2.3.63.1).");
                }
            }
        }
 /// <summary>
 /// Get the only Fetch element in ItemOperations response.
 /// </summary>
 /// <param name="itemOperationsResponse">The response of ItemOperations method</param>
 /// <returns>The first Fetch element</returns>
 private Response.ItemOperationsResponseFetch GetFetchElement(ItemOperationsResponse itemOperationsResponse)
 {
     Site.Assert.IsNotNull(itemOperationsResponse.ResponseData.Response, "The Response element of the ItemOperations response should not be null.");
     Site.Assert.AreEqual<string>("1", itemOperationsResponse.ResponseData.Status, @"The Status element of the ItemOperations response should be 1.");
     Site.Assert.IsNotNull(itemOperationsResponse.ResponseData.Response.Fetch, "The Fetch element of the ItemOperations response should not be null.");
     Site.Assert.AreEqual<int>(1, itemOperationsResponse.ResponseData.Response.Fetch.Length, "The length of Fetch element array should be 1.");
     Site.Assert.IsNotNull(itemOperationsResponse.ResponseData.Response.Fetch[0], "The first Fetch element of the ItemOperations response should not be null.");
     return itemOperationsResponse.ResponseData.Response.Fetch[0];
 }
        /// <summary>
        /// Get the Data element in ItemOperations response.
        /// </summary>
        /// <param name="itemOperationsResponse">The response of ItemOperations method</param>
        /// <returns>The Data element</returns>
        private string GetDataElement(ItemOperationsResponse itemOperationsResponse)
        {
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R5886");

            Site.Assert.IsTrue(this.User1Information.UserPassword.Length <= 256, "The expected length of password should be not larger than 256, the actual length is: {0}", this.User1Information.UserPassword.Length);

            // Verify MS-ASCMD requirement: MS-ASCMD_R5886
            // The value of Status element equals 1 represent the server accepts password and returns a successful response.
            Site.CaptureRequirementIfAreEqual<string>(
                "1",
                itemOperationsResponse.ResponseData.Status,
                5886,
                @"[In Password(ItemOperations)] The server accepts password values is not larger than 256 characters in length.");

            Response.ItemOperationsResponseFetch fetch = this.GetFetchElement(itemOperationsResponse);
            Site.Assert.IsNotNull(fetch.Properties, "The Properties element of the ItemOperations response should not be null.");
            string data = null;

            for (int i = 0; i < fetch.Properties.ItemsElementName.Length; i++)
            {
                if (fetch.Properties.ItemsElementName[i] == Response.ItemsChoiceType3.Data)
                {
                    data = fetch.Properties.Items[i].ToString();
                    break;
                }
            }

            return data;
        }
        /// <summary>
        /// Get the Body element in ItemOperations response.
        /// </summary>
        /// <param name="itemOperationsResponse">The response of ItemOperations method</param>
        /// <returns>The Body element</returns>
        private Response.Body GetBodyElement(ItemOperationsResponse itemOperationsResponse)
        {
            Response.ItemOperationsResponseFetch fetch = this.GetFetchElement(itemOperationsResponse);
            Site.Assert.IsNotNull(fetch.Properties, "The Properties element of the ItemOperations response should not be null.");
            Response.Body body = null;
            foreach (object tempObject in itemOperationsResponse.ResponseData.Response.Fetch[0].Properties.Items)
            {
                if (typeof(Response.Body).Equals(tempObject.GetType()))
                {
                    body = (Response.Body)tempObject;
                    break;
                }
            }

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R3363
            // If server response contains Body element, then MS-ASCMD_R3363 is verified.
            Site.CaptureRequirementIfIsNotNull(
                body,
                3363,
                @"[In MIMESupport(ItemOperations)] The server's response MUST include the airsyncbase:Body element ([MS-ASAIRS] section 2.2.2.4), which is a child element of the Properties element (section 2.2.3.128.1).");

            return body;
        }