public void MSOUTSPS_S02_TC26_OperationListItems_DayOfWeekOrMonthSimpleType()
        {
            string listId = this.AddListToSUT(TemplateType.Events);

            #region  Add 5 recurrence item

            // Setting recurring setting
            DateTime eventDateOfRecurrence = DateTime.Today.Date.AddDays(1);

            // Setting common recurrenceXMLData setting
            RecurrenceXML recurrenceXMLData = new RecurrenceXML();
            recurrenceXMLData.deleteExceptions = null;
            recurrenceXMLData.recurrence = new RecurrenceDefinition();

            // Set the windowEnd value, the recurrence will be end on one week later, and the repeat frequency is daily.
            DateTime winEndDate = eventDateOfRecurrence.Date.AddDays(7);
            recurrenceXMLData.recurrence.rule = new RecurrenceRule();
            recurrenceXMLData.recurrence.rule.Item = winEndDate;

            // Repeat Pattern, set it as weekly repeat.
            recurrenceXMLData.recurrence.rule.repeat = new RepeatPattern();

            // Setting the monthFrequency. every month repeat.
            RepeatPatternDaily repeatPatternDaily = new RepeatPatternDaily();
            repeatPatternDaily.dayFrequency = "1";
            recurrenceXMLData.recurrence.rule.repeat.Item = repeatPatternDaily;

            // Add recurrence items with 10 values of WeekdayOfMonth enum.
            string[] namesOfDayOfWeekOrMonth = Enum.GetNames(typeof(DayOfWeekOrMonth));
            Dictionary<string, string> listItemRecurrenceDataSettings = new Dictionary<string, string>();
            foreach (string enumNameItem in namesOfDayOfWeekOrMonth)
            {
                List<Dictionary<string, string>> addedItemsOfRecurrence = new List<Dictionary<string, string>>();
                List<MethodCmdEnum> cmds = new List<MethodCmdEnum>(1);

                string eventTitle = this.GetUniqueListItemTitle("DayOfWeekOrMonth");
                Dictionary<string, string> settingsOfDailyRecurring = this.GetDailyRecurrenceSettingWithwindowEnd(this.GetUniqueListItemTitle("DailyRecurrenceEvent"), eventDateOfRecurrence, "1", 10);
                this.Site.Assert.IsTrue(
                               settingsOfDailyRecurring.ContainsKey("RecurrenceData"),
                               "The fields setting should contain RecurrenceData field's setting.");

                this.Site.Assert.IsTrue(
                                     settingsOfDailyRecurring.ContainsKey("Title"),
                                     "The fields setting should contain Title field's setting.");

                settingsOfDailyRecurring["Title"] = eventTitle;

                // Update the RecurrenData field with recurrence.rule.firstDayOfWeek setting
                DayOfWeekOrMonth currentDayOfWeekOrMonthValue = (DayOfWeekOrMonth)Enum.Parse(typeof(DayOfWeekOrMonth), enumNameItem, true);
                recurrenceXMLData.recurrence.rule.firstDayOfWeek = currentDayOfWeekOrMonthValue;

                string recurrenceXMLString = this.GetRecurrenceXMLString(recurrenceXMLData);
                settingsOfDailyRecurring["RecurrenceData"] = recurrenceXMLString;

                // Add current list item
                addedItemsOfRecurrence.Add(settingsOfDailyRecurring);
                cmds.Add(MethodCmdEnum.New);

                UpdateListItemsUpdates updatesOfRecurrence = this.CreateUpdateListItems(cmds, addedItemsOfRecurrence, OnErrorEnum.Continue);
                UpdateListItemsResponseUpdateListItemsResult updateResult = OutspsAdapter.UpdateListItems(listId, updatesOfRecurrence);

                // Get the listItem id and the related RecurrenceData
                this.VerifyResponseOfUpdateListItem(updateResult);
                List<string> addedRecurrenceItemIds = this.GetListItemIdsFromUpdateListItemsResponse(updateResult, 1);
                listItemRecurrenceDataSettings.Add(addedRecurrenceItemIds[0], recurrenceXMLString);
            }

            this.Site.Assert.AreEqual<int>(
                                    namesOfDayOfWeekOrMonth.Length,
                                    listItemRecurrenceDataSettings.Count,
                                    "There should be match number of list items' Recurrence data setting");

            #endregion  Add 10 recurrence item

            XmlNode[] zrowItems = this.GetListItemsChangesFromSUT(listId);
            this.Site.Assert.AreEqual<int>(
                                    namesOfDayOfWeekOrMonth.Length,
                                    zrowItems.Count(),
                                    "The current list should contain [{0}] list items.",
                                    namesOfDayOfWeekOrMonth.Length);

            // Verify each WeekdayOfMonth value can be set in protocol SUT successfully.
            foreach (KeyValuePair<string, string> listItemRecurrenceDataItem in listItemRecurrenceDataSettings)
            {
                string currentListItemId = listItemRecurrenceDataItem.Key;
                int zrowIndexOfCurrentListItemId = this.GetZrowItemIndexByListItemId(zrowItems, currentListItemId);
                string actualRecurrenceData = Common.GetZrowAttributeValue(zrowItems, zrowIndexOfCurrentListItemId, "ows_RecurrenceData");
                this.Site.Assert.IsFalse(
                                string.IsNullOrEmpty(actualRecurrenceData),
                                "The actual RecurrenceData field should have value.");

                string expectedRecurrenceData = listItemRecurrenceDataItem.Value.ToLower();
                this.Site.Assert.AreEqual<string>(
                                    expectedRecurrenceData.ToLower(),
                                    actualRecurrenceData.ToLower(),
                                    "The RecurrenceData field value should match the value set in the request of UpdateListItems operation.");
            }

            // If upon verification pass, then capture R1001, R10031, R10032, R10033, R10034, R10035, R10036, R10037, R1004, R1005, R1006
            // Verify MS-OUTSPS requirement: MS-OUTSPS_R1001
            this.Site.CaptureRequirement(
                            1001,
                            @"[In DayOfWeekOrMonth] The DayOfWeekOrMonth simple type specifies a day of the week or a day of the month.");

            // Verify MS-OUTSPS requirement: MS-OUTSPS_R1004
            this.Site.CaptureRequirement(
                            1004,
                            @"[In DayOfWeekOrMonth][The enumeration value]day[of the type DayOfWeekOrMonth means]Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday are allowed.");

            // Verify MS-OUTSPS requirement: MS-OUTSPS_R1005
            this.Site.CaptureRequirement(
                            1005,
                            @"[In DayOfWeekOrMonth][The enumeration value]weekday[of the type DayOfWeekOrMonth means]Monday, Tuesday, Wednesday, Thursday, and Friday are allowed.");

            // Verify MS-OUTSPS requirement: MS-OUTSPS_R1006
            this.Site.CaptureRequirement(
                            1006,
                            @"[In DayOfWeekOrMonth][The enumeration value]weekend_day[of the type DayOfWeekOrMonth means]Sunday and Saturday are allowed.");

            // Verify MS-OUTSPS requirement: MS-OUTSPS_R10031
            this.Site.CaptureRequirement(
                            10031,
                            @"[In DayOfWeekOrMonth][The enumeration value]su[of the type DayOfWeekOrMonth means]Sunday");

            // Verify MS-OUTSPS requirement: MS-OUTSPS_R10032
            this.Site.CaptureRequirement(
                            10032,
                            @"[In DayOfWeekOrMonth][The enumeration value]mo[of the type DayOfWeekOrMonth means]Monday");

            // Verify MS-OUTSPS requirement: MS-OUTSPS_R10033
            this.Site.CaptureRequirement(
                            10033,
                            @"[In DayOfWeekOrMonth][The enumeration value]tu[of the type DayOfWeekOrMonth means]Tuesday");

            // Verify MS-OUTSPS requirement: MS-OUTSPS_R10034
            this.Site.CaptureRequirement(
                            10034,
                            @"[In DayOfWeekOrMonth][The enumeration value]we[of the type DayOfWeekOrMonth means]Wednesday");

            // Verify MS-OUTSPS requirement: MS-OUTSPS_R10035
            this.Site.CaptureRequirement(
                            10035,
                            @"[In DayOfWeekOrMonth][The enumeration value]th[of the type DayOfWeekOrMonth means]Thursday");

            // Verify MS-OUTSPS requirement: MS-OUTSPS_R10036
            this.Site.CaptureRequirement(
                            10036,
                            @"[In DayOfWeekOrMonth][The enumeration value]fr[of the type DayOfWeekOrMonth means]Friday");

            // Verify MS-OUTSPS requirement: MS-OUTSPS_R10037
            this.Site.CaptureRequirement(
                            10037,
                            @"[In DayOfWeekOrMonth][The enumeration value]sa[of the type DayOfWeekOrMonth means]Saturday");
        }
        public void MSOUTSPS_S02_TC01_OperationListItemsForAppointment()
        {
            string listId = this.AddListToSUT(TemplateType.Events);

            Dictionary<string, string> recurEventFieldsSetting = new Dictionary<string, string>();
            DateTime eventDate = DateTime.Today.Date.AddDays(1);
            DateTime endDate = eventDate.AddHours(1);
            string eventDateValue = this.GetGeneralFormatTimeString(eventDate);
            string endDateValue = this.GetGeneralFormatTimeString(endDate);
            string eventTitle = this.GetUniqueListItemTitle("RecurrenceEvent");

            // Recurring data
            RecurrenceXML recurrenceXMLData = new RecurrenceXML();
            recurrenceXMLData.deleteExceptions = null;
            recurrenceXMLData.recurrence = new RecurrenceDefinition();
            recurrenceXMLData.recurrence.rule = new RecurrenceRule();
            recurrenceXMLData.recurrence.rule.firstDayOfWeek = DayOfWeekOrMonth.su;

            // Repeat Pattern
            recurrenceXMLData.recurrence.rule.repeat = new RepeatPattern();
            RepeatPatternDaily repeatPatternDailyData = new RepeatPatternDaily();

            // Setting the dayFrequencyValue
            repeatPatternDailyData.dayFrequency = "1";
            recurrenceXMLData.recurrence.rule.repeat.Item = repeatPatternDailyData;
            recurrenceXMLData.recurrence.rule.Item = "7";
            string recurrenceXmlString = this.GetRecurrenceXMLString(recurrenceXMLData);

            // Setting necessary fields' value
            recurEventFieldsSetting.Add("EventDate", eventDateValue);

            // The ending date and time of the appointment.
            recurEventFieldsSetting.Add("EndDate", endDateValue);

            // If the EventType indicates a recurring event, then fRecurrence MUST be "1". 
            recurEventFieldsSetting.Add("EventType", "1");

            // "0" means this is not an all-day event.
            recurEventFieldsSetting.Add("fAllDayEvent", "0");

            // "1" means this is a recurrence event.
            recurEventFieldsSetting.Add("fRecurrence", "1");

            // If EventType is "1", this property MUST contain a valid RecurrenceXML.
            recurEventFieldsSetting.Add("RecurrenceData", recurrenceXmlString);

            // If EventType is "1", this property MUST contain a valid TimeZoneXML.
            TimeZoneXML customPacificTimeZone = this.GetCustomPacificTimeZoneXmlSetting();
            recurEventFieldsSetting.Add("XMLTZone", this.GetTimeZoneXMLString(customPacificTimeZone));

            // Setting Duration field's value
            recurEventFieldsSetting.Add("Duration", "0");
            recurEventFieldsSetting.Add("Title", eventTitle);

            List<Dictionary<string, string>> addeditemsOfRecurrence = new List<Dictionary<string, string>>();
            addeditemsOfRecurrence.Add(recurEventFieldsSetting);

            List<MethodCmdEnum> cmds = new List<MethodCmdEnum>(1);
            cmds.Add(MethodCmdEnum.New);

            // add a  recurrence appointment item
            UpdateListItemsUpdates updatesOfRecurrence = this.CreateUpdateListItems(cmds, addeditemsOfRecurrence, OnErrorEnum.Continue);
            UpdateListItemsResponseUpdateListItemsResult updateResult = OutspsAdapter.UpdateListItems(listId, updatesOfRecurrence);
            this.VerifyResponseOfUpdateListItem(updateResult);

            XmlNode[] zrowitems = this.GetListItemsChangesFromSUT(listId);
            int listItemIndex = this.GetZrowItemIndexByListItemId(zrowitems, "1");
            string actualEventDateValue = Common.GetZrowAttributeValue(zrowitems, listItemIndex, "ows_EventDate");
            string actualEndDateValue = Common.GetZrowAttributeValue(zrowitems, listItemIndex, "ows_EndDate");
            string actualTimeZone = Common.GetZrowAttributeValue(zrowitems, listItemIndex, "ows_XMLTZone");
            #region Capture code
            
            // Verify MS-OUTSPS requirement: MS-OUTSPS_R879
            this.Site.CaptureRequirementIfAreEqual<string>(
                this.GetTimeZoneXMLString(customPacificTimeZone),
                actualTimeZone,
                879,
                "[In Complex Types][The complex type]TimeZoneRule Contains daylight saving time (DST) biases and TransitionDate elements (section 2.2.4.8).");

            // Verify MS-OUTSPS requirement: MS-OUTSPS_R880
            // TimeZoneXML is included in request, this requirement can be captured directly if the operation executes successfully.
            this.Site.CaptureRequirement(
                880,
                "[In Complex Types][The complex type]TimeZoneXML Contains a TimeZoneRule (section 2.2.4.6).");

            // Verify MS-OUTSPS requirement: MS-OUTSPS_R950
            // TimeZoneXML is included in request, this requirement can be captured directly if the operation executes successfully.
            this.Site.CaptureRequirement(
                950,
                @"[In TimeZoneXML complex type]The TimeZoneXML complex type contains a TimeZoneRule (section 2.2.4.6) to define a time zone.
                <s:complexType name=""TimeZoneXML"">
                  <s:sequence>
                    <s:element name=""timeZoneRule"" type=""tns:TimeZoneRule"" />
                  </s:sequence>
                </s:complexType>");

            // Verify MS-OUTSPS requirement: MS-OUTSPS_R952
            // TimeZoneXML is included in request, this requirement can be captured directly if the operation executes successfully.
            this.Site.CaptureRequirement(
                952,
                @"[In TransitionDate complex type] The TransitionDate complex type contains transition dates for DST.
                <s:complexType name=""TransitionDate"">
                  <s:sequence>
                    <s:element name=""transitionRule"">
                      <s:complexType>
                        <s:simpleContent>
                          <s:extension base=""s:string"">
                            <s:attribute name=""day"" type=""tns:DayOfWeek"" default=""su"" use=""optional"" />
                            <s:attribute name=""month"" type=""s:integer"" use=""required"" />
                            <s:attribute name=""dayOfMonth"" type=""s:integer"" use=""optional"" />
                            <s:attribute name=""weekdayOfMonth"" type=""tns:WeekdayOfMonth"" default=""first"" use=""optional"" />
                          </s:extension>
                        </s:simpleContent>
                      </s:complexType>
                    </s:element>
                    <s:element name=""transitionTime"" type=""s:string"" />
                  </s:sequence>
                </s:complexType>");

            // Verify MS-OUTSPS requirement: MS-OUTSPS_R881
            this.Site.CaptureRequirementIfAreEqual<string>(
                this.GetTimeZoneXMLString(customPacificTimeZone),
                actualTimeZone,
                881,
                "[In Complex Types][The complex type]TransitionDate Contains DST transition dates.");

            // Verify MS-OUTSPS requirement: MS-OUTSPS_R945
            // TimeZoneRule is included in request, this requirement can be captured directly if the operation executes successfully.
            this.Site.CaptureRequirement(
                945,
                @"[In TimeZoneRule complex type] The TimeZoneRule complex type contains DST biases and TransitionDate (section 2.2.4.8) elements.
                <s:complexType name=""TimeZoneRule"">
                  <s:sequence>
                    <s:element name=""standardBias"" type=""s:integer"" />
                    <s:element name=""additionalDaylightBias"" type=""s:integer"" minOccurs=""0"" />
                    <s:element name=""standardDate"" type=""s1:TransitionDate"" minOccurs=""0"" />
                    <s:element name=""daylightDate"" type=""s1:TransitionDate"" minOccurs=""0"" />
                  </s:sequence>
                </s:complexType>");

            // If the EndDate and EventDate fields' values equal to the values the client set in upon steps, then capture R1264
            DateTime actualEndDate;
            if (!DateTime.TryParse(actualEndDateValue, out actualEndDate))
            {
                this.Site.Assert.Fail("The EndDate field value should be a valid DateTime format.");
            }

            DateTime actualEventDate;
            if (!DateTime.TryParse(actualEventDateValue, out actualEventDate))
            {
                this.Site.Assert.Fail("The EventDate field value should be a valid DateTime format.");
            }

            // Verify MS-OUTSPS requirement: MS-OUTSPS_R267
            this.Site.CaptureRequirementIfIsTrue(
                DateTime.Parse(actualEndDateValue) >= DateTime.Parse(actualEventDateValue),
                267,
                "[In Appointment-Specific Schema]EndDate MUST be equal to or later than EventDate.");

            // Verify MS-OUTSPS requirement: MS-OUTSPS_R271
            this.Site.CaptureRequirementIfIsTrue(
                DateTime.Parse(actualEndDateValue) >= DateTime.Parse(actualEventDateValue),
                271,
                "[In Appointment-Specific Schema]EventDate MUST be equal to or earlier than EndDate.");

            // Verify MS-OUTSPS requirement: MS-OUTSPS_R272
            this.Site.CaptureRequirementIfIsFalse(
                string.IsNullOrEmpty(actualEventDateValue),
                272,
                "[In Appointment-Specific Schema]EventDate MUST NOT be empty or missing.");

            // Verify MS-OUTSPS requirement: MS-OUTSPS_R275
            this.Site.CaptureRequirementIfIsFalse(
                string.IsNullOrEmpty(Common.GetZrowAttributeValue(zrowitems, listItemIndex, "ows_EventType")),
                275,
                "[In Appointment-Specific Schema]EventType MUST NOT be empty or missing.");

            // Verify MS-OUTSPS requirement: MS-OUTSPS_R288
            this.Site.CaptureRequirementIfIsFalse(
                string.IsNullOrEmpty(Common.GetZrowAttributeValue(zrowitems, listItemIndex, "ows_fRecurrence")),
                288,
                "[In Appointment-Specific Schema]fRecurrence MUST NOT be empty or missing.");

            #endregion
        }
        public void MSOUTSPS_S02_TC22_RecurrenceAppointmentItem_RepeatPattern()
        {
            string listId = this.AddListToSUT(TemplateType.Events);

            // Setting recurring setting
            DateTime eventDateOfRecurrence = DateTime.Today.Date.AddDays(1);
            Dictionary<string, string> settingsOfDailyRecurring = this.GetDailyRecurrenceSettingWithwindowEnd(this.GetUniqueListItemTitle("DailyRecurrenceEvent"), eventDateOfRecurrence, "1", 10);
            this.Site.Assert.IsTrue(
                            settingsOfDailyRecurring.ContainsKey("RecurrenceData"),
                            "The fields setting collection should contain RecurrenceData field setting.");

            // Setting a daily recurrence setting for RecurrenceData field.
            RecurrenceXML recurrenceXMLData = new RecurrenceXML();
            recurrenceXMLData.deleteExceptions = null;
            recurrenceXMLData.recurrence = new RecurrenceDefinition();
            recurrenceXMLData.recurrence.rule = new RecurrenceRule();
            recurrenceXMLData.recurrence.rule.firstDayOfWeek = DayOfWeekOrMonth.su;

            // Set the windowEnd value, the recurrence will be end on one week from current date.
            DateTime winEndDate = eventDateOfRecurrence.Date.AddDays(7);
            recurrenceXMLData.recurrence.rule.Item = winEndDate;

            // Repeat Pattern
            recurrenceXMLData.recurrence.rule.repeat = new RepeatPattern();

            // Setting the RepeatPatternDaily
            RepeatPatternDaily repeatPatternDailyData = new RepeatPatternDaily();
            repeatPatternDailyData.dayFrequency = "1";
            recurrenceXMLData.recurrence.rule.repeat.Item = repeatPatternDailyData;
            string recurrenceXMLString = this.GetRecurrenceXMLString(recurrenceXMLData);

            // Setting the RecurrenceData field with RepeatPattern.daily
            settingsOfDailyRecurring["RecurrenceData"] = recurrenceXMLString;

            #region add a recurrence item

            List<Dictionary<string, string>> addedItemsOfRecurrence = new List<Dictionary<string, string>>();
            List<MethodCmdEnum> cmds = new List<MethodCmdEnum>(1);

            // Add current list item
            addedItemsOfRecurrence.Add(settingsOfDailyRecurring);
            cmds.Add(MethodCmdEnum.New);

            UpdateListItemsUpdates updatesOfRecurrence = this.CreateUpdateListItems(cmds, addedItemsOfRecurrence, OnErrorEnum.Continue);
            UpdateListItemsResponseUpdateListItemsResult updateResult = OutspsAdapter.UpdateListItems(listId, updatesOfRecurrence);

            // Get the listItem id.
            this.VerifyResponseOfUpdateListItem(updateResult);
            List<string> addedRecurrenceItemIds = this.GetListItemIdsFromUpdateListItemsResponse(updateResult, 1);

            #endregion add a recurrence item

            XmlNode[] zrowItems = this.GetListItemsChangesFromSUT(listId);
            int zrowIndex = this.GetZrowItemIndexByListItemId(zrowItems, addedRecurrenceItemIds[0]);
            string actualRecurrenceXMLStringValue = Common.GetZrowAttributeValue(zrowItems, zrowIndex, "ows_RecurrenceData");

            // If the RecurrenceData field value equal to set in the request of UpdateListItems, that means setting of RepeatPattern.daily is set in the protocol SUT. If this verification passes then capture R903
            this.Site.Assert.AreEqual<string>(
                                    recurrenceXMLString.ToLower(),
                                    actualRecurrenceXMLStringValue.ToLower(),
                                    "The RecurrenceData value equal to set in the request of UpdateListItems");

            // Verify MS-OUTSPS requirement: MS-OUTSPS_R903
            this.Site.CaptureRequirement(
                           903,
                           @"[In RepeatPattern complex type]daily: If the recurrence is a daily recurrence, the daily element will be present.");
        }
        public void MSOUTSPS_S02_TC19_RecurrenceAppointmentItem_RecurrenceRulerepeatForever()
        {
            string listId = this.AddListToSUT(TemplateType.Events);

            Dictionary<string, string> recurEventFieldsSetting = new Dictionary<string, string>();
            DateTime eventDate = DateTime.Today.Date.AddDays(1);
            DateTime endDate = eventDate.Date.AddHours(1);
            string eventDateValue = this.GetGeneralFormatTimeString(eventDate);
            string endDateValue = this.GetGeneralFormatTimeString(endDate);

            // Recurring data
            RecurrenceXML recurrenceXMLData = new RecurrenceXML();
            recurrenceXMLData.deleteExceptions = null;
            recurrenceXMLData.recurrence = new RecurrenceDefinition();
            recurrenceXMLData.recurrence.rule = new RecurrenceRule();
            recurrenceXMLData.recurrence.rule.firstDayOfWeek = DayOfWeekOrMonth.su;
            recurrenceXMLData.recurrence.rule.Item = "FALSE";

            // Repeat Pattern
            recurrenceXMLData.recurrence.rule.repeat = new RepeatPattern();
            RepeatPatternDaily repeatPatternDailyData = new RepeatPatternDaily();

            // Setting the dayFrequencyValue
            repeatPatternDailyData.dayFrequency = "1";
            recurrenceXMLData.recurrence.rule.repeat.Item = repeatPatternDailyData;

            string recurrenceXmlString = this.GetRecurrenceXMLString(recurrenceXMLData);

            // Setting necessary fields' value
            recurEventFieldsSetting.Add("EventDate", eventDateValue);

            // The ending date and time of the appointment.
            recurEventFieldsSetting.Add("EndDate", endDateValue);

            // If the EventType indicates a recurring event, then fRecurrence MUST be "1". 
            recurEventFieldsSetting.Add("EventType", "1");

            // "0" means this is not an all-day event.
            recurEventFieldsSetting.Add("fAllDayEvent", "0");

            // "1" means this is a recurrence event.
            recurEventFieldsSetting.Add("fRecurrence", "1");

            // If EventType is "1", this property MUST contain a valid RecurrenceXML.
            recurEventFieldsSetting.Add("RecurrenceData", recurrenceXmlString);

            List<Dictionary<string, string>> addeditemsOfRecurrence = new List<Dictionary<string, string>>();
            addeditemsOfRecurrence.Add(recurEventFieldsSetting);

            List<MethodCmdEnum> cmds = new List<MethodCmdEnum>(1);
            cmds.Add(MethodCmdEnum.New);

            // add a  recurrence appointment item
            UpdateListItemsUpdates updatesOfRecurrence = this.CreateUpdateListItems(cmds, addeditemsOfRecurrence, OnErrorEnum.Continue);
            UpdateListItemsResponseUpdateListItemsResult updateResult = OutspsAdapter.UpdateListItems(listId, updatesOfRecurrence);
            this.VerifyResponseOfUpdateListItem(updateResult);
            XmlNode[] zrowitems = this.GetListItemsChangesFromSUT(listId);
            int listItemIndex = this.GetZrowItemIndexByListItemId(zrowitems, "1");

            #region Capture code

            // Verify MS-OUTSPS requirement: MS-OUTSPS_R1263
            this.Site.CaptureRequirementIfAreEqual(
                recurrenceXmlString,
                Common.GetZrowAttributeValue(zrowitems, listItemIndex, "ows_RecurrenceData"),
                1263,
                "[In RecurrenceRule complex type] repeatForever: Client set this value[repeatForever], and later client retrieve the value[repeatForever] from the server, they should be equal.");

            #endregion
        }
        public void MSOUTSPS_S02_TC17_RecurrenceAppointmentItem_RecurrenceDataValid()
        {
            string listId = this.AddListToSUT(TemplateType.Events);

            Dictionary<string, string> recurEventFieldsSetting = new Dictionary<string, string>();
            DateTime eventDate = DateTime.Today.Date.AddDays(1);
            DateTime endDate = eventDate.Date.AddHours(1);
            string eventDateValue = this.GetGeneralFormatTimeString(eventDate);
            string endDateValue = this.GetGeneralFormatTimeString(endDate);
            string eventTitle = this.GetUniqueListItemTitle("RecurrenceEvent");

            recurEventFieldsSetting.Add("Title", eventTitle);

            // Recurring data
            RecurrenceXML recurrenceXMLData = new RecurrenceXML();
            recurrenceXMLData.deleteExceptions = null;
            recurrenceXMLData.recurrence = new RecurrenceDefinition();
            recurrenceXMLData.recurrence.rule = new RecurrenceRule();
            recurrenceXMLData.recurrence.rule.firstDayOfWeek = DayOfWeekOrMonth.su;

            // Repeat Pattern
            recurrenceXMLData.recurrence.rule.repeat = new RepeatPattern();
            RepeatPatternDaily repeatPatternDailyData = new RepeatPatternDaily();

            // Setting the dayFrequencyValue
            repeatPatternDailyData.dayFrequency = "1";
            recurrenceXMLData.recurrence.rule.repeat.Item = repeatPatternDailyData;
            recurrenceXMLData.recurrence.rule.Item = "7";
            string recurrenceXmlString = this.GetRecurrenceXMLString(recurrenceXMLData);

            // Setting necessary fields' value
            recurEventFieldsSetting.Add("EventDate", eventDateValue);

            // The ending date and time of the appointment.
            recurEventFieldsSetting.Add("EndDate", endDateValue);

            // If the EventType indicates a recurring event, then fRecurrence MUST be "1". 
            recurEventFieldsSetting.Add("EventType", "1");

            // "0" means this is not an all-day event.
            recurEventFieldsSetting.Add("fAllDayEvent", "0");

            // "1" means this is a recurrence event.
            recurEventFieldsSetting.Add("fRecurrence", "1");

            // If EventType is "1", this property MUST contain a valid RecurrenceXML.
            recurEventFieldsSetting.Add("RecurrenceData", recurrenceXmlString);

            List<Dictionary<string, string>> addeditemsOfRecurrence = new List<Dictionary<string, string>>();
            addeditemsOfRecurrence.Add(recurEventFieldsSetting);

            List<MethodCmdEnum> cmds = new List<MethodCmdEnum>(1);
            cmds.Add(MethodCmdEnum.New);

            // add a  recurrence appointment item
            UpdateListItemsUpdates updatesOfRecurrence = this.CreateUpdateListItems(cmds, addeditemsOfRecurrence, OnErrorEnum.Continue);
            UpdateListItemsResponseUpdateListItemsResult updateResult = OutspsAdapter.UpdateListItems(listId, updatesOfRecurrence);

            XmlNode[] zrowitems = this.GetListItemsChangesFromSUT(listId);
            int listItemIndex = this.GetZrowItemIndexByListItemId(zrowitems, "1");
            XmlNode[] zrowItemsOfRecurrenceAppointment = this.GetZrowItems(updateResult.Results[0].Any);
            string updatedRecurrenceDataValue = Common.GetZrowAttributeValue(zrowItemsOfRecurrenceAppointment, 0, "ows_RecurrenceData");

            #region Capture code

            // Verify MS-OUTSPS requirement: MS-OUTSPS_R297
            this.Site.CaptureRequirementIfIsTrue(
                Common.GetZrowAttributeValue(zrowitems, listItemIndex, "ows_EventType") == "1" && Common.GetZrowAttributeValue(zrowitems, listItemIndex, "ows_RecurrenceData") == recurrenceXmlString,
                297,
                "[In Appointment-Specific Schema]RecurrenceData: If EventType is 1, this property MUST contain a valid RecurrenceXML (section 2.2.4.4).");

            // Verify MS-OUTSPS requirement: MS-OUTSPS_R898
            this.Site.CaptureRequirementIfIsTrue(
                this.VerifyComplexTypesSchema(updatedRecurrenceDataValue, typeof(RecurrenceXML)),
                898,
                @"[In Complex Types]The RecurrenceXML complex type contains a RecurrenceDefinition (section 2.2.4.3).
                    <s:complexType name=""RecurrenceXML"">
                      <s:sequence>
                        <s:element name=""recurrence"" type=""tns:RecurrenceDefinition"" />
                        <s:element name=""deleteExceptions"" type=""s:string"" fixed=""true"" minOccurs=""0"" maxOccurs=""1"" />
                      </s:sequence>
                    </s:complexType>");

            // Verify MS-OUTSPS requirement: MS-OUTSPS_R877
            this.Site.CaptureRequirementIfIsTrue(
                this.VerifyComplexTypesSchema(updatedRecurrenceDataValue, typeof(RecurrenceXML)),
                877,
                "[In Complex Types][The complex type]RecurrenceXML Contains a RecurrenceDefinition (section 2.2.4.3).");

            // Verify MS-OUTSPS requirement: MS-OUTSPS_R896
            this.Site.CaptureRequirementIfIsTrue(
                this.VerifyComplexTypesSchema(updatedRecurrenceDataValue, typeof(RecurrenceXML)),
                896,
                @"[In RecurrenceDefinition complex type] The RecurrenceDefinition complex type contains a RecurrenceRule (section 2.2.4.2).   
                    <s:complexType name=""RecurrenceDefinition"">
                      <s:sequence>
                        <s:element name=""rule"" type=""tns:RecurrenceRule"" />
                      </s:sequence>
                    </s:complexType>");

            // Verify MS-OUTSPS requirement: MS-OUTSPS_R876
            this.Site.CaptureRequirementIfIsTrue(
                this.VerifyComplexTypesSchema(updatedRecurrenceDataValue, typeof(RecurrenceXML)),
                876,
                "[In Complex Types][The complex type]RecurrenceDefinition Contains a RecurrenceRule (section 2.2.4.2).");

            // Verify MS-OUTSPS requirement: MS-OUTSPS_R888
            this.Site.CaptureRequirementIfIsTrue(
                this.VerifyComplexTypesSchema(updatedRecurrenceDataValue, typeof(RecurrenceXML)),
                888,
                @"[In RecurrenceRule complex type] The RecurrenceRule complex type defines when a recurrence takes place.
                    <s:complexType name=""RecurrenceRule"">
                      <s:sequence>
                        <s:element name=""firstDayOfWeek"" type=""tns:DayOfWeekOrMonth"" />
                        <s:element name=""repeat"" type=""tns:RepeatPattern"" />
                        <s:choice>
                          <s:element name=""windowEnd"" type=""s:dateTime"" />
                          <s:element name=""repeatForever"">
                            <s:simpleType>
                              <s:restriction base=""s:string"">            
                                <s:enumeration value=""FALSE"" />
                              </s:restriction>
                            </s:simpleType>
                          </s:element>
                          <s:element name=""repeatInstances"" type=""s:integer"" />
                        </s:choice>
                      </s:sequence>
                    </s:complexType>");

            // Verify MS-OUTSPS requirement: MS-OUTSPS_R875
            this.Site.CaptureRequirementIfIsTrue(
                this.VerifyComplexTypesSchema(updatedRecurrenceDataValue, typeof(RecurrenceXML)),
                875,
                "[In Complex Types][The complex type]RecurrenceRule Defines when a recurrence takes place.");

            // Verify MS-OUTSPS requirement: MS-OUTSPS_R878
            this.Site.CaptureRequirementIfIsTrue(
                this.VerifyComplexTypesSchema(updatedRecurrenceDataValue, typeof(RecurrenceXML)),
                878,
                "[In Complex Types][The complex type]RepeatPattern Contains a choice of elements which describe what days a recurrence occurs on.");

            // Verify MS-OUTSPS requirement: MS-OUTSPS_R902
            this.Site.CaptureRequirementIfIsTrue(
                this.VerifyComplexTypesSchema(updatedRecurrenceDataValue, typeof(RecurrenceXML)),
                902,
                @"[In Complex Types]The RepeatPattern complex type contains a choice of elements which describe what days a recurrence occurs on.
                    <s:complexType name=""RepeatPattern"">
                        < s:choice >
                            < s:element name = ""daily"" >
                            < s:complexType >
                                < s:simpleContent >
                                < s:extension base = ""s:string"" >
                                    < s:attribute name = ""weekday"" type = ""tns:TrueFalseDOW"" default= ""FALSE"" use = ""optional"" />
                                    < s:attribute name = ""dayFrequency"" type = ""s:integer"" default= ""1"" use = ""optional"" />
                                </ s:extension >
                                </ s:simpleContent >
                            </ s:complexType >
                            </ s:element >
                            < s:element name = ""weekly"" >
                            < s:complexType >
                                < s:simpleContent >
                                < s:extension base = ""s:string"" >
                                    < s:attribute name = ""su"" type = ""tns:TrueFalseDOW"" default= ""FALSE"" use = ""optional"" />
                                    < s:attribute name = ""mo"" type = ""tns:TrueFalseDOW"" default= ""FALSE"" use = ""optional"" />
                                    < s:attribute name = ""tu"" type = ""tns:TrueFalseDOW"" default= ""FALSE"" use = ""optional"" />
                                    < s:attribute name = ""we"" type = ""tns:TrueFalseDOW"" default= ""FALSE"" use = ""optional"" />
                                    < s:attribute name = ""th"" type = ""tns:TrueFalseDOW"" default= ""FALSE"" use = ""optional"" />
                                    < s:attribute name = ""fr"" type = ""tns:TrueFalseDOW"" default= ""FALSE"" use = ""optional"" />
                                    < s:attribute name = ""sa"" type = ""tns:TrueFalseDOW"" default= ""FALSE"" use = ""optional"" />
                                    < s:attribute name = ""weekFrequency"" type = ""s:integer"" default= ""1"" use = ""optional"" />
                                </ s:extension >
                                </ s:simpleContent >
                            </ s:complexType >
                            </ s:element >
                            < s:element name = ""monthlyByDay"" >
                            < s:complexType >
                                < s:simpleContent >
                                < s:extension base = ""s:string"" >
                                    < s:attribute name = ""su"" type = ""tns:TrueFalseDOW"" default= ""FALSE"" use = ""optional"" />
                                    < s:attribute name = ""mo"" type = ""tns:TrueFalseDOW"" default= ""FALSE"" use = ""optional"" />
                                    < s:attribute name = ""tu"" type = ""tns:TrueFalseDOW"" default= ""FALSE"" use = ""optional"" />
                                    < s:attribute name = ""we"" type = ""tns:TrueFalseDOW"" default= ""FALSE"" use = ""optional"" />
                                    < s:attribute name = ""th"" type = ""tns:TrueFalseDOW"" default= ""FALSE"" use = ""optional"" />
                                    < s:attribute name = ""fr"" type = ""tns:TrueFalseDOW"" default= ""FALSE"" use = ""optional"" />
                                    < s:attribute name = ""sa"" type = ""tns:TrueFalseDOW"" default= ""FALSE"" use = ""optional"" />
                                    < s:attribute name = ""day"" type = ""tns:TrueFalseDOW"" default= ""FALSE"" use = ""optional"" />
                                    < s:attribute name = ""weekday"" type = ""tns:TrueFalseDOW"" default= ""FALSE"" use = ""optional"" />
                                    < s:attribute name = ""weekend_day"" type = ""tns:TrueFalseDOW"" default= ""FALSE"" use = ""optional"" />
                                    < s:attribute name = ""monthFrequency"" type = ""s:integer"" default= ""1"" use = ""optional"" />
                                    < s:attribute name = ""weekdayOfMonth"" type = ""tns:WeekdayOfMonth"" default= ""first"" use = ""optional"" />
                                </ s:extension >
                                </ s:simpleContent >
                            </ s:complexType >
                            </ s:element >
                            < s:element name = ""monthly"" >
                            < s:complexType >
                                < s:simpleContent >
                                < s:extension base = ""s:string"" >
                                    < s:attribute name = ""monthFrequency"" type = ""s:integer"" default= ""1"" use = ""optional"" />
                                    < s:attribute name = ""day"" type = ""s:integer"" default= ""1"" use = ""optional"" />
                                </ s:extension >
                                </ s:simpleContent >
                            </ s:complexType >
                            </ s:element >
                            < s:element name = ""yearly"" >
                            < s:complexType >
                                < s:simpleContent >
                                < s:extension base = ""s:string"" >
                                    < s:attribute name = ""yearFrequency"" type = ""s:integer"" default= ""1"" use = ""optional"" />
                                    < s:attribute name = ""month"" type = ""s:integer"" default= ""1"" use = ""optional"" />
                                    < s:attribute name = ""day"" type = ""s:integer"" default= ""1"" use = ""optional"" />
                                </ s:extension >
                                </ s:simpleContent >
                            </ s:complexType >
                            </ s:element >
                            < s:element name = ""yearlyByDay"" >
                            < s:complexType >
                                < s:simpleContent >
                                < s:extension base = ""s:string"" >
                                    < s:attribute name = ""su"" type = ""tns:TrueFalseDOW"" default= ""FALSE"" use = ""optional"" />
                                    < s:attribute name = ""mo"" type = ""tns:TrueFalseDOW"" default= ""FALSE"" use = ""optional"" />
                                    < s:attribute name = ""tu"" type = ""tns:TrueFalseDOW"" default= ""FALSE"" use = ""optional"" />
                                    < s:attribute name = ""we"" type = ""tns:TrueFalseDOW"" default= ""FALSE"" use = ""optional"" />
                                    < s:attribute name = ""th"" type = ""tns:TrueFalseDOW"" default= ""FALSE"" use = ""optional"" />
                                    < s:attribute name = ""fr"" type = ""tns:TrueFalseDOW"" default= ""FALSE"" use = ""optional"" />
                                    < s:attribute name = ""sa"" type = ""tns:TrueFalseDOW"" default= ""FALSE"" use = ""optional"" />
                                    < s:attribute name = ""day"" type = ""tns:TrueFalseDOW"" default= ""FALSE"" use = ""optional"" />
                                    < s:attribute name = ""weekday"" type = ""tns:TrueFalseDOW"" default= ""FALSE"" use = ""optional"" />
                                    < s:attribute name = ""weekend_day"" type = ""tns:TrueFalseDOW"" default= ""FALSE"" use = ""optional"" />
                                    < s:attribute name = ""yearFrequency"" type = ""s:integer"" default= ""1"" use = ""optional"" />
                                    < s:attribute name = ""month"" type = ""s:integer"" default= ""1"" use = ""optional"" />
                                    < s:attribute name = ""weekdayOfMonth"" type = ""tns:WeekdayOfMonth"" default= ""first"" use = ""optional"" />
                                </ s:extension >
                                </ s:simpleContent >
                            </ s:complexType >
                            </ s:element >
                        </ s:choice >
                        </ s:complexType >
                    ");

            #endregion
        }
        public void MSOUTSPS_S02_TC14_RecurrenceAppointmentItem_VerifyUIDField()
        {
            string listId = this.AddListToSUT(TemplateType.Events);

            Dictionary<string, string> recurEventFieldsSetting = new Dictionary<string, string>();
            DateTime eventDate = DateTime.Today.Date.AddDays(1);
            DateTime endDate = eventDate.Date.AddHours(1);
            string eventDateValue = this.GetGeneralFormatTimeString(eventDate);
            string endDateValue = this.GetGeneralFormatTimeString(endDate);
            string eventTitle = this.GetUniqueListItemTitle("RecurrenceEvent");

            recurEventFieldsSetting.Add("Title", eventTitle);

            Guid uid = Guid.NewGuid();

            // Recurring data
            RecurrenceXML recurrenceXMLData = new RecurrenceXML();
            recurrenceXMLData.deleteExceptions = null;
            recurrenceXMLData.recurrence = new RecurrenceDefinition();
            recurrenceXMLData.recurrence.rule = new RecurrenceRule();
            recurrenceXMLData.recurrence.rule.firstDayOfWeek = DayOfWeekOrMonth.su;

            // Repeat Pattern
            recurrenceXMLData.recurrence.rule.repeat = new RepeatPattern();
            RepeatPatternDaily repeatPatternDailyData = new RepeatPatternDaily();

            // Setting the dayFrequencyValue
            repeatPatternDailyData.dayFrequency = "1";
            recurrenceXMLData.recurrence.rule.repeat.Item = repeatPatternDailyData;
            recurrenceXMLData.recurrence.rule.Item = "7";
            string recurrenceXmlString = this.GetRecurrenceXMLString(recurrenceXMLData);

            // Setting necessary fields' value
            recurEventFieldsSetting.Add("EventDate", eventDateValue);

            // The ending date and time of the appointment.
            recurEventFieldsSetting.Add("EndDate", endDateValue);

            // "1" indicates a recurring event. 
            recurEventFieldsSetting.Add("EventType", "1");

            // "0" means this is not an all-day event.
            recurEventFieldsSetting.Add("fAllDayEvent", "0");

            // "1" means this is a recurrence event.
            recurEventFieldsSetting.Add("fRecurrence", "1");

            // If EventType is "1", this property MUST contain a valid RecurrenceXML.
            recurEventFieldsSetting.Add("RecurrenceData", recurrenceXmlString);

            List<Dictionary<string, string>> addeditemsOfRecurrence = new List<Dictionary<string, string>>();
            addeditemsOfRecurrence.Add(recurEventFieldsSetting);

            List<MethodCmdEnum> cmds = new List<MethodCmdEnum>(1);
            cmds.Add(MethodCmdEnum.New);

            // add a  recurrence appointment item
            UpdateListItemsUpdates updatesOfRecurrence = this.CreateUpdateListItems(cmds, addeditemsOfRecurrence, OnErrorEnum.Continue);
            UpdateListItemsResponseUpdateListItemsResult updateResult = OutspsAdapter.UpdateListItems(listId, updatesOfRecurrence);
            List<string> recurrenceItemIds = this.GetListItemIdsFromUpdateListItemsResponse(updateResult, 1);

            #region Update the recurrence event
            Dictionary<string, string> recurEventFieldsSettingUpdate = new Dictionary<string, string>();
            recurEventFieldsSettingUpdate.Add("ID", recurrenceItemIds[0]);

            // If fRecurrence is true, this property MUST contain a valid stringGUID.
            recurEventFieldsSettingUpdate.Add("UID", uid.ToString());

            List<Dictionary<string, string>> addeditemsOfRecurrenceUpdate = new List<Dictionary<string, string>>();
            addeditemsOfRecurrenceUpdate.Add(recurEventFieldsSettingUpdate);

            List<MethodCmdEnum> cmdsUpdate = new List<MethodCmdEnum>(1);
            cmdsUpdate.Add(MethodCmdEnum.Update);

            // Update the recurrence event
            UpdateListItemsUpdates updatesOfRecurrenceUpdate = this.CreateUpdateListItems(cmdsUpdate, addeditemsOfRecurrenceUpdate, OnErrorEnum.Continue);
            UpdateListItemsResponseUpdateListItemsResult updateResultUpdate = OutspsAdapter.UpdateListItems(listId, updatesOfRecurrenceUpdate);
            this.VerifyResponseOfUpdateListItem(updateResultUpdate);
            #endregion

            XmlNode[] zrowitems = this.GetListItemsChangesFromSUT(listId);
            int listItemIndex = this.GetZrowItemIndexByListItemId(zrowitems, "1");
            string actualUIDValue = Common.GetZrowAttributeValue(zrowitems, listItemIndex, "ows_UID");

            #region Capture code

            Guid actualUID;
            if (!Guid.TryParse(actualUIDValue, out actualUID))
            {
                this.Site.Assert.Fail("The UID field should be valid GUID format.");
            }

            // Verify MS-OUTSPS requirement: MS-OUTSPS_R312
            this.Site.CaptureRequirementIfAreEqual<Guid>(
                uid,
                actualUID,
                312,
                "[In Appointment-Specific Schema]UID MUST be changed if, and only if, the recurrence has been changed or added. ");

            #endregion
        }
        /// <summary>
        /// Generate a daily recurrence setting with specified dayFrequency, specified title and duration.
        /// </summary>
        /// <param name="eventTitle">A parameter represents the title of event.</param>
        /// <param name="eventDate">A parameter represents the event date of event. The end date of the event is computed from this parameter by this formula: eventDate + 1 hour.</param>
        /// <param name="dayFrequencyValue">A parameter represents the value of daily recurrent frequency.</param>
        /// <param name="durationOfRecurrence">A parameter represents the duration of the recurrence event </param>
        /// <returns>A return value represents the daily recurrence setting with computed windowEnd value. windowEnd value is computed from durationOfRecurrence and eventDate parameters.</returns>
        protected Dictionary<string, string> GetDailyRecurrenceSettingWithwindowEnd(string eventTitle, DateTime eventDate, string dayFrequencyValue, double durationOfRecurrence)
        {
            if (string.IsNullOrEmpty(eventTitle))
            {
                throw new ArgumentException("Value should not be null or empty", "eventTitle");
            }

            // Recurring data
            RecurrenceXML recurrenceXMLData = new RecurrenceXML();
            recurrenceXMLData.deleteExceptions = null;
            recurrenceXMLData.recurrence = new RecurrenceDefinition();
            recurrenceXMLData.recurrence.rule = new RecurrenceRule();
            recurrenceXMLData.recurrence.rule.firstDayOfWeek = DayOfWeekOrMonth.su;

            // Set the windowEnd value, the recurrence will be end on durationOfRecurrence + 1 days from current date, and the recurrence duration should be equal to durationOfRecurrence.
            DateTime endDate = eventDate.AddHours(1);
            DateTime winEndDate = eventDate.Date.AddDays(durationOfRecurrence);
            recurrenceXMLData.recurrence.rule.Item = winEndDate;

            // Repeat Pattern
            recurrenceXMLData.recurrence.rule.repeat = new RepeatPattern();
            RepeatPatternDaily repeatPatternDailyData = new RepeatPatternDaily();

            // Setting the dayFrequencyValue
            repeatPatternDailyData.dayFrequency = dayFrequencyValue;
            recurrenceXMLData.recurrence.rule.repeat.Item = repeatPatternDailyData;

            string recurrenceXMLString = this.GetRecurrenceXMLString(recurrenceXMLData);

            // Generate a daily recurrence setting with specified dayFrequency, specified title and durationOfRecurrence.
            Dictionary<string, string> dailyRecurrenceSetting = this.GetGeneralRecurrenceEventFieldsSetting(eventTitle, eventDate, endDate, recurrenceXMLString);
            return dailyRecurrenceSetting;
        }