Example #1
0
        public void MSASCNTC_S02_TC03_ItemOperations_SchemaViewFetch()
        {
            #region Call Sync command with Add element to add a contact to the server
            Dictionary <Request.ItemsChoiceType8, object> contactProperties = this.SetContactProperties(null);
            this.AddContact(this.User1Information.ContactsCollectionId, contactProperties);

            this.RecordCaseRelativeItems(this.User1Information.UserName, this.User1Information.ContactsCollectionId, contactProperties[Request.ItemsChoiceType8.FileAs].ToString());

            // Get the new added contact
            Sync newAddedItem = this.GetSyncAddResult(contactProperties[Request.ItemsChoiceType8.FileAs].ToString(), this.User1Information.ContactsCollectionId, null, null);
            #endregion

            #region Call ItemOperations command with Schema element to retrieve the contact item added in previous step
            // Just including FileAs element in Schema
            Request.Schema schema = new Request.Schema
            {
                Items            = new object[] { string.Empty },
                ItemsElementName = new Request.ItemsChoiceType4[] { Request.ItemsChoiceType4.FileAs }
            };

            this.GetItemOperationsResult(this.User1Information.ContactsCollectionId, newAddedItem.ServerId, null, schema);
            #endregion

            #region Verify requirement
            // If only FilsAs element is returned in server response, then capture MS-ASCNTC_R485.
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCNTC_R485.");

            // Verify MS-ASCNTC requirement: MS-ASCNTC_R485
            Site.CaptureRequirementIfIsTrue(
                TestSuiteHelper.IsOnlySpecifiedElementExist((XmlElement)this.ASCNTCAdapter.LastRawResponseXml, "Properties", "FileAs"),
                485,
                @"[In ItemOperations Command Response] If an ItemOperations:Schema element ([MS-ASCMD] section 2.2.3.145) is included in the ItemOperations command request, 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>
        /// Builds a ItemOperations request to fetch the whole content of the notes
        /// </summary>
        /// <param name="collectionId">Specifies the notes folder</param>
        /// <param name="serverIds">Specifies a unique identifier that is assigned by the server for the notes</param>
        /// <param name="longIds">Specifies a unique identifier that is assigned by the server to each result returned by a previous Search response.</param>
        /// <param name="bodyPreference">Sets preference information related to the type and size of the body.</param>
        /// <param name="schema">Specifies the schema of the item to be fetched.</param>
        /// <returns>Returns the ItemOperationsRequest instance</returns>
        internal static ItemOperationsRequest CreateItemOperationsFetchRequest(
            string collectionId,
            List <string> serverIds,
            List <string> longIds,
            Request.BodyPreference bodyPreference,
            Request.Schema schema)
        {
            Request.ItemOperationsFetchOptions fetchOptions = new Request.ItemOperationsFetchOptions();
            List <object> fetchOptionItems = new List <object>();
            List <Request.ItemsChoiceType5> fetchOptionItemsName = new List <Request.ItemsChoiceType5>();

            if (null != bodyPreference)
            {
                fetchOptionItemsName.Add(Request.ItemsChoiceType5.BodyPreference);
                fetchOptionItems.Add(bodyPreference);
            }

            if (null != schema)
            {
                fetchOptionItemsName.Add(Request.ItemsChoiceType5.Schema);
                fetchOptionItems.Add(schema);
            }

            fetchOptions.Items            = fetchOptionItems.ToArray();
            fetchOptions.ItemsElementName = fetchOptionItemsName.ToArray();

            List <Request.ItemOperationsFetch> fetchElements = new List <Request.ItemOperationsFetch>();

            if (serverIds != null)
            {
                foreach (string serverId in serverIds)
                {
                    Request.ItemOperationsFetch fetchElement = new Request.ItemOperationsFetch()
                    {
                        CollectionId = collectionId,
                        ServerId     = serverId,
                        Store        = SearchName.Mailbox.ToString(),
                        Options      = fetchOptions
                    };
                    fetchElements.Add(fetchElement);
                }
            }

            if (longIds != null)
            {
                foreach (string longId in longIds)
                {
                    Request.ItemOperationsFetch fetchElement = new Request.ItemOperationsFetch()
                    {
                        LongId  = longId,
                        Store   = SearchName.Mailbox.ToString(),
                        Options = fetchOptions
                    };
                    fetchElements.Add(fetchElement);
                }
            }

            return(Common.CreateItemOperationsRequest(fetchElements.ToArray()));
        }
        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>
        /// Builds a ItemOperations request to fetch the whole content of a single mail item
        /// by using the specified collectionId, emailServerId,bodyPreference and bodyPartPreference
        /// In general, returns the XML formatted ItemOperations request as follows:
        /// <!--
        /// <?xml version="1.0" encoding="utf-8"?>
        /// <ItemOperations xmlns="ItemOperations" xmlns:airsync="AirSync" xmlns:airsyncbase="AirSyncBase">
        ///    <Fetch>
        ///       <Store>Mailbox</Store>
        ///       <airsync:CollectionId>5</airsync:CollectionId>
        ///       <airsync:ServerId>5:1</airsync:ServerId>
        ///       <Options>
        ///          <airsync:MIMESupport>2</airsync:MIMESupport>
        ///          <airsyncbase:BodyPreference>
        ///             <airsyncbase:Type>4</airsyncbase:Type>
        ///          </airsyncbase:BodyPreference>
        ///          <airsyncbase:BodyPreference>
        ///             <airsyncbase:Type>2</airsyncbase:Type>
        ///          </airsyncbase:BodyPreference>
        ///       </Options>
        ///    </Fetch>
        /// </ItemOperations>
        /// -->
        /// </summary>
        /// <param name="collectionId">Specify the folder of mailItem, which can be returned by ActiveSync FolderSync command(Refer to [MS-ASCMD]2.2.3.30.2)</param>
        /// <param name="serverIds">Specify a unique identifier that was assigned by the server for a mailItem, which can be returned by ActiveSync Sync command(Refer to [MS-ASCMD]2.2.3.151.5)</param>
        /// <param name="schema">Sets the schema information</param>
        /// <returns>Returns the ItemOperationsRequest instance</returns>
        internal static ItemOperationsRequest CreateItemOperationsFetchRequest(string collectionId, List <string> serverIds, Request.Schema schema)
        {
            Request.ItemOperations itemOperations = new Request.ItemOperations();
            List <object>          items          = new List <object>();

            Request.ItemOperationsFetch fetchElement = new Request.ItemOperationsFetch();

            if (serverIds != null)
            {
                foreach (string item in serverIds)
                {
                    fetchElement.CollectionId = collectionId;
                    fetchElement.ServerId     = item;
                    items.Add(fetchElement);
                }
            }

            itemOperations.Items = items.ToArray();

            foreach (object item in itemOperations.Items)
            {
                Request.ItemOperationsFetch fetch = item as Request.ItemOperationsFetch;
                if (fetch != null)
                {
                    fetch.Store = SearchName.Mailbox.ToString();
                    Request.ItemOperationsFetchOptions fetchOptions = new Request.ItemOperationsFetchOptions();

                    List <object> fetchOptionItems = new List <object>();
                    List <Request.ItemsChoiceType5> fetchOptionItemsName = new List <Request.ItemsChoiceType5>
                    {
                        Request.ItemsChoiceType5.BodyPreference,
                        Request.ItemsChoiceType5.Schema
                    };

                    fetchOptionItems.Add(
                        new Request.BodyPreference()
                    {
                        AllOrNone               = false,
                        AllOrNoneSpecified      = false,
                        TruncationSize          = 0,
                        TruncationSizeSpecified = false,
                        Preview          = 0,
                        PreviewSpecified = false,
                        Type             = 2,
                    });
                    fetchOptionItems.Add(schema);

                    fetchOptions.Items            = fetchOptionItems.ToArray();
                    fetchOptions.ItemsElementName = fetchOptionItemsName.ToArray();
                    fetch.Options = fetchOptions;
                }
            }

            return(Common.CreateItemOperationsRequest(itemOperations.Items));
        }
        public void MSASCNTC_S02_TC03_ItemOperations_SchemaViewFetch()
        {
            #region Call Sync command with Add element to add a contact to the server
            Dictionary<Request.ItemsChoiceType8, object> contactProperties = this.SetContactProperties(null);
            this.AddContact(this.User1Information.ContactsCollectionId, contactProperties);

            this.RecordCaseRelativeItems(this.User1Information.UserName, this.User1Information.ContactsCollectionId, contactProperties[Request.ItemsChoiceType8.FileAs].ToString());

            // Get the new added contact
            Sync newAddedItem = this.GetSyncAddResult(contactProperties[Request.ItemsChoiceType8.FileAs].ToString(), this.User1Information.ContactsCollectionId, null, null);
            #endregion

            #region Call ItemOperations command with Schema element to retrieve the contact item added in previous step
            // Just including FileAs element in Schema
            Request.Schema schema = new Request.Schema
            {
                Items = new object[] { string.Empty },
                ItemsElementName = new Request.ItemsChoiceType4[] { Request.ItemsChoiceType4.FileAs }
            };

            this.GetItemOperationsResult(this.User1Information.ContactsCollectionId, newAddedItem.ServerId, null, schema);
            #endregion

            #region Verify requirement
            // If only FilsAs element is returned in server response, then capture MS-ASCNTC_R485.
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCNTC_R485.");

            // Verify MS-ASCNTC requirement: MS-ASCNTC_R485
            Site.CaptureRequirementIfIsTrue(
                TestSuiteHelper.IsOnlySpecifiedElementExist((XmlElement)this.ASCNTCAdapter.LastRawResponseXml, "Properties", "FileAs"),
                485,
                @"[In ItemOperations Command Response] If an ItemOperations:Schema element ([MS-ASCMD] section 2.2.3.145) is included in the ItemOperations command request, 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
        }
        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
        }
Example #7
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.");
        }
        /// <summary>
        /// Create an ItemOperations command request.
        /// </summary>
        /// <param name="collectionId">The collection id.</param>
        /// <param name="serverId">The serverId of the item.</param>
        /// <param name="bodyPreference">The bodyPreference in the options element.</param>
        /// <param name="schema">Sets the schema information.</param>
        /// <returns>An ItemOperations command request.</returns>
        internal static ItemOperationsRequest CreateItemOperationsRequest(string collectionId, string serverId, Request.BodyPreference bodyPreference, Request.Schema schema)
        {
            ItemOperationsRequest request = new ItemOperationsRequest {
                RequestData = new Request.ItemOperations()
            };

            Request.ItemOperationsFetch fetch = new Request.ItemOperationsFetch
            {
                Store        = SearchName.Mailbox.ToString(),
                CollectionId = collectionId,
                ServerId     = serverId
            };

            List <object> items = new List <object>();
            List <Request.ItemsChoiceType5> itemsElementName = new List <Request.ItemsChoiceType5>();

            if (null != schema)
            {
                itemsElementName.Add(Request.ItemsChoiceType5.Schema);
                items.Add(schema);
            }

            if (null != bodyPreference)
            {
                itemsElementName.Add(Request.ItemsChoiceType5.BodyPreference);
                items.Add(bodyPreference);

                if (bodyPreference.Type == 0x4)
                {
                    itemsElementName.Add(Request.ItemsChoiceType5.MIMESupport);

                    // '2' indicates server sends MIME data for all messages but not S/MIME messages only
                    items.Add((byte)0x2);
                }
            }

            if (items.Count > 0)
            {
                fetch.Options = new Request.ItemOperationsFetchOptions()
                {
                    ItemsElementName = itemsElementName.ToArray(),
                    Items            = items.ToArray()
                };
            }

            request.RequestData.Items = new object[] { fetch };

            return(request);
        }
        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 MSASCAL_S01_TC29_ItemOperations()
        {
            #region Call Sync command to add a calendar to the server.

            Dictionary<Request.ItemsChoiceType8, object> calendarItem = new Dictionary<Request.ItemsChoiceType8, object>();

            string subject = Common.GenerateResourceName(Site, "subject");
            calendarItem.Add(Request.ItemsChoiceType8.Subject, subject);

            // Add a default calendar
            this.AddSyncCalendar(calendarItem);

            SyncItem calendar = this.GetChangeItem(this.User1Information.CalendarCollectionId, subject);

            Site.Assert.IsNotNull(calendar.Calendar, "The calendar with subject {0} should exist in server.", subject);

            this.RecordCaseRelativeItems(this.User1Information.UserName, this.User1Information.CalendarCollectionId, subject);

            #endregion

            #region Call method ItemOperations to fetch all the information about calendars using ServerIds and get the expected success response.

            // To verify MS-ASCAL_R530, just include subject element in schema.
            Request.Schema schema = new Request.Schema();
            List<object> elements = new List<object> { string.Empty };

            List<Request.ItemsChoiceType4> names = new List<Request.ItemsChoiceType4>
            {
                Request.ItemsChoiceType4.Subject
            };

            schema.Items = elements.ToArray();
            schema.ItemsElementName = names.ToArray();

            // The server id of Calendar
            List<string> serverIds = new List<string> { calendar.ServerId };
            ItemOperationsRequest itemOperationsRequest = TestSuiteHelper.CreateItemOperationsFetchRequest(this.User1Information.CalendarCollectionId, serverIds, schema);
            ItemOperationsStore fetchResponse = this.CALAdapter.ItemOperations(itemOperationsRequest);

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

            // Verify MS-ASEMAIL requirement: MS-ASCAL_R530
            Site.CaptureRequirementIfIsTrue(
                TestSuiteHelper.IsOnlySpecifiedElement((XmlElement)this.CALAdapter.LastRawResponseXml, "Properties", "Subject"),
                530,
                @"[In ItemOperations Command Response] If an airsync:Schema element ([MS-ASCMD] section 2.2.3.145) is included in the ItemOperations command request, the elements returned in the ItemOperations command response MUST be restricted to the elements that were included as child elements of the airsync:Schema element in the command request.");

            // Verify ItemOperations response
            Site.Assert.AreEqual<string>(
                "1",
                fetchResponse.Status,
                "If the ItemOperations command executes successfully, the Status in response should be 1.");

            #endregion

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

            // Verify MS-ASCAL requirement: MS-ASCAL_R525
            // If ItemOperations response can get a non-null ItemOperationsStore.CalendarItems, it means the client had fetched the calendar,
            // then we can capture this requirement
            Site.CaptureRequirementIfIsNotNull(
                fetchResponse.Items,
                525,
                @"[In Retrieving Details for One or More Calendar Items] The server responds with an ItemOperations command response ([MS-ASCMD] section 2.2.2.8).");

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

            // Verify MS-ASCAL requirement: MS-ASCAL_R528
            // If ItemOperations response can get a non-null ItemOperationsStore.CalendarItems, it means the client had fetched the calendar,
            // then we can capture this requirement
            Site.CaptureRequirementIfIsNotNull(
                fetchResponse.Items,
                528,
                @"[In ItemOperations Command Response] When a client uses an ItemOperations command request ([MS-ASCMD] section 2.2.2.8), as specified in section 3.1.5.1, to retrieve data from the server for one or more specific calendar items, the server responds with an ItemOperations command response ([MS-ASCMD] section 2.2.2.8).");
        }
        public void MSASEMAIL_S01_TC19_ItemOperations_OnlyIncludedSubjectInResponse()
        {
            #region Call method SendMail to send an email.
            string emailSubject = Common.GenerateResourceName(Site, "subject");
            this.SendPlaintextEmail(emailSubject, string.Empty, string.Empty);
            #endregion

            #region Call ItemOperations command without including BodyPreference element to fetch all the information about the e-mail
            SyncStore syncChangeResult = this.GetSyncResult(emailSubject, this.User2Information.InboxCollectionId, null);
            Sync item = TestSuiteHelper.GetSyncAddItem(syncChangeResult, emailSubject);

            // Just including subject element in schema
            Request.Schema schema = new Request.Schema();
            List<object> elements = new List<object> { string.Empty };

            List<Request.ItemsChoiceType4> names = new List<Request.ItemsChoiceType4>
            {
                Request.ItemsChoiceType4.Subject1
            };

            schema.Items = elements.ToArray();
            schema.ItemsElementName = names.ToArray();

            ItemOperationsRequest itemOperationRequest = TestSuiteHelper.CreateItemOperationsFetchRequest(this.User2Information.InboxCollectionId, item.ServerId, null, null, schema);
            ItemOperationsStore itemOperationResult = this.EMAILAdapter.ItemOperations(itemOperationRequest);
            ItemOperations itemOperationsItem = TestSuiteHelper.GetItemOperationsItem(itemOperationResult, emailSubject);
            Site.Assert.IsNotNull(itemOperationsItem, "The email item with subject '{0}' should be found in the {1} folder of user {2}.", emailSubject, FolderType.Inbox.ToString(), this.User2Information.UserName);
            #endregion

            #region Verify requirements
            // If the server responds with an ItemOperations response, then MS-ASEMAIL_R61 can be captured.
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASEMAIL_R61");

            // Verify MS-ASEMAIL requirement: MS-ASEMAIL_R61
            Site.CaptureRequirementIfAreEqual<string>(
                "1",
                itemOperationResult.Status,
                61,
                @"[In ItemOperations Command Response] When a client uses an ItemOperations command request ([MS-ASCMD] section 2.2.2.9), as specified in section 3.1.5.1, to retrieve data from the server for one or more specific e-mail items, the server responds with an ItemOperations command response.");

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

            // Verify MS-ASEMAIL requirement: MS-ASEMAIL_R63
            Site.CaptureRequirementIfIsTrue(
                TestSuiteHelper.IsOnlySpecifiedElement((XmlElement)this.EMAILAdapter.LastRawResponseXml, "Properties", "Subject"),
                63,
                @"[In ItemOperations Command Response] If an airsync:Schema element ([MS-ASCMD] section 2.2.3.149) 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 airsync:Schema element in the command request.");
            #endregion
        }