CombineChangeAndAddNoteElements() статический приватный Метод

Combines the to-be-changed elements with the added elements to form a dictionary of changed elements for the note
static private CombineChangeAndAddNoteElements ( object>.Dictionary addElements, object>.Dictionary changeElements ) : object>.Dictionary
addElements object>.Dictionary All the elements of the created note
changeElements object>.Dictionary The to-be-changed elements of the note
Результат object>.Dictionary
Пример #1
0
        public void MSASNOTE_S01_TC03_Sync_LastModifiedDateIgnored()
        {
            #region Call method Sync to add a note to the server
            Dictionary <Request.ItemsChoiceType8, object> addElements = this.CreateNoteElements();
            string lastModifiedDate = DateTime.UtcNow.ToString("yyyyMMddTHHmmssZ", CultureInfo.InvariantCulture);
            addElements.Add(Request.ItemsChoiceType8.LastModifiedDate, lastModifiedDate);
            System.Threading.Thread.Sleep(1000);
            SyncStore addResult = this.SyncAdd(addElements, 1);
            Response.SyncCollectionsCollectionResponsesAdd item = addResult.AddResponses[0];
            #endregion

            #region Call method Sync to synchronize the note item with the server.
            SyncStore result = this.SyncChanges(1);

            Note note = null;

            for (int i = 0; i < result.AddElements.Count; i++)
            {
                if (addResult.AddElements != null && addResult.AddElements.Count > 0)
                {
                    if (result.AddElements[i].ServerId.Equals(addResult.AddElements[0].ServerId))
                    {
                        note = result.AddElements[i].Note;
                        break;
                    }
                }
                else if (addResult.AddResponses != null && addResult.AddResponses.Count > 0)
                {
                    if (result.AddElements[i].ServerId.Equals(addResult.AddResponses[0].ServerId))
                    {
                        note = result.AddElements[i].Note;
                        break;
                    }
                }
            }
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASNOTE_R84");

            // Verify MS-ASNOTE requirement: MS-ASNOTE_R84
            Site.CaptureRequirementIfAreNotEqual <string>(
                lastModifiedDate,
                note.LastModifiedDate.ToString("yyyyMMddTHHmmssZ", CultureInfo.InvariantCulture),
                84,
                @"[In LastModifiedDate Element] If it is included in a Sync command request, the server will ignore it.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASNOTE_R209");

            // Verify MS-ASNOTE requirement: MS-ASNOTE_R209
            // this requirement can be captured directly after MS-ASNOTE_R84.
            Site.CaptureRequirement(
                209,
                @"[In LastModifiedDate Element] If a Sync command request includes the LastModifiedDate element, the server ignores the element and returns the actual time that the note was last modified.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASNOTE_R126");

            bool isVerifiedR126 = note.Body != null && note.Subject != null && note.MessageClass != null && note.IsLastModifiedDateSpecified && note.Categories != null && note.Categories.Category != null;

            // Verify MS-ASNOTE requirement: MS-ASNOTE_R126
            Site.CaptureRequirementIfIsTrue(
                isVerifiedR126,
                126,
                @"[In Sync Command Response] Any of the elements for the Notes class[airsyncbase:Body, Subject, MessageClass, LastModifiedDate, Categories or Category], as specified in section 2.2.2, can be included in a Sync command response as child elements of the airsync:ApplicationData element ([MS-ASCMD] section 2.2.3.11) within [either] an airsync:Add element ([MS-ASCMD] section 2.2.3.7.2) [or an airsync:Change element ([MS-ASCMD] section 2.2.3.24)].");

            #endregion

            #region Call method Sync to only change the note's LastModifiedDate element, the server will ignore the change, and the note item should be unchanged.
            // changeElements: Change the note's LastModifiedDate by replacing its LastModifiedDate with a new LastModifiedDate.
            Dictionary <Request.ItemsChoiceType7, object> changeElements = new Dictionary <Request.ItemsChoiceType7, object>();
            lastModifiedDate = DateTime.UtcNow.ToString("yyyyMMddTHHmmssZ", CultureInfo.InvariantCulture);
            changeElements.Add(Request.ItemsChoiceType7.LastModifiedDate, lastModifiedDate);
            this.SyncChange(result.SyncKey, item.ServerId, changeElements);

            #endregion

            #region Call method Sync to synchronize the changes with the server.

            SyncStore result2 = this.SyncChanges(result.SyncKey, 1);

            bool isNoteFound;
            if (result2.ChangeElements != null)
            {
                isNoteFound = TestSuiteHelper.CheckSyncChangeCommands(result, addElements[Request.ItemsChoiceType8.Subject1].ToString(), this.Site);

                Site.Assert.IsFalse(isNoteFound, "The note with subject:{0} should not be returned in Sync command response.", addElements[Request.ItemsChoiceType8.Subject1].ToString());
            }
            else
            {
                Site.Log.Add(LogEntryKind.Debug, @"The Change elements are null.");
            }
            #endregion

            #region Call method Sync to change the note's LastModifiedDate and subject.
            // changeElements: Change the note's LastModifiedDate by replacing its LastModifiedDate with a new LastModifiedDate.
            // changeElements: Change the note's subject by replacing its subject with a new subject.
            changeElements   = new Dictionary <Request.ItemsChoiceType7, object>();
            lastModifiedDate = DateTime.UtcNow.ToString("yyyyMMddTHHmmssZ", CultureInfo.InvariantCulture);
            changeElements.Add(Request.ItemsChoiceType7.LastModifiedDate, lastModifiedDate);
            string changedSubject = Common.GenerateResourceName(Site, "subject");
            changeElements.Add(Request.ItemsChoiceType7.Subject1, changedSubject);
            changeElements = TestSuiteHelper.CombineChangeAndAddNoteElements(addElements, changeElements);
            this.SyncChange(result.SyncKey, item.ServerId, changeElements);

            #endregion

            #region Call method Sync to synchronize the note item with the server.

            result = this.SyncChanges(result.SyncKey, 1);

            isNoteFound = TestSuiteHelper.CheckSyncChangeCommands(result, changeElements[Request.ItemsChoiceType7.Subject1].ToString(), this.Site);

            Site.Assert.IsTrue(isNoteFound, "The note with subject:{0} should be returned in Sync command response.", changeElements[Request.ItemsChoiceType7.Subject1].ToString());

            // The subject of the note is updated.
            this.ExistingNoteSubjects.Remove(addElements[Request.ItemsChoiceType8.Subject1].ToString());
            this.ExistingNoteSubjects.Add(changeElements[Request.ItemsChoiceType7.Subject1].ToString());

            note = result.ChangeElements[0].Note;

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASNOTE_R210");

            bool isVerifiedR210 = note.Body != null && note.Subject != null && note.MessageClass != null && note.IsLastModifiedDateSpecified && note.Categories != null && note.Categories.Category != null;

            // Verify MS-ASNOTE requirement: MS-ASNOTE_R210
            Site.CaptureRequirementIfIsTrue(
                isVerifiedR210,
                210,
                @"[In Sync Command Response] Any of the elements for the Notes class[airsyncbase:Body, Subject, MessageClass, LastModifiedDate, Categories or Category], as specified in section 2.2.2, can be included in a Sync command response as child elements of the airsync:ApplicationData element ([MS-ASCMD] section 2.2.3.11) within [either an airsync:Add element ([MS-ASCMD] section 2.2.3.7.2) or] an airsync:Change element ([MS-ASCMD] section 2.2.3.24).");

            Site.Assert.AreEqual <string>(
                changeElements[Request.ItemsChoiceType7.Subject1].ToString(),
                note.Subject,
                "The subject element in Change Command response should be the same with the changed value of subject in Change Command request.");

            #endregion
        }
Пример #2
0
        public void MSASNOTE_S01_TC02_Sync_ChangeNote_WithoutBodyInRequest()
        {
            #region Call method Sync to add a note to the server
            Dictionary <Request.ItemsChoiceType8, object> addElements = this.CreateNoteElements();
            addElements[Request.ItemsChoiceType8.Categories2] = new Request.Categories3();
            SyncStore addResult = this.SyncAdd(addElements, 1);
            Response.SyncCollectionsCollectionResponsesAdd item = addResult.AddResponses[0];
            #endregion

            #region Call method Sync to change the note's Subject and MessageClass elements.
            // changeElements:Change the note's subject by replacing its subject with a new subject.
            Dictionary <Request.ItemsChoiceType7, object> changeElements = new Dictionary <Request.ItemsChoiceType7, object>();
            string changedSubject = Common.GenerateResourceName(Site, "subject");
            changeElements.Add(Request.ItemsChoiceType7.Subject1, changedSubject);

            // changeElements:Change the note's MessageClass by replacing its MessageClass with a new MessageClass.
            changeElements.Add(Request.ItemsChoiceType7.MessageClass, "IPM.StickyNote.MSASNOTE");
            changeElements = TestSuiteHelper.CombineChangeAndAddNoteElements(addElements, changeElements);

            // changeElements:Remove the note's Body in change command
            changeElements.Remove(Request.ItemsChoiceType7.Body);
            SyncStore changeResult = this.SyncChange(addResult.SyncKey, item.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.");

            // The subject of the note is updated.
            this.ExistingNoteSubjects.Remove(addElements[Request.ItemsChoiceType8.Subject1].ToString());
            this.ExistingNoteSubjects.Add(changeElements[Request.ItemsChoiceType7.Subject1].ToString());
            #endregion

            #region Call method Sync to synchronize the note item with the server.
            // Synchronize the changes with server
            SyncStore result = this.SyncChanges(addResult.SyncKey, 1);

            bool isNoteFound = TestSuiteHelper.CheckSyncChangeCommands(result, changeElements[Request.ItemsChoiceType7.Subject1].ToString(), this.Site);

            Site.Assert.IsTrue(isNoteFound, "The note with subject:{0} should be returned in Sync command response.", changeElements[Request.ItemsChoiceType7.Subject1].ToString());

            Note note = result.ChangeElements[0].Note;

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASNOTE_R113");

            // Verify MS-ASNOTE requirement: MS-ASNOTE_R113
            Site.CaptureRequirementIfIsNotNull(
                note.Body,
                113,
                @"[In Sync Command Response] The absence of an airsyncbase:Body element (section 2.2.2.1) within an airsync:Change element is not to be interpreted as an implicit delete.");

            Site.Assert.AreEqual <string>(
                changeElements[Request.ItemsChoiceType7.Subject1].ToString(),
                note.Subject,
                "The subject element in Change Command response should be the same with the changed value of subject in Change Command request.");

            Site.Assert.AreEqual <string>(
                changeElements[Request.ItemsChoiceType7.MessageClass].ToString(),
                note.MessageClass,
                "The MessageClass element in Change Command response should be the same with the changed value of MessageClass in Change Command request.");

            #endregion
        }