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

MSOXCNOTIF_S02_TC18_VerifyUbitAndTbit() private method

private MSOXCNOTIF_S02_TC18_VerifyUbitAndTbit ( ) : void
return void
        public void MSOXCNOTIF_S02_TC18_VerifyUbitAndTbit()
        {
            this.CheckWhetherSupportMAPIHTTP();
            this.NotificationInitialize();

            #region Subscribe ObjectModified event on server
            this.CNOTIFAdapter.RegisterNotification(NotificationType.ObjectModified);
            #endregion

            #region Trigger NewMail event and get notification
            // Trigger NewMailEvent to get mail modified information to get U bit and T bit notification flag.
            this.TriggerNewMailEvent();
            DateTime beginTime = DateTime.Now;
            DateTime endTime;
            int sleepTime = int.Parse(Common.GetConfigurationPropertyValue("SleepTime", this.Site));

            if (Common.GetConfigurationPropertyValue("TransportSeq", this.Site).ToLower() != "mapi_http")
            {
                // Do a loop to keep the connection and wait for the new mail being created on server.
                do
                {
                    this.CNOTIFAdapter.EcDoAsyncConnectEx();
                    System.Threading.Thread.Sleep(sleepTime);
                    endTime = DateTime.Now;
                }
                while ((endTime - beginTime) < TimeSpan.FromMilliseconds(sleepTime * 50));
            }

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

            #region Verify notification response elements
            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)(notifyResponse.NotificationData.NotificationFlags & 0x0FFF), NotificationType.ObjectModified, "The notification type should be ObjectModified.");
                    #region Verify elements TotalMessageCount and UnreadMessageCount of the notification response
                    if ((notifyResponse.NotificationData.NotificationFlags & (ushort)FlagsBit.T) == (ushort)FlagsBit.T)
                    {
                        // Add the debug information
                        this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCNOTIF_R20701");

                        // Verify MS-OXCNOTIF requirement: MS-OXCNOTIF_R20701
                        this.Site.CaptureRequirementIfIsNotNull(
                            notifyResponse.NotificationData.TotalMessageCount,
                            20701,
                            @"[In NotificationData Structure] This field [TotalMessageCount] is available if bit 0x1000 is set in the NotificationFlags field.");
                    }

                    if ((notifyResponse.NotificationData.NotificationFlags & (ushort)FlagsBit.U) == (ushort)FlagsBit.U)
                    {
                        // Add the debug information
                        this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCNOTIF_R21101");

                        // Verify MS-OXCNOTIF requirement: MS-OXCNOTIF_R21101
                        this.Site.CaptureRequirementIfIsNotNull(
                            notifyResponse.NotificationData.UnreadMessageCount,
                            21101,
                            @"[In NotificationData Structure] This field [UnreadMessageCount] is available if bit 0x2000 is set in the NotificationFlags field.");
                    }

                    if (notifyResponse.NotificationData.TotalMessageCount != null)
                    {
                        uint inboxTableHandle;
                        this.OpenFolder(this.InboxFolderId, out inboxTableHandle);
                        uint contentTableHandle;
                        RopGetContentsTableResponse getContentsTableResponse = this.GetContentsTable(inboxTableHandle, out contentTableHandle, false);

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

                        // Verify MS-OXCNOTIF requirement: MS-OXCNOTIF_R206
                        this.Site.CaptureRequirementIfAreEqual<uint?>(
                            getContentsTableResponse.RowCount,
                            notifyResponse.NotificationData.TotalMessageCount,
                            206,
                            @"[In NotificationData Structure] TotalMessageCount: An unsigned 32-bit integer that specifies the total number of items in the folder triggering this event.");
                    }

                    if (notifyResponse.NotificationData.UnreadMessageCount != null)
                    {
                        // Add the debug information
                        this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCNOTIF_R210");

                        // Verify MS-OXCNOTIF requirement: MS-OXCNOTIF_R210
                        // In TriggerNewMailEvent() method, 1 mail is created and unread. So if the value of UnreadMessageCount is 1, this requirement can be verified.
                        this.Site.CaptureRequirementIfAreEqual<uint?>(
                            1,
                            notifyResponse.NotificationData.UnreadMessageCount,
                            210,
                            @"[In NotificationData Structure] UnreadMessageCount: An unsigned 32-bit integer that specifies the number of unread items in a folder triggering this event.");
                    }
                    #endregion
                }
            }
            #endregion
        }
S02_SubscribeAndReceiveNotifications