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

MSASCAL_S01_TC10_Categories() private method

private MSASCAL_S01_TC10_Categories ( ) : void
return void
        public void MSASCAL_S01_TC10_Categories()
        {
            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 Call Sync command to add a calendar with the element Categories and one sub-element Category to the server, and sync calendars from the server.

            Dictionary<Request.ItemsChoiceType8, object> calendarItem = new Dictionary<Request.ItemsChoiceType8, object>();
            string subjectWithCategoriesLessThan300 = Common.GenerateResourceName(Site, "subjectWithCategoriesLessThan300");
            calendarItem.Add(Request.ItemsChoiceType8.Subject, subjectWithCategoriesLessThan300);

            // Set Calendar StartTime, EndTime elements
            calendarItem.Add(Request.ItemsChoiceType8.StartTime, this.StartTime.ToString("yyyyMMddTHHmmssZ"));
            calendarItem.Add(Request.ItemsChoiceType8.EndTime, this.EndTime.ToString("yyyyMMddTHHmmssZ"));

            // Set Categories element specifies a category that is assigned to the calendar item
            calendarItem.Add(Request.ItemsChoiceType8.Categories, TestSuiteHelper.CreateCalendarCategories(new string[] { this.Category }));

            // Set Categories element specifies a category that is assigned to the exception item
            calendarItem.Add(Request.ItemsChoiceType8.Recurrence, this.CreateCalendarRecurrence(0, 6, 1));

            string categoryNameInException = this.Category + "InException";

            Request.Exceptions exceptions = new Request.Exceptions { Exception = new Request.ExceptionsException[] { } };
            List<Request.ExceptionsException> exceptionList = new List<Request.ExceptionsException>();

            Request.ExceptionsException exceptionWithCategoriesLessThan300 = TestSuiteHelper.CreateExceptionRequired(this.StartTime.AddDays(2).ToString("yyyyMMddTHHmmssZ"));
            exceptionWithCategoriesLessThan300.Categories = TestSuiteHelper.CreateCalendarCategories(new string[] { categoryNameInException }).Category;

            exceptionList.Add(exceptionWithCategoriesLessThan300);
            exceptions.Exception = exceptionList.ToArray();
            calendarItem.Add(Request.ItemsChoiceType8.Exceptions, exceptions);

            this.AddSyncCalendar(calendarItem);

            SyncItem calendarWithCategoriesLessThan300 = this.GetChangeItem(this.User1Information.CalendarCollectionId, subjectWithCategoriesLessThan300);

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

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

            #endregion

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

            // Verify MS-ASCAL requirement: MS-ASCAL_R2083
            // If the DtStamp element is not specified as a child element of an Exception element, the value of the DtStamp element is assumed to be the
            // same as the value of the top-level DtStamp element. So this requirement can be covered if DtStamp for the calendar item is returned.
            Site.CaptureRequirementIfIsNotNull(
                calendarWithCategoriesLessThan300.Calendar.DtStamp.Value,
                2083,
                @"[In DtStamp] As a top-level element of the Calendar class, the DtStamp element specifies [the date and time that the calendar item was created or modified or] the date and time at which the exception item was created or modified..");

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

            // Verify MS-ASCAL requirement: MS-ASCAL_R17711
            Site.CaptureRequirementIfAreEqual<string>(
                this.Category,
                calendarWithCategoriesLessThan300.Calendar.Categories.Category[0],
                17711,
                @"[In Categories] The Categories element specifies a collection of categories assigned to the calendar item.");

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

            // Verify MS-ASCAL requirement: MS-ASCAL_R17911
            Site.CaptureRequirementIfAreEqual<string>(
                categoryNameInException,
                calendarWithCategoriesLessThan300.Calendar.Exceptions.Exception[0].Categories[0],
                17911,
                @"[In Categories] As a child element of the Exception element (section 2.2.2.19), the Categories element specifies the categories for the exception item.");

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

            // Verify MS-ASCAL requirement: MS-ASCAL_R18011
            Site.CaptureRequirementIfAreEqual<string>(
                categoryNameInException,
                calendarWithCategoriesLessThan300.Calendar.Exceptions.Exception[0].Categories[0],
                18011,
                @"[In Categories] A command response has a maximum of one Categories child element per Exception element.");

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

            // Verify MS-ASCAL requirement: MS-ASCAL_R18311
            Site.CaptureRequirementIfAreEqual<string>(
                this.Category,
                calendarWithCategoriesLessThan300.Calendar.Categories.Category[0],
                18311,
                @"[In Category] The Category element specifies a category that is assigned to the calendar item.");

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

            // Verify MS-ASCAL requirement: MS-ASCAL_R18312
            Site.CaptureRequirementIfAreEqual<string>(
                categoryNameInException,
                calendarWithCategoriesLessThan300.Calendar.Exceptions.Exception[0].Categories[0],
                18312,
                @"[In Category] The Category element specifies a category that is assigned to the exception item.");

            if (Common.IsRequirementEnabled(11026, this.Site))
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCAL_R11026");

                // Verify MS-ASCAL requirement: MS-ASCAL_R11026
                Site.CaptureRequirementIfIsTrue(
                    calendarWithCategoriesLessThan300.Calendar.Exceptions.Exception[0].Categories.Length >= 0 && calendarWithCategoriesLessThan300.Calendar.Categories.Category.Length <= 300,
                    11026,
                    @"[In Appendix B: Product Behavior] Implementation command response includes no more than 300 Category child elements per Categories element. (Exchange 2007 SP1 and above follow this behavior.)");
            }

            #region Call Sync command to add a calendar with the element Categories and more than 300 sub-element Category to the server, and sync calendars from the server.

            calendarItem.Clear();

            // Set more than 300 sub-element Category
            List<string> categoryList = new List<string>();
            for (int i = 0; i <= 301; i++)
            {
                categoryList.Add(this.Category);
            }

            // Set Calendar StartTime, EndTime elements
            calendarItem.Add(Request.ItemsChoiceType8.StartTime, this.StartTime.ToString("yyyyMMddTHHmmssZ"));
            calendarItem.Add(Request.ItemsChoiceType8.EndTime, this.EndTime.ToString("yyyyMMddTHHmmssZ"));

            // Set Categories element specifies a category that is assigned to the calendar item
            calendarItem.Add(Request.ItemsChoiceType8.Categories, TestSuiteHelper.CreateCalendarCategories(categoryList.ToArray()));

            // Set Categories element specifies a category that is assigned to the exception item
            calendarItem.Add(Request.ItemsChoiceType8.Recurrence, this.CreateCalendarRecurrence(0, 6, 1));

            exceptions = new Request.Exceptions { Exception = new Request.ExceptionsException[] { } };
            exceptionList = new List<Request.ExceptionsException>();

            Request.ExceptionsException exceptionWithCategoriesMoreThan300 = TestSuiteHelper.CreateExceptionRequired(this.StartTime.AddDays(2).ToString("yyyyMMddTHHmmssZ"));
            exceptionWithCategoriesMoreThan300.Categories = TestSuiteHelper.CreateCalendarCategories(categoryList.ToArray()).Category;

            exceptionList.Add(exceptionWithCategoriesMoreThan300);
            exceptions.Exception = exceptionList.ToArray();
            calendarItem.Add(Request.ItemsChoiceType8.Exceptions, exceptions);

            SyncStore addCalendarResponse = this.AddSyncCalendar(calendarItem);

            Site.Assert.IsFalse(addCalendarResponse.AddResponses[0].Status.Equals(1), "Command request can not includes more than 300 Category child elements per Categories element.");

            #endregion
        }