/// <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> /// Load sync response to sync store. /// </summary> /// <param name="response">The response of Sync command.</param> /// <returns>The sync store instance.</returns> public static SyncStore LoadSyncResponse(ActiveSyncResponseBase <Response.Sync> response) { if (response.ResponseData.Item == null) { return(null); } SyncStore result = new SyncStore(); Response.SyncCollectionsCollection collection = ((Response.SyncCollections)response.ResponseData.Item).Collection[0]; for (int i = 0; i < collection.ItemsElementName.Length; i++) { switch (collection.ItemsElementName[i]) { case Response.ItemsChoiceType10.CollectionId: result.CollectionId = collection.Items[i].ToString(); break; case Response.ItemsChoiceType10.SyncKey: result.SyncKey = collection.Items[i].ToString(); break; case Response.ItemsChoiceType10.Status: result.Status = Convert.ToByte(collection.Items[i]); break; case Response.ItemsChoiceType10.Commands: Response.SyncCollectionsCollectionCommands commands = collection.Items[i] as Response.SyncCollectionsCollectionCommands; if (commands != null) { foreach (SyncItem item in LoadAddCommands(commands)) { result.AddCommands.Add(item); } } break; case Response.ItemsChoiceType10.Responses: Response.SyncCollectionsCollectionResponses responses = collection.Items[i] as Response.SyncCollectionsCollectionResponses; if (responses != null) { if (responses.Add != null) { foreach (Response.SyncCollectionsCollectionResponsesAdd add in responses.Add) { result.AddResponses.Add(add); } } } break; } } return(result); }