Microsoft.Protocols.TestSuites.MS_ASCAL.S01_CalendarElement.MSASCAL_S01_TC12_RecurrenceWithType1 C# (CSharp) Method

MSASCAL_S01_TC12_RecurrenceWithType1() private method

private MSASCAL_S01_TC12_RecurrenceWithType1 ( ) : void
return void
        public void MSASCAL_S01_TC12_RecurrenceWithType1()
        {
            Site.Assume.AreNotEqual<string>("16.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The recurring calendar item cannot be created when protocol version is set to 16.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region Generate calendar subject and record them.

            byte recurrenceType = byte.Parse("1");

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

            string subjectWithType1AndOccurrences = Common.GenerateResourceName(Site, "subjectWithType1AndOccurrences");
            string subjectWithType1AndUntil = Common.GenerateResourceName(Site, "subjectWithType1AndUntil");
            string subjectWithType1Only = Common.GenerateResourceName(Site, "subjectWithType1Only");

            #endregion

            #region Call Sync command to add a calendar with the element Recurrence including Type '1' and Occurrences sub-element to the server, and sync calendars from the server.

            // Add Calendar Recurrence element including Occurrences sub-element
            int occurrences = 4;
            int interval = 2;
            calendarItem.Add(Request.ItemsChoiceType8.Recurrence, this.CreateCalendarRecurrence(recurrenceType, occurrences, interval));
            calendarItem.Add(Request.ItemsChoiceType8.Subject, subjectWithType1AndOccurrences);

            this.AddSyncCalendar(calendarItem);
            SyncItem calendarWithType1AndOccurrences = this.GetChangeItem(this.User1Information.CalendarCollectionId, subjectWithType1AndOccurrences);

            Site.Assert.IsNotNull(calendarWithType1AndOccurrences.Calendar, "The calendar with subject {0} should exist in server.", subjectWithType1AndOccurrences);
            this.RecordCaseRelativeItems(this.User1Information.UserName, this.User1Information.CalendarCollectionId, subjectWithType1AndOccurrences);
            calendars.Add(calendarWithType1AndOccurrences);

            #endregion

            #region Call Sync command to add a calendar with the element Recurrence including Type '1' and Until sub-element to the server, and sync calendars from the server.

            calendarItem.Clear();

            // Set Calendar Recurrence element including Until sub-element
            string untilTime = this.FutureTime.AddDays(14).ToString("yyyyMMddTHHmmssZ");
            Request.Recurrence recurrence = this.CreateCalendarRecurrence(recurrenceType, 0, interval);
            recurrence.Until = untilTime;
            calendarItem.Add(Request.ItemsChoiceType8.Recurrence, recurrence);
            calendarItem.Add(Request.ItemsChoiceType8.Subject, subjectWithType1AndUntil);

            this.AddSyncCalendar(calendarItem);
            SyncItem calendarWithType1AndUntil = this.GetChangeItem(this.User1Information.CalendarCollectionId, subjectWithType1AndUntil);

            Site.Assert.IsNotNull(calendarWithType1AndUntil.Calendar, "The calendar with subject {0} should exist in server.", subjectWithType1AndUntil);
            this.RecordCaseRelativeItems(this.User1Information.UserName, this.User1Information.CalendarCollectionId, subjectWithType1AndUntil);
            calendars.Add(calendarWithType1AndUntil);

            #endregion

            #region Call Sync command to add a calendar with the element Recurrence only including Type '1' to the server, and sync calendars from the server.

            calendarItem.Clear();

            // Set Calendar Recurrence element without Occurrences and Until sub-element
            recurrence = this.CreateCalendarRecurrence(recurrenceType, occurrences, interval);
            recurrence.OccurrencesSpecified = false;
            recurrence.Until = null;
            calendarItem.Add(Request.ItemsChoiceType8.Recurrence, recurrence);

            calendarItem.Add(Request.ItemsChoiceType8.Subject, subjectWithType1Only);

            this.AddSyncCalendar(calendarItem);
            SyncItem calendarWithType1Only = this.GetChangeItem(this.User1Information.CalendarCollectionId, subjectWithType1Only);

            Site.Assert.IsNotNull(calendarWithType1Only.Calendar, "The calendar with subject {0} should exist in server.", subjectWithType1Only);
            this.RecordCaseRelativeItems(this.User1Information.UserName, this.User1Information.CalendarCollectionId, subjectWithType1Only);
            calendars.Add(calendarWithType1Only);

            #endregion

            foreach (SyncItem response in calendars)
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCAL_R19512");

                // Verify MS-ASCAL requirement: MS-ASCAL_R19512
                Site.CaptureRequirementIfIsFalse(
                    response.Calendar.Recurrence.DayOfMonthSpecified,
                    19512,
                    @"[In DayOfMonth] The DayOfMonth element MUST NOT be included in responses when the Type element value is 1.");

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

                // Verify MS-ASCAL requirement: MS-ASCAL_R32812
                Site.CaptureRequirementIfIsFalse(
                    response.Calendar.Recurrence.MonthOfYearSpecified,
                    32812,
                    @"[In MonthOfYear] The MonthOfYear element MUST NOT be included in responses when the Type element value is 1.");

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

                // Verify MS-ASCAL requirement: MS-ASCAL_R455
                Site.CaptureRequirementIfAreEqual<byte>(
                    recurrenceType,
                    response.Calendar.Recurrence.Type,
                    455,
                    @"[In Type] [The value 1 means]  Recurs weekly.");
            }
        }