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

This method is used to check the Sync Change commands.
static private CheckSyncChangeCommands ( SyncStore result, string subject, ITestSite site ) : bool
result Microsoft.Protocols.TestSuites.Common.DataStructures.SyncStore The sync result which is returned from server
subject string The expected note's subject
site ITestSite An instance of interface ITestSite which provides logging, assertions, and adapters for test code onto its execution context.
Результат bool
Пример #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_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
        }
Пример #3
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
        }