Microsoft.Protocols.TestSuites.MS_OXCNOTIF.S02_SubscribeAndReceiveNotifications.MSOXCNOTIF_S02_TC05_VerifyCreateTableViewByTableSeekRowBookmark C# (CSharp) Method

MSOXCNOTIF_S02_TC05_VerifyCreateTableViewByTableSeekRowBookmark() private method

        public void MSOXCNOTIF_S02_TC05_VerifyCreateTableViewByTableSeekRowBookmark()
        {
            this.CheckWhetherSupportMAPIHTTP();
            this.NotificationInitialize();

            #region Open Inbox folder and get content table of the Inbox folder
            uint inboxTableHandle;
            this.OpenFolder(this.InboxFolderId, out inboxTableHandle);
            uint contentTableHandle;
            this.GetContentsTable(inboxTableHandle, out contentTableHandle, false);
            #endregion

            #region Create table view by SeekRowBookmark
            // The properties need to be set
            PropertyTag[] tags = new PropertyTag[]
            { 
                PropertyTags.All[PropertyNames.PidTagInstID], 
                PropertyTags.All[PropertyNames.PidTagImportance],
                PropertyTags.All[PropertyNames.PidTagInstanceNum],
                PropertyTags.All[PropertyNames.PidTagFolderId],
                PropertyTags.All[PropertyNames.PidTagMessageClass]
            };

            // Create table view by SeekRowBookmark
            this.SetColumns(contentTableHandle, tags);
            RopCreateBookmarkResponse bookmarkRsp = this.CreateBookmark(contentTableHandle);

            // Move the cursor to the position 2
            this.SeekRowBookmark(contentTableHandle, bookmarkRsp.Bookmark, 2);
            #endregion

            #region Trigger TableRowAdded event and get notification
            this.TriggerTableRowAddedEvent();
            IList<IDeserializable> rsp = this.CNOTIFAdapter.GetNotification(true);
            Site.Assert.IsTrue(rsp.Count > 0, "The response should contain notification message.");
            #endregion

            #region Verify table view is created by SeekRowBookmark
            foreach (IDeserializable response in rsp)
            {
                Site.Assert.IsTrue(response.GetType() == typeof(RopNotifyResponse) || response.GetType() == typeof(RopPendingResponse), "The ROP response type should be RopNotifyResponse or RopPendingResponse.");
                if (response is RopNotifyResponse)
                {
                    RopNotifyResponse notifyResponse = (RopNotifyResponse)response;
                    Site.Assert.AreEqual<NotificationType>(NotificationType.TableModified, notifyResponse.NotificationData.NotificationType, "The notification type for the RopNotify response should be TableModified.");
                    Site.Assert.AreEqual<EventTypeOfTable>(EventTypeOfTable.TableRowAdded, notifyResponse.NotificationData.TableEvent, "The table event type for the RopNotify response should be TableRowAdded.");
                    this.VerifyTableModifyNotificationFlag(notifyResponse);

                    // Only Exchange 2010 and above require a table view, this server version restrict is the same with MS-OXCNTOIF_R245.
                    if (Common.IsRequirementEnabled(245, this.Site))
                    {
                        // Add the debug information
                        Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCNOTIF_R255");

                        // If the server can return notification response, it can verify RopQueryRows create a table view. so the following requirements can be captured directly. 
                        Site.CaptureRequirement(
                            255,
                            @"[In Creating and Sending TableModified Event Notifications] If a table view is required on the server, the server MUST receive a request from one of the following ROPs, each of which cause a table view to be created on the server: RopSeekRowBookmark ([MS-OXCROPS] section 2.2.5.9)");

                        this.VerifyTableViewCreated();
                    }
                }
            }
            #endregion

            // Only Exchange 2010 and above will stop sending notifications if the RopResetTable ROP is received, until a new table view is created. 
            if (Common.IsRequirementEnabled(286, this.Site))
            {
                #region Reset the contents table
                this.ResetTable(contentTableHandle);
                #endregion

                #region Trigger ObjectDeleted event and get notification
                this.TriggerObjectDeletedEvent();

                // Trigger table event after ResetTable, server shouldn't send notification response on Exchange server 2010 and above
                rsp = this.CNOTIFAdapter.GetNotification(false);
                bool isServerCreateSubscription = false;
                foreach (IDeserializable response in rsp)
                {
                    Site.Assert.IsTrue(response.GetType() == typeof(RopNotifyResponse) || response.GetType() == typeof(RopPendingResponse), "The ROP response type should be RopNotifyResponse or RopPendingResponse.");
                    if (response is RopNotifyResponse)
                    {
                        isServerCreateSubscription = true;
                    }
                }

                Site.Assert.IsFalse(isServerCreateSubscription, "The server shouldn't send notify response when reset table");
                #endregion

                #region Create table view by SeekRowBookmark
                this.SetColumns(contentTableHandle, tags);
                this.CreateBookmark(contentTableHandle);

                // Move the cursor to the position 2
                this.SeekRowBookmark(contentTableHandle, bookmarkRsp.Bookmark, 2);
                #endregion

                #region Trigger tableRowModified event and get notification
                this.TriggerTableRowModifiedEvent();

                // Create table view by SeekRowBookmark after ResetTable, and trigger table event again the server should send notification response.
                rsp = this.CNOTIFAdapter.GetNotification(true);
                Site.Assert.IsTrue(rsp.Count > 0, "The response should contain notification message.");

                foreach (IDeserializable response in rsp)
                {
                    Site.Assert.IsTrue(response.GetType() == typeof(RopNotifyResponse) || response.GetType() == typeof(RopPendingResponse), "The ROP response type should be RopNotifyResponse or RopPendingResponse.");
                    if (response is RopNotifyResponse)
                    {
                        isServerCreateSubscription = true;
                    }
                }
                #endregion

                #region Verify notification response after reset Table and create table view by RopSeekRowBookmark
                // Since the server return the notification after a table view is created by RopSeekRowBookmark, this requirement can be verified.
                this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCNTOIF_R286: The implementation does return notifications after get RopSeekRowBookmark", isServerCreateSubscription ? string.Empty : "not");

                // Verify MS-OXCNOTIF requirement: MS-OXCNOTIF_R286
                bool isR286Satisfied = isServerCreateSubscription;

                Site.CaptureRequirementIfIsTrue(
                    isR286Satisfied,
                    286,
                    @"[In Appendix A: Product Behavior] The Implementation does stop sending notifications if the RopResetTable ROP ([MS-OXCROPS] section 2.2.5.15) is received, until a new table view is created using one of the following ROPs: RopSeekRowBookmark. (Exchange 2010 and above follow this behavior.)");
                #endregion
            }
        }
S02_SubscribeAndReceiveNotifications