/// <summary> /// Create the elements of a note /// </summary> /// <returns>The dictionary of value and name for note's elements to be created</returns> protected Dictionary <Request.ItemsChoiceType8, object> CreateNoteElements() { Dictionary <Request.ItemsChoiceType8, object> addElements = new Dictionary <Request.ItemsChoiceType8, object>(); string subject = Common.GenerateResourceName(this.Site, "subject"); addElements.Add(Request.ItemsChoiceType8.Subject1, subject); Request.Body noteBody = new Request.Body { Type = 1, Data = "Content of the body." }; addElements.Add(Request.ItemsChoiceType8.Body, noteBody); Request.Categories4 categories = new Request.Categories4 { Category = new string[] { "blue category" } }; addElements.Add(Request.ItemsChoiceType8.Categories2, categories); addElements.Add(Request.ItemsChoiceType8.MessageClass, "IPM.StickyNote"); return(addElements); }
public void MSASTASK_S01_TC04_CreateTaskItemRecursMonthly() { #region Call Sync command to create a task with Recurrence whose Type element is recurs monthly. Dictionary<Request.ItemsChoiceType8, object> taskItem = new Dictionary<Request.ItemsChoiceType8, object>(); string subject = Common.GenerateResourceName(Site, "subject"); taskItem.Add(Request.ItemsChoiceType8.Subject2, subject); taskItem.Add(Request.ItemsChoiceType8.Importance1, (byte)1); Request.Categories4 categories = new Request.Categories4 { Category = "Business,Waiting".Split(',') }; taskItem.Add(Request.ItemsChoiceType8.Categories3, categories); Request.Recurrence1 recurrence = new Request.Recurrence1 { Type = 2, Start = DateTime.Now, UntilSpecified = true, DayOfMonthSpecified = true, DayOfMonth = 10 }; recurrence.Until = recurrence.Start.AddMonths(3); taskItem.Add(Request.ItemsChoiceType8.Recurrence1, recurrence); SyncStore syncResponse = this.SyncAddTask(taskItem); Site.Assert.AreEqual<int>(1, int.Parse(syncResponse.AddResponses[0].Status), "Task item should be created successfully."); ItemsNeedToDelete.Add(subject); #endregion #region Call Sync command to get the task item. SyncItem syncedTaskItem = this.GetChangeItem(this.UserInformation.TasksCollectionId, subject); Site.Assert.IsNotNull(syncedTaskItem.Task, "The task which subject is {0} should exist in server.", subject); #endregion // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R404"); // Verify MS-ASTASK requirement: MS-ASTASK_R404 // If DayOfMonthSpecified is true, DayOfMonth element is returned from server. Site.CaptureRequirementIfIsTrue( syncedTaskItem.Task.Recurrence.DayOfMonthSpecified, 404, @"[In DayOfMonth] A command [request or] response has a minimum of one DayOfMonth element per Recurrence element if the value of the Type element (section 2.2.2.27) is 2 [or 5]."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R409"); // Verify MS-ASTASK requirement: MS-ASTASK_R409 // If DayOfMonthSpecified is true, DayOfMonth element is returned from server. Site.CaptureRequirementIfIsTrue( syncedTaskItem.Task.Recurrence.DayOfMonthSpecified, 409, @"[In DayOfMonth] The DayOfMonth element MUST only be included in [requests or] responses when the Type element value is 2 [or 5]."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R366"); // Verify MS-ASTASK requirement: MS-ASTASK_R366 // If response is returned from server successfully, this requirement can be captured. Site.CaptureRequirementIfAreEqual<int>( 1, int.Parse(syncResponse.AddResponses[0].Status), 366, @"[In Sync Command Response] When a client uses the Sync command request ([MS-ASCMD] section 2.2.2.19) to synchronize its Task class items for a specified user with the tasks currently stored by the server, as specified in section 3.1.5.3, the server responds with a Sync command response ([MS-ASCMD] section 2.2.2.19)."); }
public void MSASTASK_S01_TC20_CreateTaskItemRecursMonthlyWithCalendarTypeReturned() { Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The CalendarType element is not supported when the MS-ASProtocolVersion header is set to 12.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion."); #region Call Sync command to create task item which recurs monthly and with CalendarType set. Dictionary<Request.ItemsChoiceType8, object> taskItem = new Dictionary<Request.ItemsChoiceType8, object>(); string subject = Common.GenerateResourceName(Site, "subject"); taskItem.Add(Request.ItemsChoiceType8.Subject2, subject); Request.Categories4 categories = new Request.Categories4 { Category = "Business,Waiting".Split(',') }; taskItem.Add(Request.ItemsChoiceType8.Categories3, categories); Request.Recurrence1 recurrence = new Request.Recurrence1 { Type = 2, Start = DateTime.Now, OccurrencesSpecified = true, Occurrences = 3, DayOfMonthSpecified = true, DayOfMonth = 10 }; taskItem.Add(Request.ItemsChoiceType8.Recurrence1, recurrence); SyncStore syncResponse = this.SyncAddTask(taskItem); Site.Assert.AreEqual<int>(1, int.Parse(syncResponse.AddResponses[0].Status), "Task item should be created successfully."); ItemsNeedToDelete.Add(subject); #endregion #region Call Sync command to get the task item. SyncItem syncedTaskItem = this.GetChangeItem(this.UserInformation.TasksCollectionId, subject); Site.Assert.IsNotNull(syncedTaskItem.Task, "The task which subject is {0} should exist in server.", subject); #endregion // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R82"); // Verify MS-ASTASK requirement: MS-ASTASK_R82 // If CalendarTypeSpecified is true, CalendarType element is returned from server. Site.CaptureRequirementIfIsTrue( syncedTaskItem.Task.Recurrence.CalendarTypeSpecified, 82, @"[In CalendarType] A command response has a minimum of one CalendarType child element per Recurrence element when the Type element is set to a value of 2;"); }
public void MSASTASK_S01_TC19_CreateTaskItemCategoriesWithoutChildElements() { #region Call Sync command to create task item with categories not containing any child elements. Dictionary<Request.ItemsChoiceType8, object> taskItem = new Dictionary<Request.ItemsChoiceType8, object>(); string subject = Common.GenerateResourceName(Site, "subject"); taskItem.Add(Request.ItemsChoiceType8.Subject2, subject); // Set Categories element without any child elements. Request.Categories4 categories = new Request.Categories4(); taskItem.Add(Request.ItemsChoiceType8.Categories3, categories); SyncStore syncResponse = this.SyncAddTask(taskItem); Site.Assert.AreEqual<int>(1, int.Parse(syncResponse.AddResponses[0].Status), "Task item should be created successfully."); ItemsNeedToDelete.Add(subject); #endregion #region Call Sync command to get the task item. SyncItem syncedTaskItem = this.GetChangeItem(this.UserInformation.TasksCollectionId, subject); Site.Assert.IsNotNull(syncedTaskItem.Task, "The task which subject is {0} should exist in server.", subject); #endregion // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R436"); // Verify MS-ASTASK requirement: MS-ASTASK_R436 // If Categories element is not returned from server, this element has been removed. Site.CaptureRequirementIfIsNull( syncedTaskItem.Task.Categories, 436, @"[In Categories] If a Categories element contains no Category child elements in a request [or response], then the categories for the specified task will be removed."); }
public void MSASNOTE_S01_TC07_Sync_ChangeNote_Categories() { #region Call method Sync to add a note with two child elements in a Categories element to the server Dictionary <Request.ItemsChoiceType8, object> addElements = this.CreateNoteElements(); Request.Categories4 categories = new Request.Categories4 { Category = new string[2] }; Collection <string> category = new Collection <string> { "blue category", "red category" }; category.CopyTo(categories.Category, 0); addElements[Request.ItemsChoiceType8.Categories2] = categories; this.SyncAdd(addElements, 1); #endregion #region Call method Sync to synchronize the note item with the server and expect to get two child elements in response. // Synchronize the changes with server SyncStore result = this.SyncChanges(1); Note noteAdded = result.AddElements[0].Note; Site.Assert.IsNotNull(noteAdded.Categories, "The Categories element in response should not be null."); Site.Assert.IsNotNull(noteAdded.Categories.Category, "The category array in response should not be null."); Site.Assert.AreEqual(2, noteAdded.Categories.Category.Length, "The length of category array in response should be equal to 2."); #endregion #region Call method Sync to change the note with MessageClass elements and one child element of Categories element is missing. Dictionary <Request.ItemsChoiceType7, object> changeElements = new Dictionary <Request.ItemsChoiceType7, object> { { Request.ItemsChoiceType7.MessageClass, "IPM.StickyNote.MSASNOTE1" } }; categories.Category = new string[1]; category.Remove("red category"); category.CopyTo(categories.Category, 0); changeElements.Add(Request.ItemsChoiceType7.Categories3, categories); SyncStore changeResult = this.SyncChange(result.SyncKey, result.AddElements[0].ServerId, changeElements); Site.Assert.AreEqual <byte>( 1, changeResult.CollectionStatus, "The server should return a Status 1 in the Sync command response indicate sync command succeed."); #endregion #region Call method Sync to synchronize the note item with the server, and check if one child element is missing in response. // Synchronize the changes with server result = this.SyncChanges(result.SyncKey, 1); bool isNoteFound = TestSuiteHelper.CheckSyncChangeCommands(result, addElements[Request.ItemsChoiceType8.Subject1].ToString(), this.Site); Site.Assert.IsTrue(isNoteFound, "The note with subject:{0} should be returned in Sync command response.", addElements[Request.ItemsChoiceType8.Subject1].ToString()); Note note = result.ChangeElements[0].Note; Site.Assert.IsNotNull(note.Categories, "The Categories element in response should not be null."); Site.Assert.IsNotNull(note.Categories.Category, "The category array in response should not be null."); Site.Assert.IsNotNull(note.Subject, "The Subject element in response should not be null."); Site.Assert.AreEqual(1, note.Categories.Category.Length, "The length of category array in response should be equal to 1."); bool hasRedCategory = false; if (note.Categories.Category[0].Equals("red category", StringComparison.Ordinal)) { hasRedCategory = true; } // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASNOTE_R10002"); // Verify MS-ASNOTE requirement: MS-ASNOTE_R10002 Site.CaptureRequirementIfIsFalse( hasRedCategory, 10002, @"[In Sync Command Response] If a child of the Categories element (section 2.2.2.3) that was previously set is missing, the server will delete that property from the note."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASNOTE_R10003"); // Verify MS-ASNOTE requirement: MS-ASNOTE_R10003 Site.CaptureRequirementIfAreEqual <string>( noteAdded.Subject, note.Subject, 10003, @"[In Sync Command Response] The absence of a Subject element (section 2.2.2.6) within an airsync:Change element is not to be interpreted as an implicit delete."); #endregion #region Call method Sync to change the note with MessageClass elements and without Categories element. changeElements = new Dictionary <Request.ItemsChoiceType7, object> { { Request.ItemsChoiceType7.MessageClass, "IPM.StickyNote.MSASNOTE2" } }; changeResult = this.SyncChange(result.SyncKey, result.ChangeElements[0].ServerId, changeElements); Site.Assert.AreEqual <byte>( 1, changeResult.CollectionStatus, "The server should return a Status 1 in the Sync command response indicate sync command succeed."); #endregion #region Call method Sync to synchronize the note item with the server, and check if the Categories element is missing in response. // Synchronize the changes with server result = this.SyncChanges(result.SyncKey, 1); isNoteFound = TestSuiteHelper.CheckSyncChangeCommands(result, addElements[Request.ItemsChoiceType8.Subject1].ToString(), this.Site); Site.Assert.IsTrue(isNoteFound, "The note with subject:{0} should be returned in Sync command response.", addElements[Request.ItemsChoiceType8.Subject1].ToString()); note = result.ChangeElements[0].Note; // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASNOTE_R112"); // Verify MS-ASNOTE requirement: MS-ASNOTE_R112 Site.CaptureRequirementIfIsNull( note.Categories, 112, @"[In Sync Command Response] If the Categories element (section 2.2.2.2) that was previously set is missing[in an airsync:Change element in a Sync command request], the server will delete that property from the note."); #endregion }