Microsoft.Protocols.TestSuites.MS_ASAIRS.TestSuiteBase.GetItemOperationsResult C# (CSharp) Method

GetItemOperationsResult() protected method

Fetch item with specified ServerID on the server.
protected GetItemOperationsResult ( string collectionId, string serverId, string fileReference, Request bodyPreferences, Request bodyPartPreferences, DeliveryMethodForFetch deliveryMethod ) : ItemOperations
collectionId string The collection id.
serverId string The server id of the mail.
fileReference string The file reference of the attachment.
bodyPreferences Microsoft.Protocols.TestSuites.Common.Request The bodyPreference in the options element.
bodyPartPreferences Microsoft.Protocols.TestSuites.Common.Request The bodyPartPreference in the options element.
deliveryMethod DeliveryMethodForFetch Indicate whether use multipart or inline method to send the request.
return Microsoft.Protocols.TestSuites.Common.DataStructures.ItemOperations
        protected DataStructures.ItemOperations GetItemOperationsResult(string collectionId, string serverId, string fileReference, Request.BodyPreference[] bodyPreferences, Request.BodyPartPreference[] bodyPartPreferences, DeliveryMethodForFetch? deliveryMethod)
        {
            DataStructures.ItemOperations item = null;
            ItemOperationsRequest request = TestSuiteHelper.CreateItemOperationsRequest(collectionId, serverId, fileReference, bodyPreferences, bodyPartPreferences);

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

            do
            {
                Thread.Sleep(waitTime);
                DataStructures.ItemOperationsStore itemOperationsStore = this.ASAIRSAdapter.ItemOperations(request, deliveryMethod ?? DeliveryMethodForFetch.Inline);

                // Since the item serverId or attachment fileReference is unique, there should be only one item in response
                this.Site.Assert.AreEqual<int>(
                    1,
                    itemOperationsStore.Items.Count,
                    "The count of Items in ItemOperations command response should be 1.");

                if (itemOperationsStore.Items[0].Email != null)
                {
                    item = itemOperationsStore.Items[0];
                }
            }
            while (item == null && counter < retryCount);

            this.Site.Assert.IsNotNull(item, "The item should be found, retry count: {0}.", counter);

            return item;
        }