Exemplo n.º 1
0
        public static void InitServiceClient <ServicePortClient, ServicePort>(this ServiceHolder <ServicePortClient, ServicePort> s, IEnumerable <IChannelController> controllers, BaseOnvifTest test, bool includeAddressController = false)
            where ServicePort : class
            where ServicePortClient : ClientBase <ServicePort>, ServicePort
        {
            bool found = false;

            if (!s.HasAddress)
            {
                s.Retrieve(test.Features);
                test.RunStep(() =>
                {
                    if (!s.HasAddress)
                    {
                        throw new AssertException(string.Format("{0} service not found", s.ServiceName));
                    }
                    else
                    {
                        found = true;
                        test.LogStepEvent(s.Address);
                    }
                },
                             string.Format("Get {0} service address", s.ServiceName), OnvifFaults.NoSuchService, true, true);
                test.DoRequestDelay();
            }

            test.Assert(found,
                        string.Format("{0} service address not found", s.ServiceName),
                        string.Format("Check that the DUT returned {0} service address", s.ServiceName));

            if (found)
            {
                var controller = new EndpointController(new EndpointAddress(s.Address));

                var ctrls = new List <IChannelController>();
                ctrls.Add(controller);
                ctrls.AddRange(controllers);

                Binding binding = test.CreateBinding(includeAddressController, ctrls);

                s.CreateClient(binding, test.AttachSecurity, test.SetupChannel);
            }
        }
Exemplo n.º 2
0
        void InitServiceClient(ServiceHolder serviceHolder, IEnumerable <IChannelController> controllers)
        {
            bool found = false;

            if (!serviceHolder.HasAddress)
            {
                RunStep(() =>
                {
                    serviceHolder.Retrieve(Features);
                    if (!serviceHolder.HasAddress)
                    {
                        throw new AssertException(string.Format("{0} service not found", serviceHolder.ServiceName));
                    }
                    else
                    {
                        found = true;
                        LogStepEvent(serviceHolder.Address);
                    }
                }, string.Format("Get {0} service address", serviceHolder.ServiceName));
                DoRequestDelay();
            }

            Assert(found,
                   string.Format("{0} service address not found", serviceHolder.ServiceName),
                   string.Format("Check that the DUT returned {0} service address", serviceHolder.ServiceName));

            EndpointController controller = new EndpointController(new EndpointAddress(serviceHolder.Address));

            List <IChannelController> ctrls = new List <IChannelController>();

            ctrls.Add(controller);
            ctrls.AddRange(controllers);

            Binding binding = CreateBinding(
                false,
                ctrls);

            serviceHolder.CreateClient(binding, AttachSecurity, SetupChannel);
        }