A static class contains all helper methods used in test cases.
        public void MSASNOTE_S03_TC02_ItemOperations_SchemaViewFetch()
        {
            #region Call method Sync to add a note to the server
            Dictionary <Request.ItemsChoiceType8, object> addElements = this.CreateNoteElements();
            this.SyncAdd(addElements, 1);
            #endregion

            #region Call method Search to search notes using the given keyword text

            // Search note from server
            SearchStore result = this.NOTEAdapter.Search(this.UserInformation.NotesCollectionId, addElements[Request.ItemsChoiceType8.Subject1].ToString(), true, 1);

            Site.Assert.AreEqual <int>(
                1,
                result.Results.Count,
                @"There should be only one note item returned in sync response.");

            #endregion

            #region Call method ItemOperations to fetch all the information about notes using longIds.
            // longIds:Long id of the created note item.
            List <string> longIds = new List <string> {
                result.Results[0].LongId
            };

            Request.BodyPreference bodyReference = new Request.BodyPreference {
                Type = 1
            };
            Request.Schema schema = new Request.Schema
            {
                ItemsElementName = new Request.ItemsChoiceType4[1],
                Items            = new object[] { new Request.Body() }
            };
            schema.ItemsElementName[0] = Request.ItemsChoiceType4.Body;

            // serverIds:null
            ItemOperationsRequest itemOperationRequest = TestSuiteHelper.CreateItemOperationsFetchRequest(null, null, longIds, bodyReference, schema);
            ItemOperationsStore   itemOperationsResult = this.NOTEAdapter.ItemOperations(itemOperationRequest);
            Site.Assert.IsNotNull(itemOperationsResult, "The ItemOperations result must not be null!");

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

            Site.Assert.IsNull(itemOperationsResult.Items[0].Note.Subject, "Subject should be null.");
            Site.Assert.IsNull(itemOperationsResult.Items[0].Note.MessageClass, "MessageClass should be null.");
            Site.Assert.IsNull(itemOperationsResult.Items[0].Note.Categories, "Categories should be null.");
            Site.Assert.IsFalse(itemOperationsResult.Items[0].Note.IsLastModifiedDateSpecified, "LastModifiedSpecified should not be present.");

            // Verify MS-ASNOTE requirement: MS-ASNOTE_R103
            Site.CaptureRequirementIfIsNotNull(
                itemOperationsResult.Items[0].Note.Body,
                103,
                @"[In ItemOperations Command Response] If an itemoperations:Schema element ([MS-ASCMD] section 2.2.3.145) is included in the ItemOperations command request, then the elements returned in the ItemOperations command response MUST be restricted to the elements that were included as child elements of the ItemOperations:Schema element in the command request.");

            #endregion
        }
예제 #2
0
        /// <summary>
        /// Call Sync command to fetch the change of the notes from previous syncKey
        /// </summary>
        /// <param name="syncKey">The sync key</param>
        /// <param name="bodyType">The type of the body</param>
        /// <returns>Return change result</returns>
        protected SyncStore SyncChanges(string syncKey, byte bodyType)
        {
            Request.BodyPreference bodyPreference = new Request.BodyPreference {
                Type = bodyType
            };

            SyncRequest syncRequest = TestSuiteHelper.CreateSyncRequest(syncKey, this.UserInformation.NotesCollectionId, bodyPreference);
            SyncStore   syncResult  = this.NOTEAdapter.Sync(syncRequest, true);

            return(syncResult);
        }
예제 #3
0
        /// <summary>
        /// Call Sync command to fetch all notes
        /// </summary>
        /// <param name="bodyType">The type of the body</param>
        /// <returns>Return change result</returns>
        protected SyncStore SyncChanges(byte bodyType)
        {
            SyncRequest syncInitialRequest = TestSuiteHelper.CreateInitialSyncRequest(this.UserInformation.NotesCollectionId);
            SyncStore   syncInitialResult  = this.NOTEAdapter.Sync(syncInitialRequest, false);

            // Verify sync change result
            this.Site.Assert.AreEqual <byte>(
                1,
                syncInitialResult.CollectionStatus,
                "The server returns a Status 1 in the Sync command response indicate sync command success.",
                syncInitialResult.Status);

            SyncStore syncResult = this.SyncChanges(syncInitialResult.SyncKey, bodyType);

            this.Site.Assert.AreEqual <byte>(
                1,
                syncResult.CollectionStatus,
                "The server should return a Status 1 in the Sync command response indicate sync command succeed.");

            this.Site.Assert.IsNotNull(
                syncResult.AddElements,
                "The server should return Add elements in response");

            Collection <Sync> expectedCommands = new Collection <Sync>();

            foreach (Sync sync in syncResult.AddElements)
            {
                this.Site.Assert.IsNotNull(
                    sync,
                    @"The Add element in response should not be null.");

                this.Site.Assert.IsNotNull(
                    sync.Note,
                    @"The note class in response should not be null.");

                if (this.ExistingNoteSubjects.Contains(sync.Note.Subject))
                {
                    expectedCommands.Add(sync);
                }
            }

            this.Site.Assert.AreEqual <int>(
                this.ExistingNoteSubjects.Count,
                expectedCommands.Count,
                @"The number of Add elements returned in response should be equal to the number of expected notes' subjects");

            syncResult.AddElements.Clear();
            foreach (Sync sync in expectedCommands)
            {
                syncResult.AddElements.Add(sync);
            }

            return(syncResult);
        }
예제 #4
0
        /// <summary>
        /// Call Sync command to delete a note
        /// </summary>
        /// <param name="syncKey">The sync key</param>
        /// <param name="serverId">The server id of the note, which is returned by server</param>
        /// <returns>Return the sync delete result</returns>
        private SyncStore SyncDelete(string syncKey, string serverId)
        {
            List <object> deleteData = new List <object> {
                new Request.SyncCollectionDelete {
                    ServerId = serverId
                }
            };
            SyncRequest syncRequest = TestSuiteHelper.CreateSyncRequest(syncKey, this.UserInformation.NotesCollectionId, deleteData);
            SyncStore   result      = this.NOTEAdapter.Sync(syncRequest, false);

            return(result);
        }
예제 #5
0
        public void MSASNOTE_S01_TC05_Sync_InvalidMessageClass()
        {
            #region Call method Sync to add a note to the server
            Dictionary <Request.ItemsChoiceType8, object> addElements = this.CreateNoteElements();
            addElements[Request.ItemsChoiceType8.MessageClass] = "IPM.invalidClass";
            SyncRequest syncRequest = TestSuiteHelper.CreateInitialSyncRequest(this.UserInformation.NotesCollectionId);
            SyncStore   syncResult  = this.NOTEAdapter.Sync(syncRequest, false);

            Site.Assert.AreEqual <byte>(
                1,
                syncResult.CollectionStatus,
                "The server should return a status code 1 in the Sync command response indicate sync command success.");

            List <object>             addData = new List <object>();
            Request.SyncCollectionAdd add     = new Request.SyncCollectionAdd
            {
                ClientId        = System.Guid.NewGuid().ToString(),
                ApplicationData = new Request.SyncCollectionAddApplicationData
                {
                    ItemsElementName = new Request.ItemsChoiceType8[addElements.Count],
                    Items            = new object[addElements.Count]
                }
            };

            addElements.Keys.CopyTo(add.ApplicationData.ItemsElementName, 0);
            addElements.Values.CopyTo(add.ApplicationData.Items, 0);
            addData.Add(add);

            syncRequest = TestSuiteHelper.CreateSyncRequest(syncResult.SyncKey, this.UserInformation.NotesCollectionId, addData);
            SyncStore addResult = this.NOTEAdapter.Sync(syncRequest, false);

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

            // Verify MS-ASNOTE requirement: MS-ASNOTE_R119
            Site.CaptureRequirementIfAreEqual <int>(
                6,
                int.Parse(addResult.AddResponses[0].Status),
                119,
                @"[In MessageClass Element] If a client submits a Sync command request ([MS-ASCMD] section 2.2.2.19) that contains a MessageClass element value that does not conform to the requirements specified in section 2.2.2.5, the server MUST respond with a Status element with a value of 6, as specified in [MS-ASCMD] section 2.2.3.162.16.");

            #endregion
        }
예제 #6
0
        /// <summary>
        /// Call Sync command to change a note
        /// </summary>
        /// <param name="syncKey">The sync key</param>
        /// <param name="serverId">The server Id of the note</param>
        /// <param name="changedElements">The changed elements of the note</param>
        /// <returns>Return the sync change result</returns>
        protected SyncStore SyncChange(string syncKey, string serverId, Dictionary <Request.ItemsChoiceType7, object> changedElements)
        {
            Request.SyncCollectionChange change = new Request.SyncCollectionChange
            {
                ServerId        = serverId,
                ApplicationData = new Request.SyncCollectionChangeApplicationData
                {
                    ItemsElementName = new Request.ItemsChoiceType7[changedElements.Count],
                    Items            = new object[changedElements.Count]
                }
            };

            changedElements.Keys.CopyTo(change.ApplicationData.ItemsElementName, 0);
            changedElements.Values.CopyTo(change.ApplicationData.Items, 0);

            List <object> changeData = new List <object> {
                change
            };
            SyncRequest syncRequest = TestSuiteHelper.CreateSyncRequest(syncKey, this.UserInformation.NotesCollectionId, changeData);

            return(this.NOTEAdapter.Sync(syncRequest, false));
        }
예제 #7
0
        /// <summary>
        /// Call Sync command to add a note
        /// </summary>
        /// <param name="addElements">The elements of a note item to be added</param>
        /// <param name="count">The number of the note</param>
        /// <returns>Return the sync add result</returns>
        protected SyncStore SyncAdd(Dictionary <Request.ItemsChoiceType8, object> addElements, int count)
        {
            SyncRequest syncRequest = TestSuiteHelper.CreateInitialSyncRequest(this.UserInformation.NotesCollectionId);
            SyncStore   syncResult  = this.NOTEAdapter.Sync(syncRequest, false);

            // Verify sync change result
            this.Site.Assert.AreEqual <byte>(
                1,
                syncResult.CollectionStatus,
                "The server should return a status code 1 in the Sync command response indicate sync command success.");

            List <object> addData = new List <object>();

            string[] subjects = new string[count];

            // Construct every note
            for (int i = 0; i < count; i++)
            {
                Request.SyncCollectionAdd add = new Request.SyncCollectionAdd
                {
                    ClientId        = System.Guid.NewGuid().ToString(),
                    ApplicationData = new Request.SyncCollectionAddApplicationData
                    {
                        ItemsElementName = new Request.ItemsChoiceType8[addElements.Count],
                        Items            = new object[addElements.Count]
                    }
                };

                // Since only one subject is generated in addElement, if there are multiple notes, generate unique subjects with index for every note.
                if (count > 1)
                {
                    addElements[Request.ItemsChoiceType8.Subject1] = Common.GenerateResourceName(this.Site, "subject", (uint)(i + 1));
                }

                subjects[i] = addElements[Request.ItemsChoiceType8.Subject1].ToString();
                addElements.Keys.CopyTo(add.ApplicationData.ItemsElementName, 0);
                addElements.Values.CopyTo(add.ApplicationData.Items, 0);
                addData.Add(add);
            }

            syncRequest = TestSuiteHelper.CreateSyncRequest(syncResult.SyncKey, this.UserInformation.NotesCollectionId, addData);
            SyncStore addResult = this.NOTEAdapter.Sync(syncRequest, false);

            this.Site.Assert.AreEqual <byte>(
                1,
                addResult.CollectionStatus,
                "The server should return a Status 1 in the Sync command response indicate sync command succeed.");

            this.Site.Assert.IsNotNull(
                addResult.AddResponses,
                @"The Add elements in Responses element of the Sync response should not be null.");

            this.Site.Assert.AreEqual <int>(
                count,
                addResult.AddResponses.Count,
                @"The actual number of note items should be returned in Sync response as the expected number.");

            for (int i = 0; i < count; i++)
            {
                this.Site.Assert.IsNotNull(
                    addResult.AddResponses[i],
                    @"The Add element in response should not be null.");

                this.Site.Assert.AreEqual <int>(
                    1,
                    int.Parse(addResult.AddResponses[i].Status),
                    "The server should return a Status 1 in the Sync command response indicate sync command succeed.");

                this.ExistingNoteSubjects.Add(subjects[i]);
            }

            return(addResult);
        }
예제 #8
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
        }
예제 #9
0
        public void MSASNOTE_S01_TC06_Sync_AddNote_WithBodyTypes()
        {
            #region Call method Sync to add a note to the server
            Dictionary <Request.ItemsChoiceType8, object> addElements = this.CreateNoteElements();
            this.SyncAdd(addElements, 1);

            #endregion

            #region Call method Sync to synchronize the note item with the server and expect to get the body of Type 1.
            SyncStore result = this.SyncChanges(1);

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

            Site.Assert.AreEqual <string>(
                ((Request.Body)addElements[Request.ItemsChoiceType8.Body]).Data,
                note.Body.Data,
                @"The content of body in response should be equal to that in request.");

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

            // Verify MS-ASNOTE requirement: MS-ASNOTE_R38
            // If the content of the body is the same in request and response and the type is 1, then MS-ASNOTE_R38 can be captured.
            Site.CaptureRequirementIfAreEqual <int>(
                1,
                note.Body.Type,
                38,
                @"[In Body] The value 1 means Plain text.");

            #endregion

            #region Call method Sync to synchronize the note item with the server and expect to get the body of Type 2.
            result = this.SyncChanges(2);

            note = result.AddElements[0].Note;

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

            bool isHTML = TestSuiteHelper.IsHTML(note.Body.Data);
            Site.Assert.IsTrue(
                isHTML,
                @"The content of body element in response should be in HTML format. Actual: {0}",
                isHTML);

            // Verify MS-ASNOTE requirement: MS-ASNOTE_R39
            // If the content of the body is in HTML format and the type is 2, then MS-ASNOTE_R39 can be captured.
            Site.CaptureRequirementIfAreEqual <int>(
                2,
                note.Body.Type,
                39,
                @"[In Body] The value 2 means HTML.");

            #endregion

            #region Call method Sync to synchronize the note item with the server and expect to get the body of Type 3.
            result = this.SyncChanges(3);

            note = result.AddElements[0].Note;

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

            try
            {
                byte[] contentBytes = Convert.FromBase64String(note.Body.Data);
                System.Text.Encoding.UTF8.GetString(contentBytes);
            }
            catch (FormatException formatException)
            {
                throw new FormatException("The content of body should be Base64 encoded", formatException);
            }

            // Verify MS-ASNOTE requirement: MS-ASNOTE_R40
            // If the content of the body is in Base64 format and the type is 3, then MS-ASNOTE_R40 can be captured.
            Site.CaptureRequirementIfAreEqual <int>(
                3,
                note.Body.Type,
                40,
                @"[In Body] The value 3 means Rich Text Format (RTF).");

            #endregion
        }
예제 #10
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
        }
예제 #11
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
        }
        public void MSASNOTE_S03_TC01_ItemOperations_GetZeroOrMoreNotes()
        {
            #region Call method Sync to add two notes to the server
            Dictionary <Request.ItemsChoiceType8, object> addElements = this.CreateNoteElements();
            this.SyncAdd(addElements, 2);
            #endregion

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

            #endregion

            #region Call method ItemOperations to fetch all the information about notes using ServerIds
            // serverIds:the server ids of two note items.
            List <string> serverIds = new List <string> {
                result.AddElements[0].ServerId, result.AddElements[1].ServerId
            };
            ItemOperationsRequest itemOperationRequest = TestSuiteHelper.CreateItemOperationsFetchRequest(this.UserInformation.NotesCollectionId, serverIds, null, null, null);
            ItemOperationsStore   itemOperationsResult = this.NOTEAdapter.ItemOperations(itemOperationRequest);

            Site.Assert.AreEqual <int>(
                2,
                itemOperationsResult.Items.Count,
                @"Two results should be returned in ItemOperations response.");

            Site.Assert.IsNotNull(
                itemOperationsResult.Items[0].Note,
                @"The first note class in ItemOperations response should not be null.");

            Site.Assert.IsNotNull(
                itemOperationsResult.Items[1].Note,
                @"The second note class in ItemOperations response should not be null.");

            #endregion

            #region Call method ItemOperations to fetch all the information about notes using a non-existing ServerIds
            serverIds.Clear();
            serverIds.Add(this.UserInformation.NotesCollectionId + ":notExisting");
            itemOperationRequest = TestSuiteHelper.CreateItemOperationsFetchRequest(this.UserInformation.NotesCollectionId, serverIds, null, null, null);
            itemOperationsResult = this.NOTEAdapter.ItemOperations(itemOperationRequest);

            Site.Assert.IsNull(
                itemOperationsResult.Items[0].Note,
                @"zero Notes class XML blocks is returned in its response");

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

            // Verify MS-ASNOTE requirement: MS-ASNOTE_R208
            // Server can return zero or more Notes class blocks which can be seen from two steps above.
            Site.CaptureRequirement(
                208,
                @"[In Abstract Data Model] The server returns a Notes class XML block for every note that matches the criteria specified by the client command request.");

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

            // Verify MS-ASNOTE requirement: MS-ASNOTE_R128
            // Server can return zero or more Notes class blocks which can be seen from two steps above.
            Site.CaptureRequirement(
                128,
                @"[In Abstract Data Model] The server can return zero or more Notes class XML blocks in its response, depending on how many notes match the criteria specified by the client command request.");

            #endregion
        }