/// <summary>
        /// Add a meeting to the server.
        /// </summary>
        /// <param name="calendarCollectionId">The collectionId of the folder which the item should be added.</param>
        /// <param name="elementsToValueMap">The key and value pairs of common meeting properties.</param>
        protected void SyncAddMeeting(string calendarCollectionId, Dictionary <Request.ItemsChoiceType8, object> elementsToValueMap)
        {
            Request.SyncCollectionAddApplicationData applicationData = new Request.SyncCollectionAddApplicationData
            {
                Items            = new object[elementsToValueMap.Count],
                ItemsElementName = new Request.ItemsChoiceType8[elementsToValueMap.Count]
            };

            if (elementsToValueMap.Count > 0)
            {
                elementsToValueMap.Values.CopyTo(applicationData.Items, 0);
                elementsToValueMap.Keys.CopyTo(applicationData.ItemsElementName, 0);
            }

            SyncStore   iniSync        = this.InitializeSync(calendarCollectionId);
            SyncRequest syncAddRequest = TestSuiteHelper.CreateSyncAddRequest(iniSync.SyncKey, calendarCollectionId, applicationData);

            SyncStore syncAddResponse = this.EMAILAdapter.Sync(syncAddRequest);

            Site.Assert.AreEqual <int>(
                1,
                int.Parse(syncAddResponse.AddResponses[0].Status),
                "The sync add operation should be successful.");
        }
        /// <summary>
        /// Create a default calendar object in the current login user calendar folder
        /// </summary>
        /// <param name="subject">The calendar subject</param>
        /// <param name="organizerEmailAddress">The organizer email address</param>
        /// <param name="attendeeEmailAddress">The attendee email address</param>
        /// <param name="calendarUID">The uid of calendar</param>
        /// <param name="timestamp">The DtStamp of calendar</param>
        /// <param name="startTime">The StartTime of calendar</param>
        /// <param name="endTime">The EndTime of calendar</param>
        /// <returns>Returns the Calendar instance</returns>
        protected Calendar CreateDefaultCalendar(
            string subject,
            string organizerEmailAddress,
            string attendeeEmailAddress,
            string calendarUID,
            DateTime?timestamp,
            DateTime?startTime,
            DateTime?endTime)
        {
            #region Configure the default calendar application data
            Request.SyncCollectionAdd syncAddCollection = new Request.SyncCollectionAdd();
            string clientId = TestSuiteHelper.GetClientId();
            syncAddCollection.ClientId        = clientId;
            syncAddCollection.ApplicationData = new Request.SyncCollectionAddApplicationData();

            List <object> items = new List <object>();
            List <Request.ItemsChoiceType8> itemsElementName = new List <Request.ItemsChoiceType8>();

            if (!Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("12.1"))
            {
                items.Add(true);
                itemsElementName.Add(Request.ItemsChoiceType8.ResponseRequested);
            }
            #region TIME/Subject/Location/UID
            items.Add(string.Format("{0:yyyyMMddTHHmmss}Z", null == startTime ? DateTime.UtcNow.AddDays(5) : startTime.Value));
            itemsElementName.Add(Request.ItemsChoiceType8.StartTime);

            items.Add(string.Format("{0:yyyyMMddTHHmmss}Z", null == endTime ? DateTime.UtcNow.AddDays(5).AddMinutes(30) : endTime.Value));
            itemsElementName.Add(Request.ItemsChoiceType8.EndTime);

            if (!Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("16.0") && !Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("16.1"))
            {
                items.Add(string.Format("{0:yyyyMMddTHHmmss}Z", null == timestamp ? DateTime.UtcNow.AddDays(5) : timestamp.Value));
                itemsElementName.Add(Request.ItemsChoiceType8.DtStamp);
            }

            items.Add(subject);
            itemsElementName.Add(Request.ItemsChoiceType8.Subject);

            items.Add(calendarUID ?? Guid.NewGuid().ToString());
            if (Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("16.0") || Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("16.1"))
            {
                itemsElementName.Add(Request.ItemsChoiceType8.ClientUid);
            }
            else
            {
                itemsElementName.Add(Request.ItemsChoiceType8.UID);
            }

            if (Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("16.0") || Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("16.1"))
            {
                Request.Location location = new Request.Location();
                location.DisplayName = "OFFICE";
                items.Add(location);
                itemsElementName.Add(Request.ItemsChoiceType8.Location);
            }
            else
            {
                items.Add("OFFICE");
                itemsElementName.Add(Request.ItemsChoiceType8.Location1);
            }
            #endregion

            #region Attendee/Organizer
            Request.AttendeesAttendee attendee = new Request.AttendeesAttendee
            {
                Email                 = attendeeEmailAddress,
                Name                  = new MailAddress(attendeeEmailAddress).User,
                AttendeeStatus        = 0x0,
                AttendeeTypeSpecified = true,
                AttendeeType          = 0x1
            };

            // 0x0 = Response unknown

            // 0x1 = Required
            items.Add(new Request.Attendees()
            {
                Attendee = new Request.AttendeesAttendee[] { attendee }
            });
            itemsElementName.Add(Request.ItemsChoiceType8.Attendees);

            if (!Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("16.0") && !Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("16.1"))
            {
                items.Add(organizerEmailAddress);
                itemsElementName.Add(Request.ItemsChoiceType8.OrganizerEmail);
                items.Add(new MailAddress(organizerEmailAddress).DisplayName);
                itemsElementName.Add(Request.ItemsChoiceType8.OrganizerName);
            }
            #endregion

            #region Sensitivity/BusyStatus/AllDayEvent
            // 0x0 == Normal
            items.Add((byte)0x0);
            itemsElementName.Add(Request.ItemsChoiceType8.Sensitivity);

            // 0x1 == Tentative
            items.Add((byte)0x1);
            itemsElementName.Add(Request.ItemsChoiceType8.BusyStatus);

            // 0x0 not an all-day event
            items.Add((byte)0x0);
            itemsElementName.Add(Request.ItemsChoiceType8.AllDayEvent);
            #endregion

            syncAddCollection.ApplicationData.Items            = items.ToArray();
            syncAddCollection.ApplicationData.ItemsElementName = itemsElementName.ToArray();
            #endregion

            #region Execute the Sync command to upload the calendar
            SyncStore   initSyncResponse      = this.InitializeSync(this.User1Information.CalendarCollectionId);
            SyncRequest uploadCalendarRequest = TestSuiteHelper.CreateSyncAddRequest(initSyncResponse.SyncKey, this.User1Information.CalendarCollectionId, syncAddCollection);
            this.EMAILAdapter.Sync(uploadCalendarRequest);
            #endregion

            #region Get the new added calendar item
            SyncStore getItemResponse = this.GetSyncResult(subject, this.User1Information.CalendarCollectionId, null);
            Sync      calendarItem    = TestSuiteHelper.GetSyncAddItem(getItemResponse, subject);
            Site.Assert.IsNotNull(calendarItem, "The item with subject {0} should be found in the folder {1}.", subject, FolderType.Calendar.ToString());
            #endregion

            return(calendarItem.Calendar);
        }