Esempio n. 1
0
        public static void OperationInvokerCalled()
        {
            TestDispatchOperationInvoker.ClearCounts();
            var behavior = new TestServiceBehavior {
                OperationInvokerFactory = TestDispatchOperationInvoker.Create
            };
            var factory = ExtensibilityHelper.CreateChannelFactory <SimpleService, ISimpleService>(behavior);

            factory.Open();
            var channel = factory.CreateChannel();

            ((System.ServiceModel.Channels.IChannel)channel).Open();
            var echo = channel.Echo("hello");

            Assert.Equal("hello", echo);
            Assert.Equal(1, TestDispatchOperationInvoker.InvokeCount);
            ((System.ServiceModel.Channels.IChannel)channel).Close();
            factory.Close();
            TestHelper.CloseServiceModelObjects((System.ServiceModel.Channels.IChannel)channel, factory);
        }
Esempio n. 2
0
        public static void OperationInvokerCalledMultiple()
        {
            TestDispatchOperationInvoker.ClearCounts();
            var behavior = new TestServiceBehavior {
                OperationInvokerFactory = TestDispatchOperationInvoker.Create
            };

            System.ServiceModel.ChannelFactory <ISimpleService> factory = ExtensibilityHelper.CreateChannelFactory <SimpleService, ISimpleService>(behavior);
            factory.Open();
            ISimpleService channel = factory.CreateChannel();

            ((System.ServiceModel.Channels.IChannel)channel).Open();
            foreach (int dummy in Enumerable.Range(0, 10))
            {
                string echo = channel.Echo("hello");
                Assert.Equal("hello", echo);
            }
            Assert.Equal(10, TestDispatchOperationInvoker.InvokeCount);
            Assert.Equal(1, TestDispatchOperationInvoker.InstanceCount);
            ((System.ServiceModel.Channels.IChannel)channel).Close();
            factory.Close();
            TestHelper.CloseServiceModelObjects((System.ServiceModel.Channels.IChannel)channel, factory);
        }