Exemplo n.º 1
0
        public static void ReplacementMessageUsed()
        {
            string replacementEchoString = "bbbbb";
            var    inspector             = new MessageReplacingDispatchMessageInspector(replacementEchoString);
            var    behavior = new TestServiceBehavior {
                DispatchMessageInspector = inspector
            };
            var service = new DispatcherTestService();
            var factory = ExtensibilityHelper.CreateChannelFactory <DispatcherTestService, ISimpleService>(
                (services) =>
            {
                services.AddSingleton <IServiceBehavior>(behavior);
                services.AddSingleton(service);
            });

            factory.Open();
            var channel = factory.CreateChannel();
            var echo    = channel.Echo("hello");

            Assert.Equal(replacementEchoString, service.ReceivedEcho);
            Assert.Equal(replacementEchoString, echo);
            ((System.ServiceModel.Channels.IChannel)channel).Close();
            factory.Close();
            TestHelper.CloseServiceModelObjects((System.ServiceModel.Channels.IChannel)channel, factory);
        }
Exemplo n.º 2
0
        public static void ReplacementMessageUsed()
        {
            string replacementEchoString = "bbbbb";
            var    services  = new ServiceCollection();
            var    inspector = new MessageReplacingDispatchMessageInspector(replacementEchoString);
            var    behavior  = new TestServiceBehavior {
                DispatchMessageInspector = inspector
            };

            services.AddSingleton <IServiceBehavior>(behavior);
            var service = new DispatcherTestService();

            TestHelper.BuildDispatcherAndCallService(services, service);
            Assert.Equal(replacementEchoString, service.ReceivedEcho);
        }