Wrapper class of ItemOperations response
Exemple #1
0
        /// <summary>
        /// Fetch item with specified ServerID on the server.
        /// </summary>
        /// <param name="collectionId">The collection id.</param>
        /// <param name="serverId">The server id of the mail.</param>
        /// <param name="fileReference">The file reference of the attachment.</param>
        /// <param name="bodyPreferences">The bodyPreference in the options element.</param>
        /// <param name="bodyPartPreferences">The bodyPartPreference in the options element.</param>
        /// <param name="deliveryMethod">Indicate whether use multipart or inline method to send the request.</param>
        /// <returns>The item with specified ServerID.</returns>
        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);
        }
        public void MSASAIRS_S03_TC02_NormalAttachment()
        {
            #region Send a mail with normal attachment
            string subject = Common.GenerateResourceName(Site, "Subject");
            string body    = Common.GenerateResourceName(Site, "Body");
            this.SendEmail(EmailType.NormalAttachment, subject, body);
            #endregion

            #region Verify requirements
            DataStructures.Sync syncItem = this.GetSyncResult(subject, this.User2Information.InboxCollectionId, null, null, null);
            this.VerifyMethodElementValue(syncItem.Email, 1);

            DataStructures.ItemOperations itemOperationsItem = this.GetItemOperationsResult(this.User2Information.InboxCollectionId, syncItem.ServerId, null, null, null, null);
            this.VerifyMethodElementValue(itemOperationsItem.Email, 1);

            if (Common.IsRequirementEnabled(53, this.Site))
            {
                DataStructures.Search searchItem = this.GetSearchResult(subject, this.User2Information.InboxCollectionId, null, null, null);
                this.VerifyMethodElementValue(searchItem.Email, 1);
            }

            // According to above steps, requirement MS-ASAIRS_R225 can be captured directly
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASAIRS_R225");

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R225
            Site.CaptureRequirement(
                225,
                @"[In Method (Attachment)] [The value] 1 [of the Method element] meaning ""Normal attachment"" specifies that the attachment is a normal attachment.");

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R160
            Site.CaptureRequirementIfIsNotNull(
                ((Response.AttachmentsAttachment)syncItem.Email.Attachments.Items[0]).ContentId,
                160,
                @"[In ContentId (Attachment)] The ContentId element is an optional child element of the Attachment element (section 2.2.2.7) that contains the unique object ID for an attachment.");

            this.Site.CaptureRequirementIfIsNotNull(
                ((Response.AttachmentsAttachment)syncItem.Email.Attachments.Items[0]).ContentId,
                1343,
                @"[In ContentId (Attachment)] [The ContentId element is an optional child element of the Attachment element (section 2.2.2.7) that contains the unique identifier of the attachment, and] is used to reference the attachment within the item to which the attachment belongs.");

            #endregion
        }
        public void MSASAIRS_S03_TC04_OLEAttachment()
        {
            #region Send a mail with an embedded OLE object
            string subject = Common.GenerateResourceName(Site, "Subject");
            string body    = Common.GenerateResourceName(Site, "Body");
            this.SendEmail(EmailType.AttachOLE, subject, body);
            #endregion

            #region Verify requirements
            DataStructures.Sync syncItem = this.GetSyncResult(subject, this.User2Information.InboxCollectionId, null, null, null);
            this.VerifyMethodElementValue(syncItem.Email, 6);

            DataStructures.ItemOperations itemOperationsItem = this.GetItemOperationsResult(this.User2Information.InboxCollectionId, syncItem.ServerId, null, null, null, null);
            this.VerifyMethodElementValue(itemOperationsItem.Email, 6);

            if (Common.IsRequirementEnabled(53, this.Site))
            {
                DataStructures.Search searchItem = this.GetSearchResult(subject, this.User2Information.InboxCollectionId, itemOperationsItem.Email.ConversationId, null, null);
                this.VerifyMethodElementValue(searchItem.Email, 6);
            }

            // According to above steps, requirement MS-ASAIRS_R230 can be captured directly
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASAIRS_R230");

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R230
            Site.CaptureRequirement(
                230,
                @"[In Method (Attachment)] [The value] 6 [of the Method element] meaning ""Attach OLE"" indicates that the attachment is an embedded Object Linking and Embedding (OLE) object, such as an inline image.");

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R100299
            Site.CaptureRequirementIfIsTrue(
                ((Response.AttachmentsAttachment)syncItem.Email.Attachments.Items[0]).IsInline,
                100299,
                @"[In IsInline (Attachment)] If the value[IsInline] is TRUE, then the attachment is embedded in the message.");
            #endregion
        }
        public void MSASAIRS_S03_TC03_EmbeddedMessageAttachment()
        {
            #region Send a mail with an e-mail messsage attachment
            string subject = Common.GenerateResourceName(Site, "Subject");
            string body    = Common.GenerateResourceName(Site, "Body");
            this.SendEmail(EmailType.EmbeddedAttachment, subject, body);
            #endregion

            #region Verify requirements
            DataStructures.Sync syncItem = this.GetSyncResult(subject, this.User2Information.InboxCollectionId, null, null, null);
            this.VerifyMethodElementValue(syncItem.Email, 5);

            DataStructures.ItemOperations itemOperationsItem = this.GetItemOperationsResult(this.User2Information.InboxCollectionId, syncItem.ServerId, null, null, null, null);
            this.VerifyMethodElementValue(itemOperationsItem.Email, 5);

            if (Common.IsRequirementEnabled(53, this.Site))
            {
                DataStructures.Search searchItem = this.GetSearchResult(subject, this.User2Information.InboxCollectionId, itemOperationsItem.Email.ConversationId, null, null);
                this.VerifyMethodElementValue(searchItem.Email, 5);
            }

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R2299
            Site.CaptureRequirementIfIsTrue(
                ((Response.AttachmentsAttachment)syncItem.Email.Attachments.Items[0]).DisplayName.EndsWith(".eml", System.StringComparison.CurrentCultureIgnoreCase),
                2299,
                @"[In Method (Attachment)] [The value] 5 [of the Method element] meaning ""Embedded message"" indicates that the attachment is an e-mail message, and that the attachment file has an .eml extension.");

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R100298
            Site.CaptureRequirementIfIsFalse(
                ((Response.AttachmentsAttachment)syncItem.Email.Attachments.Items[0]).IsInlineSpecified,
                100298,
                @"[In IsInline (Attachment)] If the value[IsInline] is FALSE, then the attachment is not embedded in the message.");
            #endregion
        }
        /// <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;
        }
        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
            }
        }