/// <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> /// This method is used to retrieve the Commands element in Sync response. /// </summary> /// <param name="syncResponse">The response of sync command.</param> /// <returns>The commands element in the response of sync command.</returns> private Response.SyncCollectionsCollectionCommands GetCommandsFromSyncResponse(SyncResponse syncResponse) { if (syncResponse.ResponseData.Item == null) { return(null); } Response.SyncCollections syncCollections = (Response.SyncCollections)syncResponse.ResponseData.Item; Site.Assert.AreEqual <int>(1, syncCollections.Collection.Length, "There should be one Collection element in Sync response."); Site.Assert.IsNotNull(syncCollections.Collection[0], "The Collection element in Sync response should be not null."); for (int i = 0; i < syncCollections.Collection[0].ItemsElementName.Length; i++) { if (Response.ItemsChoiceType10.Commands == syncCollections.Collection[0].ItemsElementName[i]) { Site.Assert.IsNotNull(syncCollections.Collection[0].Items[i], "The Commands element in Sync response should be not null."); return((Response.SyncCollectionsCollectionCommands)syncCollections.Collection[0].Items[i]); } } return(null); }