Exemple #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);
            }
        }
Exemple #2
0
        public void InitServiceClient(IEnumerable <IChannelController> controllers, bool includeAddressController = false)
        {
            bool found = false;

            if (string.IsNullOrEmpty(ServiceAddress))
            {
                ServiceAddress = ServiceAddressRetrievalAction(Test.Features);
                Test.RunStep(() =>
                {
                    //Failed to retrive service's address
                    if (string.IsNullOrEmpty(ServiceAddress))
                    {
                        throw new AssertException(string.Format("{0} service not found", ServiceName));
                    }
                    else
                    {
                        found = true;
                        Test.LogStepEvent(ServiceAddress);
                    }
                },
                             string.Format("Get {0} service address", ServiceName), OnvifFaults.NoSuchService, true, true);
                Test.DoRequestDelay();
            }

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

            if (found)
            {
                var controller = new EndpointController(new EndpointAddress(ServiceAddress));

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

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

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