void ConfigurationEventTestBis(
            TopicInfo topicInfo,
            Action <XmlElement, TopicInfo> validateTopic,
            ValidateConfigurationMessageFunction validateMessageFunction,
            string sourceTokenSimpleItem,
            Action <string> validateConfigurationFunction)
        {
            int actualTerminationTime = 60;

            if (_eventSubscriptionTimeout != 0)
            {
                actualTerminationTime = _eventSubscriptionTimeout;
            }
            int timeout = _operationDelay / 1000;

            RunTest(
                () =>
            {
                // Get topic description from the DUT.
                XmlElement topicElement = GetTopicElement(topicInfo);

                Assert(null != topicElement,
                       string.Format("Topic {0} not supported", topicInfo.GetDescription()),
                       "Check if the event topic is supported");

                XmlElement messageDescription = topicElement.GetMessageDescription();
                validateTopic(messageDescription, topicInfo);

                // filter for current test
                TestTool.Proxies.Event.FilterType filter = CreateSubscriptionFilter(topicInfo);

                string message = string.Format("{0}  event is expected!", topicInfo.GetDescription());
                bool UseNotify = UseNotifyToGetEvents;

                Dictionary <NotificationMessageHolderType, XmlElement> notifications = null;
                SubscriptionHandler Handler = null;
                try
                {
                    Handler = new SubscriptionHandler(this, UseNotify, GetEventServiceAddress());
                    Handler.Subscribe(filter, actualTerminationTime);

                    Operator.ShowMessage(message);

                    var pullingCondition = new SubscriptionHandler.WaitFirstNotificationPollingCondition(timeout);
                    Handler.WaitMessages(1, pullingCondition, out notifications);
                }
                finally
                {
                    Operator.HideMessage();
                    SubscriptionHandler.Unsubscribe(Handler);
                }
                Assert(null != notifications && notifications.Any(),
                       string.Format("No notification messages are received.{0}WARNING: may be Operation delay is too low", Environment.NewLine),
                       "Check that DUT sent any notification messages");
                Assert(notifications.Count == 1,
                       string.Format("{0} messages received - unable to check actual configuration", notifications.Count),
                       "Check that exactly one notification is received");

                BeginStep("Validate message");

                XmlNamespaceManager manager = CreateNamespaceManager(notifications.First().Value.OwnerDocument);
                StringBuilder logger        = new StringBuilder();
                bool ok = true;

                MessageCheckSettings settings = new MessageCheckSettings();
                settings.ExpectedTopic        = topicInfo;
                settings.RawMessageElements   = notifications;
                settings.NamespaceManager     = manager;

                NotificationMessageHolderType m = notifications.Keys.First();
                ok = validateMessageFunction(m, notifications[m], manager, logger);

                if (!ok)
                {
                    throw new AssertException(logger.ToStringTrimNewLine());
                }

                StepPassed();

                // validateMessageFunction should return false, if this simple item is missing
                string token = m.Message.GetMessageSourceSimpleItems()[sourceTokenSimpleItem];
                validateConfigurationFunction(token);
            },
                () =>
            {
            });
        }
        void CommonDoorPropertyEventStateChangeTestBis(Func <DoorInfo, bool> doorCapabilitiesTest,
                                                       TopicInfo topicInfo,
                                                       ValidateMessageFunction validateMessageFunction)
        {
            int actualTerminationTime = 60;

            if (_eventSubscriptionTimeout != 0)
            {
                actualTerminationTime = _eventSubscriptionTimeout;
            }
            int timeout = _operationDelay / 1000;

            RunTest(
                () =>
            {
                //3.	Get complete list of doors from the DUT (see Annex A.1).
                List <DoorInfo> fullDoorInfosList = GetDoorInfoList();

                //4.	Check that there is at least one Door with Capabilities.[CAPABILITIES FOR THE TEST]= “true”.
                // Otherwise skip other steps and go to the next test.
                List <DoorInfo> doorsList = null;
                if (doorCapabilitiesTest != null)
                {
                    doorsList = fullDoorInfosList.Where(A => doorCapabilitiesTest(A)).ToList();
                }
                else
                {
                    doorsList = fullDoorInfosList;
                }

                Assert(doorsList.Any(),
                       "No Doors with required Capabilities found, exit the test.",
                       "Check there is appropriate door for test");

                //5.	ONVIF Client will select one random Door (token = Token1) with
                // Capabilities.DoorMonitor= “true”.
                // ToDo: may be change it to really random selection
                DoorInfo selectedDoor = doorsList[0];

                // filter for current test
                Proxies.Event.FilterType filter = CreateSubscriptionFilter(topicInfo);

                //6.	ONVIF Client will invoke SubscribeRequest message with tns1:DoorControl/DoorPhysicalState Topic as Filter and an InitialTerminationTime of 60s to ensure that the SubscriptionManager is deleted after one minute.
                //7.	Verify that the DUT sends a SubscribeResponse message.
                //8.	Test Operator will invoke change of DoorPhysicalState property for Door with token = Token1.
                //9.	Verify that DUT sends Notify message.
                string message = string.Format("{0} event is expected \r\n for the Door with token={{0}}",
                                               topicInfo.GetDescription());

                DoorSelectionData data = new DoorSelectionData
                {
                    SelectedToken   = selectedDoor.token,
                    MessageTemplate = message,
                    Doors           = doorsList.Select(D => new DoorSelectionData.DoorShortInfo()
                    {
                        Token = D.token, Name = D.Name
                    }).ToList()
                };

                string Message = string.Format("{0} event is expected \r\n for the Door with token = '{1}'",
                                               topicInfo.GetDescription(), selectedDoor.token);

                bool UseNotify = UseNotifyToGetEvents;

                Dictionary <NotificationMessageHolderType, XmlElement> notifications = null;
                CurrentSubsciption = null;
                try
                {
                    CurrentSubsciption = new SubscriptionHandler(this, UseNotify, GetEventServiceAddress());
                    CurrentSubsciption.Subscribe(filter, actualTerminationTime);

                    Operator.ShowMessage(Message);
//                        Handler.WaitMessages(
//                            timeout,
//                            (n) => CheckMessagePropertyOperation(n, OnvifMessage.CHANGED),
//                            SubscriptionHandler.WaitCondition.WC_ALL,
//                            out notifications);
                    var pullingCondition = new SubscriptionHandler.WaitFirstNotificationPollingCondition(timeout)
                    {
                        Filter = msg => CheckMessagePropertyOperation(msg, OnvifMessage.CHANGED)
                    };
                    CurrentSubsciption.WaitMessages(1, pullingCondition, out notifications);
                }
                finally
                {
                    Operator.HideMessage();
                    UnsubscribeCurrentSubsciption();
                }

                Assert(null != notifications && notifications.Any(),
                       string.Format("Message with PropertyOperation='Changed' for the door with token='{0}' has not been received.{1}WARNING: may be Operation delay is too low",
                                     data.SelectedToken, Environment.NewLine),
                       "Check that the message for selected door has been received");


                //10.	Verify received Notify messages (correct value for UTC time, TopicExpression and
                // wsnt:Message).
                //11.	Verify that TopicExpression is equal to [TOPIC] for
                // received Notify message.
                //12.	Verify that notification contains Source.SimpleItem item with Name="DoorToken"
                // and Value= “Token1”.
                //13.	Verify that notification contains Data.SimpleItem item with Name=[ITEMNAME] and
                // Value with type is equal to [TYPE].

                BeginStep("Validate messages");

                XmlNamespaceManager manager = CreateNamespaceManager(notifications.First().Value.OwnerDocument);

                StringBuilder logger = new StringBuilder();
                bool ok = true;

                MessageCheckSettings settings = new MessageCheckSettings();
                settings.Data               = data.SelectedToken;
                settings.ExpectedTopic      = topicInfo;
                settings.RawMessageElements = notifications;
                settings.NamespaceManager   = manager;

                foreach (NotificationMessageHolderType m in notifications.Keys)
                {
                    bool local = validateMessageFunction(m, settings, logger);
                    ok         = ok && local;
                }
                if (!ok)
                {
                    throw new AssertException(logger.ToStringTrimNewLine());
                }

                StepPassed();
            },
                () =>
            {
                Operator.HideMessage();
                //Operator.HideDoorSelectionMessage();
            });
        }