/// <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.Categories3 categories = new Request.Categories3 { Category = new string[] { "blue category" } }; addElements.Add(Request.ItemsChoiceType8.Categories2, categories); addElements.Add(Request.ItemsChoiceType8.MessageClass, "IPM.StickyNote"); return(addElements); }
/// <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.Categories3 categories = new Request.Categories3 { Category = new string[] { "blue category" } }; addElements.Add(Request.ItemsChoiceType8.Categories2, categories); addElements.Add(Request.ItemsChoiceType8.MessageClass, "IPM.StickyNote"); return addElements; }
public void MSASCMD_S19_TC50_Sync_Class() { Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Class element is not supported in a Sync command response when the MS-ASProtocolVersion header is set to 12.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion."); #region Add a new Note item string noteSubject = Common.GenerateResourceName(Site, "noteSubject"); Request.Body noteBody = new Request.Body { Type = 1, Data = "Content of the body." }; Request.Categories3 categories = new Request.Categories3 { Category = new string[] { "blue category" } }; Request.SyncCollectionAdd noteData = new Request.SyncCollectionAdd { ClientId = TestSuiteBase.ClientId, ApplicationData = new Request.SyncCollectionAddApplicationData { ItemsElementName = new Request.ItemsChoiceType8[] { Request.ItemsChoiceType8.Subject1, Request.ItemsChoiceType8.Body, Request.ItemsChoiceType8.Categories2, Request.ItemsChoiceType8.MessageClass }, Items = new object[] { noteSubject, noteBody, categories, "IPM.StickyNote" } }, Class = "Calendar" }; this.Sync(TestSuiteBase.CreateEmptySyncRequest(this.User1Information.NotesCollectionId)); SyncRequest syncRequest = TestSuiteBase.CreateSyncAddRequest(this.LastSyncKey, this.User1Information.NotesCollectionId, noteData); SyncResponse syncResponse = this.Sync(syncRequest, false); Response.SyncCollectionsCollectionResponses responses = TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Responses) as Response.SyncCollectionsCollectionResponses; #endregion // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R941"); // Verify MS-ASCMD requirement: MS-ASCMD_R941 Site.CaptureRequirementIfAreEqual<string>( "Calendar", responses.Add[0].Class, 941, @"[In Class(Sync)] As a child element of the Add element in the Sync command response, the Class element<20> identifies the class of the item being added to the collection."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_9945"); // Verify MS-ASCMD requirement: MS-ASCMD_R9945 Site.CaptureRequirementIfAreEqual<string>( "Calendar", responses.Add[0].Class, 9945, @"[In Class(Sync)] In all contexts of a Sync command request or Sync command response, the valid Class element value is Calendar."); }
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.Categories3 categories = new Request.Categories3 { 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 }
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.Categories3 categories = new Request.Categories3 { 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 }