コード例 #1
0
        public void EnableDisableAccessPointTest()
        {
            RunTest(() =>
            {
                List <AccessPointInfo> aps = GetFullAccessPointInfoList();

                Action <string> disableAccessPoint =
                    new Action <string>(
                        (t) =>
                {
                    DisableAccessPoint(t);

                    AccessPointState actual = GetAccessPointState(t);

                    Assert(actual.Enabled == false,
                           "AccessPoint is enabled",
                           string.Format("Check that AccessPoint '{0}' is disabled", t));
                });

                Assert(aps.Any(e => null != e.Capabilities && e.Capabilities.DisableAccessPoint),
                       "There is no Access Points with DisableAccessPoint equal to true",
                       "Check there is Access Point with DisableAccessPoint equal to true");

                foreach (AccessPointInfo info in aps)
                {
                    Assert(info.Capabilities != null, "Capabilities field is null",
                           string.Format("Check that capabilities are present for AccessPoint '{0}'", info.token));

                    if (info.Capabilities.DisableAccessPoint)
                    {
                        string token = info.token;

                        AccessPointState state = GetAccessPointState(token);

                        bool enabled = state.Enabled;

                        bool initiallyEnabled = enabled;

                        if (initiallyEnabled)
                        {
                            disableAccessPoint(token);
                        }

                        EnableAccessPoint(token);

                        AccessPointState actualState = GetAccessPointState(token);

                        Assert(actualState.Enabled,
                               "AccessPoint is disabled",
                               string.Format("Check that AccessPoint '{0}' is enabled", token));

                        if (!initiallyEnabled)
                        {
                            disableAccessPoint(token);
                        }
                    }
                }
            });
        }
コード例 #2
0
        protected AccessPointState GetAccessPointState(string token, string stepName)
        {
            AccessPointState info = null;

            RunStep(() => { info = Client.GetAccessPointState(token); }, stepName);
            DoRequestDelay();
            return(info);
        }
コード例 #3
0
        public static AccessPointState GetAccessPointState(this IAccessControlService s, string Token)
        {
            s.InitializeGuard();

            AccessPointState r = null;

            s.Test.RunStep(() => r = s.ServiceClient.Port.GetAccessPointState(Token), "Get Access Point State");

            return(r);
        }
コード例 #4
0
        protected AccessPointState GetAccessPointState(string token)
        {
            PACSPortClient client = PACSPortClient;

            AccessPointState state = null;

            RunStep(
                () => { state = client.GetAccessPointState(token); },
                string.Format("Get AccessPoint state [token='{0}']", token));
            DoRequestDelay();
            return(state);
        }
コード例 #5
0
 public DoorOpenedNotificationHandler(
     AccessPointState state,
     ILEDService ledService,
     IBuzzerService buzzerService,
     IServiceEventClient serviceEventClient,
     ILogger <DoorOpenedNotificationHandler> logger)
 {
     _state              = state;
     _ledService         = ledService;
     _buzzerService      = buzzerService;
     _serviceEventClient = serviceEventClient;
     _logger             = logger;
 }
コード例 #6
0
 public LockCommandHandler(
     IMediator mediator,
     AccessPointState state,
     IRelayControlService relayControlService,
     IServiceEventClient serviceEventClient,
     ILEDService ledService,
     ILogger <LockCommandHandler> logger)
 {
     _mediator            = mediator;
     _state               = state;
     _relayControlService = relayControlService;
     _serviceEventClient  = serviceEventClient;
     _ledService          = ledService;
     _logger              = logger;
 }
コード例 #7
0
 public DoorClosedNotificationHandler(
     IMediator mediator,
     AccessPointState state,
     ILEDService ledService,
     IRelayControlService relayControlService,
     IServiceEventClient serviceEventClient,
     ILogger <DoorClosedNotificationHandler> logger)
 {
     _mediator            = mediator;
     _state               = state;
     _ledService          = ledService;
     _relayControlService = relayControlService;
     _serviceEventClient  = serviceEventClient;
     _logger              = logger;
 }
コード例 #8
0
 public OnTagReadNotificationHandler(
     IMediator mediator,
     AccessPointState state,
     ILEDService ledService,
     IBuzzerService buzzerService,
     IAuthorizationClient authorizationClient,
     ILogger <OnTagReadNotificationHandler> logger)
 {
     _mediator            = mediator;
     _state               = state;
     _ledService          = ledService;
     _buzzerService       = buzzerService;
     _authorizationClient = authorizationClient;
     _logger              = logger;
 }
コード例 #9
0
 public SetConfigurationCommandHandler(
     IMediator mediator,
     AccessPointState state,
     AccessPointContext accessPointContext,
     IRelayControlService relayControlService,
     IServiceEventClient serviceEventClient,
     ILEDService ledService)
 {
     _mediator           = mediator;
     _accessPointContext = accessPointContext;
     _state = state;
     _relayControlService = relayControlService;
     _serviceEventClient  = serviceEventClient;
     _ledService          = ledService;
 }
コード例 #10
0
        public void GetAccessPointStateTest()
        {
            RunTest(() =>
            {
                List <AccessPointInfo> aps = GetFullAccessPointInfoList();

                foreach (AccessPointInfo info in aps)
                {
                    AccessPointState state = GetAccessPointState(info.token);

                    if (info.Capabilities != null && info.Capabilities.DisableAccessPoint == false)
                    {
                        Assert(state.Enabled,
                               "State.Enabled is false",
                               "Check that State.Enabled is true when DisableAccessPoint capability is not supported");
                    }
                }
            });
        }
コード例 #11
0
 public GetAlarmStateQueryHandler(AccessPointState state)
 {
     _state = state;
 }
コード例 #12
0
 public GetConfigurationQueryHandler(AccessPointState state)
 {
     _state = state;
 }
コード例 #13
0
 public GetLockStateQueryHandler(AccessPointState state)
 {
     _state = state;
 }
コード例 #14
0
        public void AccessPointEnabledEventTest()
        {
            EndpointReferenceType subscriptionReference = null;

            System.DateTime subscribeStarted = System.DateTime.MaxValue;

            int timeout = 60;

            RunTest(
                () =>
            {
                // Topic for current test
                // tns1:AccessPoint/State/Enabled
                TopicInfo topicInfo = ConstructTopic(new string[] { "AccessPoint", "State", "Enabled" });

                //3.	Get complete list of access points from the DUT (see Annex A.1).
                List <AccessPointInfo> fullAccessPointsList = GetAccessPointInfoList();

                List <AccessPointInfo> accessPoints =
                    fullAccessPointsList.Where(A => A.Capabilities != null && A.Capabilities.DisableAccessPoint).ToList();

                //4.	ONVIF Client will invoke GetEventPropertiesRequest message to retrieve all events supported by the DUT.
                //5.	Verify the GetEventPropertiesResponse message from the DUT.
                //6.	Check if there is an event with Topic tns1:AccessControl/AccessPoint/Enabled. If there is no event with such Topic skip other steps, fail the test and go to the next test.
                // Get topic description from the DUT.
                XmlElement topicElement = GetTopicElement(topicInfo);

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

                //7.	Check that this event is a Property event (MessageDescription.IsProperty="true").
                //8.	Check that this event contains Source.SimpleItemDescription item with Name="AccessPointToken" and Type="pt:ReferenceToken".
                //9.	Check that this event contains Data.SimpleItemDescription item with Name="Enabled" and Type=" xs:boolean".
                //10.	Check that this event contains Data.SimpleItemDescription item with Name="Reason" and Type=" xs:string".

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

                FilterInfo filter = CreateFilter(topicInfo, messageDescription);

                //11.	ONVIF Client will invoke SubscribeRequest message with tns1:AccessControl/AccessPoint/Enabled Topic as Filter and an InitialTerminationTime of 60s to ensure that the SubscriptionManager is deleted after one minute.
                //12.	Verify that the DUT sends a SubscribeResponse message.

                //13.	Verify that DUT sends Notify message(s)

                Dictionary <NotificationMessageHolderType, XmlElement> notifications = new Dictionary <NotificationMessageHolderType, XmlElement>();

                subscriptionReference =
                    ReceiveMessages(filter.Filter,
                                    timeout,
                                    new Action(() => { }),
                                    fullAccessPointsList.Count,
                                    notifications,
                                    out subscribeStarted);

                //14.	Verify received Notify messages  (correct value for UTC time, TopicExpression and wsnt:Message).
                //15.	Verify that TopicExpression is equal to tns1:AccessControl/AccessPoint/Enabled
                // for all received Notify messages.
                //16.	Verify that each notification contains Source.SimpleItem item with Name="AccessPointToken"
                // and Value is equal to one of existing Access Point Tokens (e.g. complete list of access points contains Access Point with the same token). Verify that there are Notification messages for each Access Point.
                //17.	Verify that each notification contains Data.SimpleItem item with Name="Enabled" and
                // Value with type is equal to xs:boolean.
                //18.	Verify that each notification which contains Data.SimpleItem item with Name="Reason" contains
                // Value with type is equal to xs:string.
                //19.	Verify that Notify PropertyOperation="Initialized".

                ValidateMessages(notifications, topicInfo, OnvifMessage.INITIALIZED, accessPoints, ValidateAccessPointEnabledMessage);

                Dictionary <string, NotificationMessageHolderType> accessPointsMessages = new Dictionary <string, NotificationMessageHolderType>();
                ValidateMessagesSet(notifications.Keys, accessPoints, accessPointsMessages);

                //20.	ONVIF Client will invoke GetAccessPointStateRequest message for each Access Point
                // with corresponding tokens.
                //21.	Verify the GetAccessPointStateResponse messages from the DUT. Verify that Data.SimpleItem
                // item with Name="Enabled" from Notification message has the same value with Enabled elements
                // from corresponding GetAccessPointStateResponse messages for each AccessPoint.

                foreach (string accessPointToken in accessPointsMessages.Keys)
                {
                    AccessPointState state = GetAccessPointState(accessPointToken);

                    string expectedState = state.Enabled.ToString().ToLower();

                    XmlElement messageElement = accessPointsMessages[accessPointToken].Message;

                    // Simple Items must be OK by that moment
                    Dictionary <string, string> dataSimpleItems = messageElement.GetMessageDataSimpleItems();

                    string notificationState = dataSimpleItems["State"];

                    Assert(expectedState == notificationState,
                           string.Format("State is different ({0} in GetAccessPointStateResponse, {1} in Notification)", expectedState, notificationState),
                           "Check that state is the same in Notification and in GetAccessPointStateResponse");
                }
            },
                () =>
            {
                ReleaseSubscription(subscribeStarted, subscriptionReference, timeout);
            });
        }
コード例 #15
0
        public void AccessPointEnabledStateChangeEventTest()
        {
            List <EndpointReferenceType> subscriptionReferences = new List <EndpointReferenceType>();
            List <System.DateTime>       allSubscribeStarted    = new List <System.DateTime>();

            int timeout = 60;

            RunTest(
                () =>
            {
                // Topic for current test
                // tns1:AccessPoint/State/Enabled
                TopicInfo topicInfo = ConstructTopic(new string[] { "AccessPoint", "State", "Enabled" });

                TestTool.Proxies.Event.FilterType filter = CreateSubscriptionFilter(topicInfo);

                //3.	Get complete list of access points from the DUT (see Annex A.1).
                //4.	If Access Point with Token1 (Token1 is the first AccessPointInfo.token from the
                // complete list of access points at step 3) has AccessPointInfo.Capabilities.DisableAccessPoint
                // equal to false, then skip steps 7-18 and go to the step 19.

                List <AccessPointInfo> fullAccessPointsList = GetAccessPointInfoList();

                List <AccessPointInfo> accessPoints = fullAccessPointsList.Where(AP => AP.Capabilities.DisableAccessPoint).ToList();

                foreach (AccessPointInfo info in accessPoints)
                {
                    string accessPointToken = info.token;

                    //5.	ONVIF Client will invoke GetAccessPointStateRequest message (TokenList.Token = Token1,
                    // where Token1 is the first token from the complete list of access points at step 3) to
                    // retrieve Access Point state for specified token from the DUT.
                    //6.	Verify the GetAccessPointStateResponse message from the DUT.
                    AccessPointState state = GetAccessPointState(accessPointToken);

                    //7.	ONVIF Client will invoke SubscribeRequest message with tns1:AccessControl/AccessPoint/Enabled
                    // Topic as Filter and an InitialTerminationTime of 60s to ensure that the SubscriptionManager is
                    // deleted after one minute.
                    //8.	Verify that the DUT sends a SubscribeResponse message.



                    //9.	If Access Point with Token1 (Token1 is the first AccessPointInfo.token from the complete
                    // list of access points at step 3) has AccessPointState.Enabled equal to true, then skip steps
                    // 10-11 and go to the step 12.
                    //10.	ONVIF Client will invoke EnableAccessPointRequest message (Token = “Token1”, where Token1
                    // is the first AccessPointInfo.token from the complete list of access points at step 3) to try
                    // enabling access point.
                    //11.	Verify the EnableAccessPointResponse message from the DUT. Go to the step 13.
                    //12.	ONVIF Client will invoke DisableAccessPointRequest message (Token = “Token1”, where Token1
                    // is the first AccessPointInfo.token from the complete list of access points at step 3) to try
                    // disabling access point.
                    //13.	Verify the DisableAccessPointResponse message from the DUT.

                    Action eventInitiationAction = null;
                    if (state.Enabled)
                    {
                        eventInitiationAction = new Action(() => { DisableAccessPoint(accessPointToken); });
                    }
                    else
                    {
                        eventInitiationAction = new Action(() => { EnableAccessPoint(accessPointToken); });
                    }

                    //14.	Verify that DUT sends Notify message.
                    //15.	Verify received Notify messages (correct value for UTC time, TopicExpression and
                    // wsnt:Message).
                    //16.	Verify that TopicExpression is equal to tns1:AccessControl/AccessPoint/Enabled for all
                    // received Notify messages.
                    //17.	Verify that notification contains Source.SimpleItem item with Name="AccessPointToken" and
                    // Value= “Token1” (e.g. complete list of access points contains Access Point with the same token).
                    Dictionary <NotificationMessageHolderType, XmlElement> notifications = new Dictionary <NotificationMessageHolderType, XmlElement>();

                    System.DateTime subscribeStarted = System.DateTime.MaxValue;
                    int cnt = subscriptionReferences.Count;
                    subscriptionReferences.Add(null);
                    allSubscribeStarted.Add(subscribeStarted);
                    EndpointReferenceType subscriptionReference =
                        ReceiveMessages(filter,
                                        timeout,
                                        eventInitiationAction,
                                        1,
                                        (n) => CheckMessagePropertyOperation(n, OnvifMessage.CHANGED),
                                        notifications,
                                        out subscribeStarted);

                    subscriptionReferences[cnt] = subscriptionReference;
                    allSubscribeStarted[cnt]    = subscribeStarted;

                    ValidateMessages(notifications, topicInfo, info.token, ValidateAccessPointEnabledMessage);

                    //18.	Verify that notification contains Data.SimpleItem item with Name="Enabled" and Value with
                    // type is equal to xs:boolean and with value equal to current state of  Access Point.

                    // We ignore messages with property operation different from "Changed"
                    // And the only message expected in this case should be message for "our" AccessPoint
                    foreach (NotificationMessageHolderType message in notifications.Keys)
                    {
                        XmlElement messageElement = message.Message;

                        string expectedState = (!state.Enabled).ToString().ToLower();

                        XmlElement dataElement = messageElement.GetMessageData();
                        // SimpleItems must be OK by that moment
                        Dictionary <string, string> dataSimpleItems = dataElement.GetMessageDataSimpleItems();

                        string notificationState = dataSimpleItems["State"];

                        Assert(expectedState == notificationState,
                               string.Format("State is different ({0} in GetAccessPointStateResponse, {1} in Notification)", expectedState, notificationState),
                               "Check that state is the same in Notification and in GetAccessPointStateResponse");
                    }
                }

                //19.	Repeat steps 4-18 for all other tokens from complete list of access points at step 3.
            },
                () =>
            {
                for (int i = 0; i < subscriptionReferences.Count; i++)
                {
                    System.DateTime subscribeStarted            = allSubscribeStarted[i];
                    EndpointReferenceType subscriptionReference = subscriptionReferences[i];
                    ReleaseSubscription(subscribeStarted, subscriptionReference, timeout);
                }
            });
        }