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

MSASCAL_S01_TC20_IsLeapMonth() private method

private MSASCAL_S01_TC20_IsLeapMonth ( ) : void
return void
        public void MSASCAL_S01_TC20_IsLeapMonth()
        {
            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.

            Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The IsLeapMonth element is not supported when the MS-ASProtocolVersion header is set to 12.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

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

            string subjectWithIsLeapMonth0 = Common.GenerateResourceName(Site, "subjectWithIsLeapMonth0");
            string subjectWithCalendarTypeWithoutIsLeapMonth = Common.GenerateResourceName(Site, "subjectWithCalendarTypeWithoutIsLeapMonth");
            string subjectWithCalendarTypeAndIsLeapMonth = Common.GenerateResourceName(Site, "subjectWithCalendarTypeAndIsLeapMonth");

            #endregion

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

            int occurrences = 5;
            int interval = 1;

            // Set Calendar Recurrence element including IsLeapMonth sub-element
            byte recurrenceType = byte.Parse("5");
            Request.Recurrence recurrence = this.CreateCalendarRecurrence(recurrenceType, occurrences, interval);

            // IsLeapMonth is set to 0, the recurrence of the appointment doesn't takes place on the embolismic (leap) month
            recurrence.IsLeapMonth = 0;
            recurrence.IsLeapMonthSpecified = true;

            calendarItem.Add(Request.ItemsChoiceType8.Recurrence, recurrence);
            calendarItem.Add(Request.ItemsChoiceType8.Subject, subjectWithIsLeapMonth0);

            this.AddSyncCalendar(calendarItem);
            SyncItem calendarWithIsLeapMonth0 = this.GetChangeItem(this.User1Information.CalendarCollectionId, subjectWithIsLeapMonth0);

            Site.Assert.IsNotNull(calendarWithIsLeapMonth0.Calendar, "The calendar with subject {0} should exist in server.", subjectWithIsLeapMonth0);
            this.RecordCaseRelativeItems(this.User1Information.UserName, this.User1Information.CalendarCollectionId, subjectWithIsLeapMonth0);
            #endregion

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

            // Verify MS-ASCAL requirement: MS-ASCAL_R608
            Site.CaptureRequirementIfAreEqual<byte>(
                (byte)0,
                calendarWithIsLeapMonth0.Calendar.Recurrence.IsLeapMonth,
                608,
                @"[In IsLeapMonth] [The value] 0 [means] False.");

            #region Call Sync command to add a calendar with the element Recurrence without IsLeapMonth but including the CalendarType element to the server, and sync calendars from the server.

            calendarItem.Clear();

            // Set Calendar Recurrence element without IsLeapMonth sub-element
            recurrenceType = byte.Parse("5");
            recurrence = this.CreateCalendarRecurrence(recurrenceType, occurrences, interval);

            // CalendarType is set to 15, Chinese Lunar calendar system is used by the recurrence
            recurrence.CalendarTypeSpecified = true;
            recurrence.CalendarType = 15;

            calendarItem.Add(Request.ItemsChoiceType8.Recurrence, recurrence);
            calendarItem.Add(Request.ItemsChoiceType8.Subject, subjectWithCalendarTypeWithoutIsLeapMonth);

            this.AddSyncCalendar(calendarItem);
            SyncItem calendarWithCalendarTypeWithoutIsLeapMonth = this.GetChangeItem(this.User1Information.CalendarCollectionId, subjectWithCalendarTypeWithoutIsLeapMonth);

            Site.Assert.IsNotNull(calendarWithCalendarTypeWithoutIsLeapMonth.Calendar, "The calendar with subject {0} should exist in server.", subjectWithCalendarTypeWithoutIsLeapMonth);
            this.RecordCaseRelativeItems(this.User1Information.UserName, this.User1Information.CalendarCollectionId, subjectWithCalendarTypeWithoutIsLeapMonth);
            #endregion

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

            // Verify MS-ASCAL requirement: MS-ASCAL_R28411
            // If Sync response can get a non-null IsLeapMonth, then we can capture this requirement
            Site.CaptureRequirementIfIsNotNull(
                calendarWithCalendarTypeWithoutIsLeapMonth.Calendar.Recurrence.IsLeapMonth,
                28411,
                @"[In IsLeapMonth] The IsLeapMonth element<11> specifies whether the recurrence of the appointment takes place on the embolismic (leap) month.");

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

            // Verify MS-ASCAL requirement: MS-ASCAL_R288
            // If Sync response can get a non-null IsLeapMonth, then we can capture this requirement
            Site.CaptureRequirementIfIsNotNull(
                calendarWithCalendarTypeWithoutIsLeapMonth.Calendar.Recurrence.IsLeapMonth,
                288,
                @"[In IsLeapMonth] This element only applies when the CalendarType element (section 2.2.2.9) specifies a calendar system that incorporates an embolismic (leap) month.");

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

            // Verify MS-ASCAL requirement: MS-ASCAL_R293
            Site.CaptureRequirementIfAreEqual<byte>(
                (byte)0,
                calendarWithCalendarTypeWithoutIsLeapMonth.Calendar.Recurrence.IsLeapMonth,
                293,
                @"[In IsLeapMonth] The default value of the IsLeapMonth element is 0 (FALSE).");

            #region Call Sync command to add a calendar with the element Recurrence including IsLeapMonth sub-element setting as '1' and CalendarType sub-element setting as "Gregorian" to the server, and sync calendars from the server.

            calendarItem.Clear();

            // Set Calendar Recurrence element without IsLeapMonth sub-element
            recurrenceType = byte.Parse("5");
            recurrence = this.CreateCalendarRecurrence(recurrenceType, occurrences, interval);
            recurrence.MonthOfYear = byte.Parse("6");

            // CalendarType set to "Gregorian"
            recurrence.CalendarTypeSpecified = true;
            recurrence.CalendarType = 1;

            // IsLeapMonth is set to 1, the recurrence of the appointment takes place on the embolismic (leap) month
            recurrence.IsLeapMonth = 1;
            recurrence.IsLeapMonthSpecified = true;

            calendarItem.Add(Request.ItemsChoiceType8.Recurrence, recurrence);
            calendarItem.Add(Request.ItemsChoiceType8.Subject, subjectWithCalendarTypeAndIsLeapMonth);
            calendarItem.Add(Request.ItemsChoiceType8.StartTime, new DateTime(2017, 1, 1, 1, 0, 0).ToString("yyyyMMddTHHmmssZ"));
            calendarItem.Add(Request.ItemsChoiceType8.EndTime, new DateTime(2017, 1, 1, 2, 0, 0).ToString("yyyyMMddTHHmmssZ"));

            this.AddSyncCalendar(calendarItem);
            SyncItem calendarWithCalendarTypeAndIsLeapMonth = this.GetChangeItem(this.User1Information.CalendarCollectionId, subjectWithCalendarTypeAndIsLeapMonth);

            Site.Assert.IsNotNull(calendarWithCalendarTypeAndIsLeapMonth.Calendar, "The calendar with subject {0} should exist in server.", subjectWithCalendarTypeAndIsLeapMonth);
            this.RecordCaseRelativeItems(this.User1Information.UserName, this.User1Information.CalendarCollectionId, subjectWithCalendarTypeAndIsLeapMonth);
            #endregion

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

            // Verify MS-ASCAL requirement: MS-ASCAL_R290
            Site.CaptureRequirementIfIsTrue(
                calendarWithCalendarTypeAndIsLeapMonth.Calendar.Recurrence.IsLeapMonthSpecified && calendarWithCalendarTypeAndIsLeapMonth.Calendar.Recurrence.IsLeapMonth != 1,
                290,
                @"[In IsLeapMonth] This element[IsLeapMonth] has no effect when specified in conjunction with the Gregorian calendar.");

            #region Call Sync command to add a calendar with the element Recurrence including IsLeapMonth sub-element setting as '1' and CalendarType sub-element setting as "Chinese Lunar" to the server, and sync calendars from the server.

            calendarItem.Clear();

            // Set Calendar Recurrence element without IsLeapMonth sub-element
            recurrenceType = byte.Parse("5");
            recurrence = this.CreateCalendarRecurrence(recurrenceType, occurrences, interval);
            recurrence.MonthOfYear = byte.Parse("6");

            // CalendarType set to "Chinese Lunar"
            recurrence.CalendarTypeSpecified = true;
            recurrence.CalendarType = 15;

            // IsLeapMonth is set to 1, the recurrence of the appointment takes place on the embolismic (leap) month
            recurrence.IsLeapMonth = 1;
            recurrence.IsLeapMonthSpecified = true;

            calendarItem.Add(Request.ItemsChoiceType8.Recurrence, recurrence);
            calendarItem.Add(Request.ItemsChoiceType8.StartTime, new DateTime(2017, 1, 1, 1, 0, 0).ToString("yyyyMMddTHHmmssZ"));
            calendarItem.Add(Request.ItemsChoiceType8.EndTime, new DateTime(2017, 1, 1, 2, 0, 0).ToString("yyyyMMddTHHmmssZ"));

            this.AddSyncCalendar(calendarItem);
            SyncItem calendar = this.GetChangeItem(this.User1Information.CalendarCollectionId, this.SubjectName);

            Site.Assert.IsNotNull(calendar.Calendar, "The calendar with subject {0} should exist in server.", this.SubjectName);
            this.RecordCaseRelativeItems(this.User1Information.UserName, this.User1Information.CalendarCollectionId, this.SubjectName);
            #endregion

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

            // Verify MS-ASCAL requirement: MS-ASCAL_R609
            Site.CaptureRequirementIfIsTrue(
                calendar.Calendar.Recurrence.IsLeapMonthSpecified && calendar.Calendar.Recurrence.IsLeapMonth == 1,
                609,
                @"[In IsLeapMonth] [The value] 1 [means]True.");
        }