/// <summary> /// Set sync request application data with calendar value /// </summary> /// <param name="calendar">The calendar instance</param> /// <returns>The application data for sync request</returns> private static Request.SyncCollectionAddApplicationData SetApplicationDataFromCalendar(Calendar calendar) { Request.SyncCollectionAddApplicationData applicationData = new Request.SyncCollectionAddApplicationData(); List <Request.ItemsChoiceType8> elementName = new List <Request.ItemsChoiceType8>(); List <object> elementValue = new List <object>(); // Set application data elementName.Add(Request.ItemsChoiceType8.Timezone); elementValue.Add(calendar.Timezone); elementName.Add(Request.ItemsChoiceType8.Subject); elementValue.Add(calendar.Subject); elementName.Add(Request.ItemsChoiceType8.Sensitivity); elementValue.Add(calendar.Sensitivity); elementName.Add(Request.ItemsChoiceType8.BusyStatus); elementValue.Add(calendar.BusyStatus); elementName.Add(Request.ItemsChoiceType8.AllDayEvent); elementValue.Add(calendar.AllDayEvent); applicationData.ItemsElementName = elementName.ToArray(); applicationData.Items = elementValue.ToArray(); return(applicationData); }
/// <summary> /// Add a meeting or appointment to server /// </summary> /// <param name="calendar">the calendar item</param> private void SyncAddCalendar(Calendar calendar) { Request.SyncCollectionAddApplicationData applicationData = SetApplicationDataFromCalendar(calendar); this.GetInitialSyncResponse(this.User1Information.CalendarCollectionId); Request.SyncCollectionAdd addCalendar = new Request.SyncCollectionAdd { ClientId = TestSuiteBase.ClientId, ApplicationData = applicationData }; SyncRequest syncAddCalendarRequest = TestSuiteBase.CreateSyncAddRequest(this.LastSyncKey, this.User1Information.CalendarCollectionId, addCalendar); SyncResponse syncAddCalendarResponse = this.CMDAdapter.Sync(syncAddCalendarRequest); // Get data from response Response.SyncCollections syncCollections = (Response.SyncCollections)syncAddCalendarResponse.ResponseData.Item; Response.SyncCollectionsCollectionResponses syncResponses = null; for (int index = 0; index < syncCollections.Collection[0].ItemsElementName.Length; index++) { if (syncCollections.Collection[0].ItemsElementName[index] == Response.ItemsChoiceType10.Responses) { syncResponses = (Response.SyncCollectionsCollectionResponses)syncCollections.Collection[0].Items[index]; break; } } Site.Assert.AreEqual(1, syncResponses.Add.Length, "User only upload one calendar item"); int statusCode = int.Parse(syncResponses.Add[0].Status); Site.Assert.AreEqual(1, statusCode, "If upload calendar item successful, server should return status 1"); }
/// <summary> /// Generate a Sync Add command with body element. /// </summary> /// <returns>Returns a command list instance.</returns> private static object[] CreateSyncAddCommands() { Request.Body addBody = new Request.Body { Type = 1, Data = "Test sync add" }; List <object> items = new List <object>(); List <Request.ItemsChoiceType8> itemsElementName = new List <Request.ItemsChoiceType8>(); items.Add(addBody); itemsElementName.Add(Request.ItemsChoiceType8.Body); Request.SyncCollectionAddApplicationData applicationData = new Request.SyncCollectionAddApplicationData { Items = items.ToArray(), ItemsElementName = itemsElementName.ToArray() }; Request.SyncCollectionAdd syncAdd = new Request.SyncCollectionAdd { ClientId = Guid.NewGuid().ToString("N"), ApplicationData = applicationData }; List <object> commandList = new List <object> { syncAdd }; return(commandList.ToArray()); }
/// <summary> /// Add a calendar to server, and if add is success then sync CalendarFolder. /// </summary> /// <param name="items">The dictionary store calendar item's element name and element value</param> /// <returns>Return the sync response</returns> public SyncStore AddSyncCalendar(Dictionary <Request.ItemsChoiceType8, object> items) { // Create a default calendar instance with Subject, TimeZone, Body, OrganizerEmail, OrganizerName, Location and UID elements Dictionary <Request.ItemsChoiceType8, object> calendar = this.CreateDefaultCalendar(); // Add elements if (items != null) { foreach (KeyValuePair <Request.ItemsChoiceType8, object> item in items) { if (calendar.ContainsKey(item.Key)) { calendar[item.Key] = item.Value; } else { calendar.Add(item.Key, item.Value); } } } Request.SyncCollectionAddApplicationData addCalendar = new Request.SyncCollectionAddApplicationData { Items = calendar.Values.ToArray <object>(), ItemsElementName = calendar.Keys.ToArray <Request.ItemsChoiceType8>() }; // Sync to get the SyncKey SyncStore initializeSyncResponse = this.InitializeSync(this.CurrentUserInformation.CalendarCollectionId, null); // Add the calendar item SyncRequest syncRequest = TestSuiteHelper.CreateSyncAddRequest(this.CurrentUserInformation.CalendarCollectionId, initializeSyncResponse.SyncKey, addCalendar); SyncStore syncCalendarResponse = this.CALAdapter.Sync(syncRequest); // Verify sync response, if the Sync command executes successfully, the Status in response should be 1. Site.Assert.AreEqual <byte>( 1, syncCalendarResponse.CollectionStatus, "If the Sync command executes successfully, the Status in response should be 1."); if (syncCalendarResponse.AddResponses != null) { foreach (Response.SyncCollectionsCollectionResponsesAdd response in syncCalendarResponse.AddResponses) { if (response.Status.Equals(byte.Parse("1"))) { // Sync command to do an initialization Sync, and get the server changes through sync command syncCalendarResponse = this.SyncChanges(this.CurrentUserInformation.CalendarCollectionId); } else { return(syncCalendarResponse); } } } return(syncCalendarResponse); }
/// <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> private 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); } string iniSyncKey = this.GetInitialSyncKey(calendarCollectionId); SyncRequest syncAddRequest = TestSuiteHelper.CreateSyncAddRequest(iniSyncKey, calendarCollectionId, applicationData); SyncStore syncAddResponse = this.ASAIRSAdapter.Sync(syncAddRequest); Site.Assert.AreEqual <int>( 1, int.Parse(syncAddResponse.AddResponses[0].Status), "The sync add operation should be successful."); }
/// <summary> /// Create a SyncCollectionAdd instance for adding a contact. /// </summary> /// <param name="fileAs">The FileAs element for the contact.</param> /// <param name="data">The body data of contact.</param> /// <param name="truncated">The Truncated element for the contact.</param> /// <returns>Return a SyncCollectionAdd instance.</returns> private static Request.SyncCollectionAdd CreateSyncAddContact(string fileAs, string data, bool? truncated) { Request.SyncCollectionAdd syncAdd = new Request.SyncCollectionAdd { ClientId = Guid.NewGuid().ToString("N") }; List<object> items = new List<object>(); List<Request.ItemsChoiceType8> itemsElementName = new List<Request.ItemsChoiceType8>(); items.Add(fileAs); itemsElementName.Add(Request.ItemsChoiceType8.FileAs); Request.Body addBody = new Request.Body { Type = 1, Data = data }; if (truncated != null) { addBody.TruncatedSpecified = true; addBody.Truncated = (bool)truncated; } items.Add(addBody); itemsElementName.Add(Request.ItemsChoiceType8.Body); Request.SyncCollectionAddApplicationData applicationData = new Request.SyncCollectionAddApplicationData { Items = items.ToArray(), ItemsElementName = itemsElementName.ToArray() }; syncAdd.ApplicationData = applicationData; return syncAdd; }
public void MSASCAL_S01_TC35_RecurrenceWithInterval0() { 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 Recurrence including Type '0' and Occurrences sub-element to the server, and sync calendars from the server. Dictionary<Request.ItemsChoiceType8, object> calendarItem = this.CreateDefaultCalendar(); calendarItem.Add(Request.ItemsChoiceType8.Recurrence, this.CreateCalendarRecurrence(byte.Parse("0"), 3, 0)); Request.SyncCollectionAddApplicationData addCalendar = new Request.SyncCollectionAddApplicationData { Items = calendarItem.Values.ToArray<object>(), ItemsElementName = calendarItem.Keys.ToArray<Request.ItemsChoiceType8>() }; // Sync to get the SyncKey SyncStore initializeSyncResponse = this.InitializeSync(this.CurrentUserInformation.CalendarCollectionId, null); // Add the calendar item SyncRequest syncRequest = TestSuiteHelper.CreateSyncAddRequest(this.CurrentUserInformation.CalendarCollectionId, initializeSyncResponse.SyncKey, addCalendar); SyncStore syncCalendarResponse = this.CALAdapter.Sync(syncRequest); if (Common.IsRequirementEnabled(4, this.Site)) { // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCAL_R4"); // Verify MS-ASCAL requirement: MS-ASCAL_R4 Site.CaptureRequirementIfAreEqual<string>( "6", syncCalendarResponse.AddResponses[0].Status, 4, @"[In Appendix B: Product Behavior] <2> Section 2.2.2.25: If Interval is set to 0 in command request, Microsoft Exchange Server 2007 returns Status value 6;"); } if (Common.IsRequirementEnabled(5, this.Site)) { 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); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCAL_R5"); // Verify MS-ASCAL requirement: MS-ASCAL_R5 Site.CaptureRequirementIfAreEqual<ushort>( 1, calendar.Calendar.Recurrence.Interval, 5, @"[In Appendix B: Product Behavior] [<2> Section 2.2.2.25: If Interval is set to 0 in command request,] Exchange 2010, Exchange 2013, and Exchange 2016 Preview return Interval value 1."); } #endregion }
/// <summary> /// Set sync request application data with calendar value /// </summary> /// <param name="calendar">The calendar instance</param> /// <returns>The application data for sync request</returns> private static Request.SyncCollectionAddApplicationData SetApplicationDataFromCalendar(Calendar calendar) { Request.SyncCollectionAddApplicationData applicationData = new Request.SyncCollectionAddApplicationData(); List<Request.ItemsChoiceType8> elementName = new List<Request.ItemsChoiceType8>(); List<object> elementValue = new List<object>(); // Set application data elementName.Add(Request.ItemsChoiceType8.Timezone); elementValue.Add(calendar.Timezone); elementName.Add(Request.ItemsChoiceType8.Subject); elementValue.Add(calendar.Subject); elementName.Add(Request.ItemsChoiceType8.Sensitivity); elementValue.Add(calendar.Sensitivity); elementName.Add(Request.ItemsChoiceType8.BusyStatus); elementValue.Add(calendar.BusyStatus); elementName.Add(Request.ItemsChoiceType8.AllDayEvent); elementValue.Add(calendar.AllDayEvent); applicationData.ItemsElementName = elementName.ToArray(); applicationData.Items = elementValue.ToArray(); return applicationData; }
/// <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."); }
public void MSASAIRS_S05_TC01_Location() { Site.Assume.AreNotEqual <string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Location element is supported when the MS-ASProtocolVersion header is set to 16.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion."); Site.Assume.AreNotEqual <string>("14.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Location element is supported when the MS-ASProtocolVersion header is set to 16.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion."); Site.Assume.AreNotEqual <string>("14.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Location element is supported when the MS-ASProtocolVersion header is set to 16.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion."); #region Call Sync command with Add element to add an appointment to the server Request.SyncCollectionAddApplicationData applicationData = new Request.SyncCollectionAddApplicationData(); List <object> items = new List <object>(); List <Request.ItemsChoiceType8> itemsElementName = new List <Request.ItemsChoiceType8>(); string subject = Common.GenerateResourceName(Site, "Subject"); items.Add(subject); itemsElementName.Add(Request.ItemsChoiceType8.Subject); // MeetingStauts is set to 0, which means it is an appointment with no attendees. byte meetingStatus = 0; items.Add(meetingStatus); itemsElementName.Add(Request.ItemsChoiceType8.MeetingStatus); Request.Location location = new Request.Location(); location.Accuracy = (double)1; location.AccuracySpecified = true; location.Altitude = (double)55.46; location.AltitudeAccuracy = (double)1; location.AltitudeAccuracySpecified = true; location.AltitudeSpecified = true; location.Annotation = "Location sample annotation"; location.City = "Location sample city"; location.Country = "Location sample country"; location.DisplayName = "Location sample dislay name"; location.Latitude = (double)11.56; location.LatitudeSpecified = true; location.LocationUri = "Location Uri"; location.Longitude = (double)1.9; location.LongitudeSpecified = true; location.PostalCode = "Location sample postal code"; location.State = "Location sample state"; location.Street = "Location sample street"; items.Add(location); itemsElementName.Add(Request.ItemsChoiceType8.Location1); applicationData.Items = items.ToArray(); applicationData.ItemsElementName = itemsElementName.ToArray(); SyncRequest syncAddRequest = TestSuiteHelper.CreateSyncAddRequest(this.GetInitialSyncKey(this.User1Information.CalendarCollectionId), this.User1Information.CalendarCollectionId, applicationData); DataStructures.SyncStore syncAddResponse = this.ASAIRSAdapter.Sync(syncAddRequest); Site.Assert.IsTrue(syncAddResponse.AddResponses[0].Status.Equals("1"), "The sync add operation should be success; It is:{0} actually", syncAddResponse.AddResponses[0].Status); // Add the appointment to clean up list. this.RecordCaseRelativeItems(this.User1Information.UserName, this.User1Information.CalendarCollectionId, subject); #endregion #region Call Sync command to get the new added calendar item. DataStructures.Sync syncItem = this.GetSyncResult(subject, this.User1Information.CalendarCollectionId, null, null, null); #endregion #region Call ItemOperations command to reterive the added calendar item. this.GetItemOperationsResult(this.User1Information.CalendarCollectionId, syncItem.ServerId, null, null, null, null); #endregion #region Call Search command to search the added calendar item. this.GetSearchResult(subject, this.User1Information.CalendarCollectionId, null, null, null); #endregion }
/// <summary> /// Generate a Sync Add command with body element. /// </summary> /// <returns>Returns a command list instance.</returns> private static object[] CreateSyncAddCommands() { Request.Body addBody = new Request.Body { Type = 1, Data = "Test sync add" }; List<object> items = new List<object>(); List<Request.ItemsChoiceType8> itemsElementName = new List<Request.ItemsChoiceType8>(); items.Add(addBody); itemsElementName.Add(Request.ItemsChoiceType8.Body); Request.SyncCollectionAddApplicationData applicationData = new Request.SyncCollectionAddApplicationData { Items = items.ToArray(), ItemsElementName = itemsElementName.ToArray() }; Request.SyncCollectionAdd syncAdd = new Request.SyncCollectionAdd { ClientId = Guid.NewGuid().ToString("N"), ApplicationData = applicationData }; List<object> commandList = new List<object> { syncAdd }; return commandList.ToArray(); }
/// <summary> /// Create a sync add request. /// </summary> /// <param name="syncKey">Specify the sync key obtained from the last sync response</param> /// <param name="collectionId">Specify the server ID of the folder to be synchronized, which can be returned by ActiveSync FolderSync command.</param> /// <param name="applicationData">Contains the data used to specify the Add element for Sync command.</param> /// <returns>Returns the SyncRequest instance.</returns> internal static SyncRequest CreateSyncAddRequest(string syncKey, string collectionId, Request.SyncCollectionAddApplicationData applicationData) { SyncRequest syncAddRequest = TestSuiteHelper.CreateSyncRequest(syncKey, collectionId, null); Request.SyncCollectionAdd add = new Request.SyncCollectionAdd { ClientId = GetClientId(), ApplicationData = applicationData }; List <object> commandList = new List <object> { add }; syncAddRequest.RequestData.Collections[0].Commands = commandList.ToArray(); return(syncAddRequest); }
public void MSASCAL_S01_TC32_WithoutUID() { #region Call Sync command to add a calendar without element UID to the server, and sync calendars from the server. Dictionary<Request.ItemsChoiceType8, object> calendarItem = this.CreateDefaultCalendar(); calendarItem.Remove(Request.ItemsChoiceType8.UID); Request.SyncCollectionAddApplicationData addCalendar = new Request.SyncCollectionAddApplicationData { Items = calendarItem.Values.ToArray<object>(), ItemsElementName = calendarItem.Keys.ToArray<Request.ItemsChoiceType8>() }; // Sync to get the SyncKey SyncStore initializeSyncResponse = this.InitializeSync(this.CurrentUserInformation.CalendarCollectionId, null); // Add the calendar item SyncRequest syncRequest = TestSuiteHelper.CreateSyncAddRequest(this.CurrentUserInformation.CalendarCollectionId, initializeSyncResponse.SyncKey, addCalendar); SyncStore syncCalendarResponse = this.CALAdapter.Sync(syncRequest); // Verify sync response, if the Sync command executes successfully, the Status in response should be 1. Site.Assert.AreEqual<byte>( 1, syncCalendarResponse.CollectionStatus, "If the Sync command executes successfully, the Status in response should be 1."); 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 if (!this.IsActiveSyncProtocolVersion121 && !this.IsActiveSyncProtocolVersion140 && !this.IsActiveSyncProtocolVersion141) { // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCAL_R2223"); // Verify MS-ASCAL requirement: MS-ASCAL_R2223 Site.CaptureRequirementIfIsNotNull( calendar.Calendar.UID, 2223, @"[In UID] When a calendar item is created, the server will generate a unique identifier for the calendar item and return the identifier in the UID element of the Sync command response ([MS-ASCMD] section 2.2.2.20) for an add operation."); } }
/// <summary> /// This method is used to add a contact to server. /// </summary> /// <param name="collectionId">The collectionId of the folder which the contact is added to.</param> /// <param name="contactProperties">The dictionary for contact properties and its values.</param> /// <returns>The result returned from server for adding a contact.</returns> protected DataStructures.SyncStore AddContact(string collectionId, Dictionary<Request.ItemsChoiceType8, object> contactProperties) { Request.SyncCollectionAddApplicationData applicationData = new Request.SyncCollectionAddApplicationData { ItemsElementName = new Request.ItemsChoiceType8[contactProperties.Count], Items = new object[contactProperties.Count] }; contactProperties.Keys.CopyTo(applicationData.ItemsElementName, 0); contactProperties.Values.CopyTo(applicationData.Items, 0); string syncKey = this.GetInitialSyncKey(collectionId, null); SyncRequest syncAddRequest = TestSuiteHelper.CreateSyncAddRequest(syncKey, collectionId, applicationData); DataStructures.SyncStore syncAddStore = this.ASCNTCAdapter.Sync(syncAddRequest); this.Site.Assert.AreEqual<byte>( 1, syncAddStore.CollectionStatus, "The Sync Add operation to add a contact should be successful."); // Since only one contact is added, the count of AddResponses should be 1. this.Site.Assert.AreEqual<int>( 1, syncAddStore.AddResponses.Count, "Only one contact is added, the count of AddResponses should be 1."); return syncAddStore; }
/// <summary> /// Add a calendar to server, and if add is success then sync CalendarFolder. /// </summary> /// <param name="items">The dictionary store calendar item's element name and element value</param> /// <returns>Return the sync response</returns> public SyncStore AddSyncCalendar(Dictionary<Request.ItemsChoiceType8, object> items) { // Create a default calendar instance with Subject, TimeZone, Body, OrganizerEmail, OrganizerName, Location and UID elements Dictionary<Request.ItemsChoiceType8, object> calendar = this.CreateDefaultCalendar(); // Add elements if (items != null) { foreach (KeyValuePair<Request.ItemsChoiceType8, object> item in items) { if (calendar.ContainsKey(item.Key)) { calendar[item.Key] = item.Value; } else { calendar.Add(item.Key, item.Value); } } } Request.SyncCollectionAddApplicationData addCalendar = new Request.SyncCollectionAddApplicationData { Items = calendar.Values.ToArray<object>(), ItemsElementName = calendar.Keys.ToArray<Request.ItemsChoiceType8>() }; // Sync to get the SyncKey SyncStore initializeSyncResponse = this.InitializeSync(this.CurrentUserInformation.CalendarCollectionId, null); // Add the calendar item SyncRequest syncRequest = TestSuiteHelper.CreateSyncAddRequest(this.CurrentUserInformation.CalendarCollectionId, initializeSyncResponse.SyncKey, addCalendar); SyncStore syncCalendarResponse = this.CALAdapter.Sync(syncRequest); // Verify sync response, if the Sync command executes successfully, the Status in response should be 1. Site.Assert.AreEqual<byte>( 1, syncCalendarResponse.CollectionStatus, "If the Sync command executes successfully, the Status in response should be 1."); if (syncCalendarResponse.AddResponses != null) { foreach (Response.SyncCollectionsCollectionResponsesAdd response in syncCalendarResponse.AddResponses) { if (response.Status.Equals(byte.Parse("1"))) { // Sync command to do an initialization Sync, and get the server changes through sync command syncCalendarResponse = this.SyncChanges(this.CurrentUserInformation.CalendarCollectionId); } else { return syncCalendarResponse; } } } return syncCalendarResponse; }
public void MSASAIRS_S05_TC01_Location() { Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Location element is supported when the MS-ASProtocolVersion header is set to 16.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion."); Site.Assume.AreNotEqual<string>("14.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Location element is supported when the MS-ASProtocolVersion header is set to 16.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion."); Site.Assume.AreNotEqual<string>("14.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Location element is supported when the MS-ASProtocolVersion header is set to 16.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion."); #region Call Sync command with Add element to add an appointment to the server Request.SyncCollectionAddApplicationData applicationData = new Request.SyncCollectionAddApplicationData(); List<object> items = new List<object>(); List<Request.ItemsChoiceType8> itemsElementName = new List<Request.ItemsChoiceType8>(); string subject = Common.GenerateResourceName(Site, "Subject"); items.Add(subject); itemsElementName.Add(Request.ItemsChoiceType8.Subject); // MeetingStauts is set to 0, which means it is an appointment with no attendees. byte meetingStatus = 0; items.Add(meetingStatus); itemsElementName.Add(Request.ItemsChoiceType8.MeetingStatus); Request.Location location = new Request.Location(); location.Accuracy = (double)1; location.AccuracySpecified = true; location.Altitude = (double)55.46; location.AltitudeAccuracy = (double)1; location.AltitudeAccuracySpecified = true; location.AltitudeSpecified = true; location.Annotation = "Location sample annotation"; location.City = "Location sample city"; location.Country = "Location sample country"; location.DisplayName = "Location sample dislay name"; location.Latitude = (double)11.56; location.LatitudeSpecified = true; location.LocationUri = "Location Uri"; location.Longitude = (double)1.9; location.LongitudeSpecified = true; location.PostalCode = "Location sample postal code"; location.State = "Location sample state"; location.Street = "Location sample street"; items.Add(location); itemsElementName.Add(Request.ItemsChoiceType8.Location1); applicationData.Items = items.ToArray(); applicationData.ItemsElementName = itemsElementName.ToArray(); SyncRequest syncAddRequest = TestSuiteHelper.CreateSyncAddRequest(this.GetInitialSyncKey(this.User1Information.CalendarCollectionId), this.User1Information.CalendarCollectionId, applicationData); DataStructures.SyncStore syncAddResponse = this.ASAIRSAdapter.Sync(syncAddRequest); Site.Assert.IsTrue(syncAddResponse.AddResponses[0].Status.Equals("1"), "The sync add operation should be success; It is:{0} actually", syncAddResponse.AddResponses[0].Status); // Add the appointment to clean up list. this.RecordCaseRelativeItems(this.User1Information.UserName, this.User1Information.CalendarCollectionId, subject); #endregion #region Call Sync command to get the new added calendar item. DataStructures.Sync syncItem = this.GetSyncResult(subject, this.User1Information.CalendarCollectionId, null, null, null); #endregion #region Call ItemOperations command to reterive the added calendar item. this.GetItemOperationsResult(this.User1Information.CalendarCollectionId, syncItem.ServerId, null, null, null, null); #endregion #region Call Search command to search the added calendar item. this.GetSearchResult(subject, this.User1Information.CalendarCollectionId, null, null, null); #endregion }
public void MSASAIRS_S05_TC01_Location() { Site.Assume.AreNotEqual <string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Location element is supported when the MS-ASProtocolVersion header is set to 16.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion."); Site.Assume.AreNotEqual <string>("14.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Location element is supported when the MS-ASProtocolVersion header is set to 16.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion."); Site.Assume.AreNotEqual <string>("14.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Location element is supported when the MS-ASProtocolVersion header is set to 16.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion."); #region Call Sync command with Add element to add an appointment to the server Request.SyncCollectionAddApplicationData applicationData = new Request.SyncCollectionAddApplicationData(); List <object> items = new List <object>(); List <Request.ItemsChoiceType8> itemsElementName = new List <Request.ItemsChoiceType8>(); string subject = Common.GenerateResourceName(Site, "Subject"); items.Add(subject); itemsElementName.Add(Request.ItemsChoiceType8.Subject); // MeetingStauts is set to 0, which means it is an appointment with no attendees. byte meetingStatus = 0; items.Add(meetingStatus); itemsElementName.Add(Request.ItemsChoiceType8.MeetingStatus); Request.Location location = new Request.Location(); location.Accuracy = (double)1; location.AccuracySpecified = true; location.Altitude = (double)55.46; location.AltitudeAccuracy = (double)1; location.AltitudeAccuracySpecified = true; location.AltitudeSpecified = true; location.Annotation = "Location sample annotation"; location.City = "Location sample city"; location.Country = "Location sample country"; location.DisplayName = "Location sample dislay name"; location.Latitude = (double)11.56; location.LatitudeSpecified = true; location.LocationUri = "Location Uri"; location.Longitude = (double)1.9; location.LongitudeSpecified = true; location.PostalCode = "Location sample postal code"; location.State = "Location sample state"; location.Street = "Location sample street"; items.Add(location); itemsElementName.Add(Request.ItemsChoiceType8.Location); applicationData.Items = items.ToArray(); applicationData.ItemsElementName = itemsElementName.ToArray(); SyncRequest syncAddRequest = TestSuiteHelper.CreateSyncAddRequest(this.GetInitialSyncKey(this.User1Information.CalendarCollectionId), this.User1Information.CalendarCollectionId, applicationData); DataStructures.SyncStore syncAddResponse = this.ASAIRSAdapter.Sync(syncAddRequest); Site.Assert.IsTrue(syncAddResponse.AddResponses[0].Status.Equals("1"), "The sync add operation should be success; It is:{0} actually", syncAddResponse.AddResponses[0].Status); // Add the appointment to clean up list. this.RecordCaseRelativeItems(this.User1Information.UserName, this.User1Information.CalendarCollectionId, subject); #endregion #region Call Sync command to get the new added calendar item. DataStructures.Sync syncItem = this.GetSyncResult(subject, this.User1Information.CalendarCollectionId, null, null, null); #endregion #region Call ItemOperations command to reterive the added calendar item. this.GetItemOperationsResult(this.User1Information.CalendarCollectionId, syncItem.ServerId, null, null, null, null); #endregion #region Call Sync command to remove the location of the added calender item. // Create empty change items list. List <object> changeItems = new List <object>(); List <Request.ItemsChoiceType7> changeItemsElementName = new List <Request.ItemsChoiceType7>(); // Create an empty location. location = new Request.Location(); // Add the location field name into the change items element name list. changeItemsElementName.Add(Request.ItemsChoiceType7.Location); // Add the empty location value to the change items value list. changeItems.Add(location); // Create sync collection change. Request.SyncCollectionChange collectionChange = new Request.SyncCollectionChange { ServerId = syncItem.ServerId, ApplicationData = new Request.SyncCollectionChangeApplicationData { ItemsElementName = changeItemsElementName.ToArray(), Items = changeItems.ToArray() } }; // Create change sync collection Request.SyncCollection collection = new Request.SyncCollection { SyncKey = this.SyncKey, CollectionId = this.User1Information.CalendarCollectionId, Commands = new object[] { collectionChange } }; // Create change sync request. SyncRequest syncChangeRequest = Common.CreateSyncRequest(new Request.SyncCollection[] { collection }); // Change the location of the added calender by Sync request. DataStructures.SyncStore syncChangeResponse = this.ASAIRSAdapter.Sync(syncChangeRequest); Site.Assert.IsTrue(syncChangeResponse.CollectionStatus.Equals(1), "The sync change operation should be success; It is:{0} actually", syncChangeResponse.CollectionStatus); #region Call Sync command to get the new changed calendar item that removed the location. syncItem = this.GetSyncResult(subject, this.User1Information.CalendarCollectionId, null, null, null); #endregion #region Call ItemOperations command to reterive the changed calendar item that removed the location. DataStructures.ItemOperations itemOperations = this.GetItemOperationsResult(this.User1Information.CalendarCollectionId, syncItem.ServerId, null, null, null, null); #endregion // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASAIRS_R1001013"); // Verify MS-ASAIRS requirement: MS-ASAIRS_R1001013 Site.CaptureRequirementIfIsNull( itemOperations.Calendar.Location1.DisplayName, 1001013, @"[In Location] The client's request can include an empty Location element to remove the location from an item."); #endregion if (Common.IsRequirementEnabled(53, this.Site)) { #region Call Search command to search the added calendar item. this.GetSearchResult(subject, this.User1Information.CalendarCollectionId, null, null, null); #endregion } }
/// <summary> /// Create one sample calendar object. /// </summary> /// <param name="subject">Meeting subject.</param> /// <param name="attendeeEmailAddress">Meeting attendee email address.</param> /// <param name="createdCalendar">The calendar object</param> /// <returns>One sample calendar object.</returns> protected Calendar CreateCalendar(string subject, string attendeeEmailAddress, Calendar createdCalendar) { Dictionary<Request.ItemsChoiceType8, object> elementsToValueMap = this.SetMeetingProperties(subject, attendeeEmailAddress, this.Site); if (!Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("12.1")) { elementsToValueMap.Add(Request.ItemsChoiceType8.ResponseRequested, true); } if (createdCalendar != null) { if (createdCalendar.DtStamp != null) { elementsToValueMap.Add(Request.ItemsChoiceType8.DtStamp, DateTime.Parse(createdCalendar.DtStamp.ToString()).ToString("yyyyMMddTHHmmssZ")); } if (createdCalendar.StartTime != null) { elementsToValueMap.Add(Request.ItemsChoiceType8.StartTime, DateTime.Parse(createdCalendar.StartTime.ToString()).ToString("yyyyMMddTHHmmssZ")); } if (createdCalendar.EndTime != null) { elementsToValueMap.Add(Request.ItemsChoiceType8.EndTime, DateTime.Parse(createdCalendar.EndTime.ToString()).ToString("yyyyMMddTHHmmssZ")); } } // Call Sync command with Add element to add a meeting 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); } Request.SyncCollectionAdd calendarData = new Request.SyncCollectionAdd() { ClientId = TestSuiteBase.ClientId, ApplicationData = applicationData, }; this.GetInitialSyncResponse(this.User1Information.CalendarCollectionId); SyncRequest syncAddRequest = TestSuiteBase.CreateSyncAddRequest(this.LastSyncKey, this.User1Information.CalendarCollectionId, calendarData); SyncResponse syncResponse = this.Sync(syncAddRequest); SyncStore getChangeResult = this.GetSyncResult(subject, this.User1Information.CalendarCollectionId, null); Sync calendar = this.GetSyncAddItem(getChangeResult, subject); return calendar.Calendar; }
/// <summary> /// Builds a Sync add request by using the specified sync key, folder collection ID and add application data. /// In general, returns the XMl formatted Sync request as follows: /// <!-- /// <?xml version="1.0" encoding="utf-8"?> /// <Sync xmlns="AirSync"> /// <Collections> /// <Collection> /// <SyncKey>0</SyncKey> /// <CollectionId>5</CollectionId> /// <GetChanges>1</GetChanges> /// <WindowSize>152</WindowSize> /// <Commands> /// <Add> /// <ServerId>5:1</ServerId> /// <ApplicationData> /// ... /// </ApplicationData> /// </Add> /// </Commands> /// </Collection> /// </Collections> /// </Sync> /// --> /// </summary> /// <param name="collectionId">Specify the server ID of the folder to be synchronized, which can be returned by ActiveSync FolderSync command(Refer to [MS-ASCMD]2.2.3.30.5)</param> /// <param name="syncKey">Specify the sync key obtained from the last sync response(Refer to [MS-ASCMD]2.2.3.166.4)</param> /// <param name="addCalendars">Contains the data used to specify the Add element for Sync command(Refer to [MS-ASCMD]2.2.3.7.2)</param> /// <returns>Returns the SyncRequest instance</returns> internal static SyncRequest CreateSyncAddRequest(string collectionId, string syncKey, Request.SyncCollectionAddApplicationData addCalendars) { SyncRequest syncAddRequest; Request.SyncCollectionAdd add = new Request.SyncCollectionAdd { ClientId = TestSuiteHelper.Next(), ApplicationData = addCalendars }; List <object> commandList = new List <object> { add }; // The Sync request include the GetChanges element of the Collection element will set to 0 (FALSE) syncAddRequest = TestSuiteHelper.CreateSyncRequest(collectionId, syncKey, false); syncAddRequest.RequestData.Collections[0].Commands = commandList.ToArray(); return(syncAddRequest); }
public void MSASCAL_S01_TC03_CalendarWithoutOptionalElements() { #region Call Sync command to add a calendar without optional elements to the server, and sync calendars from the server. Dictionary<Request.ItemsChoiceType8, object> calendarItem = new Dictionary<Request.ItemsChoiceType8, object> { { Request.ItemsChoiceType8.Subject, this.SubjectName } }; // Set Calendar Subject Property Request.SyncCollectionAddApplicationData addCalendar = new Request.SyncCollectionAddApplicationData { Items = calendarItem.Values.ToArray<object>(), ItemsElementName = calendarItem.Keys.ToArray<Request.ItemsChoiceType8>() }; // Sync to get the SyncKey SyncStore initializeSyncResponse = this.InitializeSync(this.User1Information.CalendarCollectionId, null); // Add the calendar item SyncRequest syncRequest = TestSuiteHelper.CreateSyncAddRequest(this.User1Information.CalendarCollectionId, initializeSyncResponse.SyncKey, addCalendar); this.CALAdapter.Sync(syncRequest); SyncItem calendarWithoutOptionalElements = this.GetChangeItem(this.User1Information.CalendarCollectionId, this.SubjectName); Site.Assert.IsNotNull(calendarWithoutOptionalElements.Calendar, "The calendar with subject {0} should exist in server.", this.SubjectName); this.RecordCaseRelativeItems(this.User1Information.UserName, this.User1Information.CalendarCollectionId, this.SubjectName); #endregion }