/// <summary>
        /// Create a Request.ExceptionsException instance with ExceptionStartTime elements.
        /// </summary>
        /// <param name="exceptionStartTime">Specifies the start time of the original recurring meeting</param>
        /// <returns>The created Request.ExceptionsException instance.</returns>
        internal static Request.ExceptionsException CreateExceptionRequired(string exceptionStartTime)
        {
            Request.ExceptionsException exception = new Request.ExceptionsException
            {
                ExceptionStartTime = exceptionStartTime
            };

            return(exception);
        }
        /// <summary>
        /// Create a Request.ExceptionsException instance with ExceptionStartTime elements.
        /// </summary>
        /// <param name="exceptionStartTime">Specifies the start time of the original recurring meeting</param>
        /// <returns>The created Request.ExceptionsException instance.</returns>
        internal static Request.ExceptionsException CreateExceptionRequired(string exceptionStartTime)
        {
            Request.ExceptionsException exception = new Request.ExceptionsException
            {
                ExceptionStartTime = exceptionStartTime
            };

            return exception;
        }
示例#3
0
        public void MSASCMD_S19_TC51_Sync_Change_Exceptions()
        {
            Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Class element is not supported in a Sync command response when the MS-ASProtocolVersion header is set to 12.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");
            Site.Assume.AreNotEqual<string>("16.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "Recurrences cannot be added in protocol version 16.0");

            this.Sync(TestSuiteBase.CreateEmptySyncRequest(this.User1Information.CalendarCollectionId));

            #region Call Sync Add operation to add a new recurrence calendar.
            string recurrenceCalendarSubject = Common.GenerateResourceName(Site, "calendarSubject");
            string location = Common.GenerateResourceName(Site, "Room");
            DateTime currentDate = DateTime.Now.AddDays(1);
            DateTime startTime = new DateTime(currentDate.Year, currentDate.Month, currentDate.Day, 10, 0, 0);
            DateTime endTime = startTime.AddHours(10);

            Request.ExceptionsException exception = new Request.ExceptionsException();
            exception.ExceptionStartTime = startTime.AddDays(2).ToString("yyyyMMddTHHmmssZ");
            Request.Exceptions exceptions = new Request.Exceptions() { Exception = new Request.ExceptionsException[] { exception } };

            Request.Recurrence recurrence = new Request.Recurrence
            {
                Type = 0
            };

            Request.SyncCollectionAdd recurrenceCalendarData = new Request.SyncCollectionAdd
            {
                ClientId = TestSuiteBase.ClientId,
                ApplicationData =
                    new Request.SyncCollectionAddApplicationData
                    {
                        ItemsElementName =
                            new Request.ItemsChoiceType8[] 
                            { 
                                Request.ItemsChoiceType8.Subject, Request.ItemsChoiceType8.Location,
                                Request.ItemsChoiceType8.StartTime, Request.ItemsChoiceType8.EndTime,
                                Request.ItemsChoiceType8.Recurrence, Request.ItemsChoiceType8.Exceptions,
                                Request.ItemsChoiceType8.UID
                            },
                        Items =
                        new object[] 
                        { 
                            recurrenceCalendarSubject, location, 
                            startTime.ToString("yyyyMMddTHHmmssZ"),
                            endTime.ToString("yyyyMMddTHHmmssZ"),
                            recurrence, exceptions, Guid.NewGuid().ToString()
                        }
                    },
                Class = "Calendar"
            };

            SyncRequest syncRequest = TestSuiteBase.CreateSyncAddRequest(this.LastSyncKey, this.User1Information.CalendarCollectionId, recurrenceCalendarData);
            SyncResponse syncResponse = this.Sync(syncRequest);
            Site.Assert.IsNotNull(syncResponse.ResponseData.Item, "The items returned in the Sync command response should not be null.");
            Response.SyncCollectionsCollectionResponses responses = TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Responses) as Response.SyncCollectionsCollectionResponses;
            Site.Assert.AreEqual<int>(1, int.Parse(responses.Add[0].Status), "The calendar should be added successfully.");
            TestSuiteBase.RecordCaseRelativeItems(this.User1Information, this.User1Information.CalendarCollectionId, recurrenceCalendarSubject);

            syncResponse = this.SyncChanges(this.User1Information.CalendarCollectionId);
            string serverId = TestSuiteBase.FindServerId(syncResponse, "Subject", recurrenceCalendarSubject);
            Site.Assert.IsNotNull(serverId, "The recurrence calendar should be found.");
            #endregion

            #region Change the subject of the added recurrence calendar.
            string updatedCalendarSubject = Common.GenerateResourceName(Site, "updatedCalendarSubject");

            Request.SyncCollectionChangeApplicationData changeCalednarData = new Request.SyncCollectionChangeApplicationData();
            changeCalednarData.ItemsElementName = new Request.ItemsChoiceType7[] { Request.ItemsChoiceType7.Subject, Request.ItemsChoiceType7.Recurrence };
            changeCalednarData.Items = new object[] { updatedCalendarSubject, recurrence };

            Request.SyncCollectionChange appDataChange = new Request.SyncCollectionChange
            {
                ApplicationData = changeCalednarData,
                ServerId = serverId
            };

            syncRequest = CreateSyncChangeRequest(this.LastSyncKey, this.User1Information.CalendarCollectionId, appDataChange);
            syncResponse = this.Sync(syncRequest);
            Site.Assert.AreEqual<uint>(1, Convert.ToUInt32(TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Status)), "The FileAs of the contact should be updated successfully.");
            TestSuiteBase.RemoveRecordCaseRelativeItems(this.User1Information, this.User1Information.CalendarCollectionId, recurrenceCalendarSubject);
            TestSuiteBase.RecordCaseRelativeItems(this.User1Information, this.User1Information.CalendarCollectionId, updatedCalendarSubject);

            syncResponse = this.SyncChanges(this.User1Information.CalendarCollectionId);
            serverId = TestSuiteBase.FindServerId(syncResponse, "Subject", updatedCalendarSubject);
            Site.Assert.IsNotNull(serverId, "The recurrence calendar should be found.");

            Response.SyncCollectionsCollectionCommands commands = TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Commands) as Response.SyncCollectionsCollectionCommands;
            Site.Assert.IsNotNull(commands.Add, "The Add element should not be null.");

            foreach (Response.SyncCollectionsCollectionCommandsAdd item in commands.Add)
            {
                if (item.ServerId == serverId)
                {
                    for (int i = 0; i < item.ApplicationData.ItemsElementName.Length; i++)
                    {
                        if (item.ApplicationData.ItemsElementName[i] == Response.ItemsChoiceType8.Exceptions)
                        {
                            Response.Exceptions currentExceptions = item.ApplicationData.Items[i] as Response.Exceptions;
                            Site.Assert.IsNotNull(currentExceptions, "The Exceptions element should exist.");

                            Response.ExceptionsException currentException = currentExceptions.Exception[0];

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

                            // Verify MS-ASCMD requirement: MS-ASCMD_R877
                            Site.CaptureRequirementIfAreEqual<string>(
                                exception.ExceptionStartTime.ToString(),
                                currentException.ExceptionStartTime.ToString(),
                                877,
                                @"[In Change] If a calendar:Exception ([MS-ASCAL] section 2.2.2.19) node within the calendar:Exceptions node is not present, that particular exception will remain unchanged.");

                            break;
                        }
                    }

                    break;
                }
            }
            #endregion

            #region Change the subject of the added recurrence calendar again.
            string allNewCalendarSubject = Common.GenerateResourceName(Site, "updatedCalendarSubject");

            changeCalednarData.ItemsElementName = new Request.ItemsChoiceType7[] { Request.ItemsChoiceType7.Subject, Request.ItemsChoiceType7.Recurrence, Request.ItemsChoiceType7.Exceptions, Request.ItemsChoiceType7.UID };
            changeCalednarData.Items = new object[] { allNewCalendarSubject, recurrence, null, Guid.NewGuid().ToString() };

            appDataChange = new Request.SyncCollectionChange
            {
                ApplicationData = changeCalednarData,
                ServerId = serverId
            };

            syncRequest = CreateSyncChangeRequest(this.LastSyncKey, this.User1Information.CalendarCollectionId, appDataChange);
            syncResponse = this.Sync(syncRequest);
            Site.Assert.AreEqual<uint>(1, Convert.ToUInt32(TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Status)), "The FileAs of the contact should be updated successfully.");
            TestSuiteBase.RemoveRecordCaseRelativeItems(this.User1Information, this.User1Information.CalendarCollectionId, updatedCalendarSubject);
            TestSuiteBase.RecordCaseRelativeItems(this.User1Information, this.User1Information.CalendarCollectionId, allNewCalendarSubject);

            syncResponse = this.SyncChanges(this.User1Information.CalendarCollectionId);
            serverId = TestSuiteBase.FindServerId(syncResponse, "Subject", allNewCalendarSubject);
            Site.Assert.IsNotNull(serverId, "The recurrence calendar should be found.");

            commands = TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Commands) as Response.SyncCollectionsCollectionCommands;
            Site.Assert.IsNotNull(commands.Add, "The Add element should not be null.");

            foreach (Response.SyncCollectionsCollectionCommandsAdd item in commands.Add)
            {
                if (item.ServerId == serverId)
                {
                    for (int i = 0; i < item.ApplicationData.ItemsElementName.Length; i++)
                    {
                        if (item.ApplicationData.ItemsElementName[i] == Response.ItemsChoiceType8.Exceptions)
                        {
                            Response.Exceptions currentExceptions = item.ApplicationData.Items[i] as Response.Exceptions;
                            Site.Assert.IsNotNull(currentExceptions, "The Exceptions element should exist.");

                            Response.ExceptionsException currentException = currentExceptions.Exception[0];

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

                            // Verify MS-ASCMD requirement: MS-ASCMD_R876
                            Site.CaptureRequirementIfAreEqual<string>(
                                exception.ExceptionStartTime.ToString(),
                                currentException.ExceptionStartTime.ToString(),
                                876,
                                @"[In Change] [Certain in-schema properties remain untouched in the following three cases:] If a calendar:Exceptions ([MS-ASCAL] section 2.2.2.20) node is not specified, the properties for that calendar:Exceptions node will remain unchanged.");

                            break;
                        }
                    }

                    break;
                }
            }
            #endregion
        }