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); }
public static void MessageInspectorCalled() { var services = new ServiceCollection(); var inspector = new TestDispatchMessageInspector(); var behavior = new TestServiceBehavior { DispatchMessageInspector = inspector }; services.AddSingleton <IServiceBehavior>(behavior); TestHelper.BuildDispatcherAndCallDefaultService(services); Assert.True(inspector.AfterReceiveCalled); Assert.True(inspector.BeforeSendCalled); Assert.True(inspector.CorrelationStateMatch); }
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); }
public void InstanceProviderReleaseCalledWithCorrectObjectTest() { var instanceProvider = new TestInstanceProvider(); var behavior = new TestServiceBehavior { InstanceProvider = instanceProvider }; var factory = ExtensibilityHelper.CreateChannelFactory <SimpleService, ISimpleService>(behavior); factory.Open(); var channel = factory.CreateChannel(); var echo = channel.Echo("hello"); Assert.Equal("hello", echo); Assert.True(instanceProvider.InstanceHashCode > 0);; Assert.True(instanceProvider.ReleasedInstanceHashCode == instanceProvider.InstanceHashCode); ((System.ServiceModel.Channels.IChannel)channel).Close(); factory.Close(); TestHelper.CloseServiceModelObjects((System.ServiceModel.Channels.IChannel)channel, factory); }
public void InstanceProviderCalledTest() { var instanceProvider = new TestInstanceProvider(); var behavior = new TestServiceBehavior { InstanceProvider = instanceProvider }; var factory = ExtensibilityHelper.CreateChannelFactory <SimpleService, ISimpleService>(behavior); factory.Open(); var channel = factory.CreateChannel(); var echo = channel.Echo("hello"); Assert.Equal("hello", echo); Assert.Equal(1, instanceProvider.GetInstanceCallCount); Assert.Equal(1, instanceProvider.ReleaseInstanceCallCount); ((System.ServiceModel.Channels.IChannel)channel).Close(); factory.Close(); TestHelper.CloseServiceModelObjects((System.ServiceModel.Channels.IChannel)channel, factory); }
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); }
public static void MessageInspectorCalled() { var inspector = new TestDispatchMessageInspector(); var behavior = new TestServiceBehavior { DispatchMessageInspector = inspector }; var factory = ExtensibilityHelper.CreateChannelFactory <SimpleService, ISimpleService>(behavior); factory.Open(); var channel = factory.CreateChannel(); var echo = channel.Echo("hello"); Assert.Equal("hello", echo); Assert.True(inspector.AfterReceiveCalled); Assert.True(inspector.BeforeSendCalled); Assert.True(inspector.CorrelationStateMatch); ((System.ServiceModel.Channels.IChannel)channel).Close(); factory.Close(); TestHelper.CloseServiceModelObjects((System.ServiceModel.Channels.IChannel)channel, factory); }
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); }
public TestOperationBehavior(TestServiceBehavior testServiceBehavior) { _parent = testServiceBehavior; }