public async Task Should_not_call_MutateOutgoing_when_hasOutgoingTransportMessageMutators_is_false() { var behavior = new MutateOutgoingTransportMessageBehavior(hasOutgoingTransportMessageMutators: false); var context = new TestableOutgoingPhysicalMessageContext(); var mutator = new MutatorThatIndicatesIfItWasCalled(); context.Builder.Register<IMutateOutgoingTransportMessages>(() => mutator); await behavior.Invoke(context, ctx => TaskEx.CompletedTask); Assert.IsFalse(mutator.MutateOutgoingCalled); }
public async Task Should_not_call_MutateOutgoing_when_hasOutgoingMessageMutators_is_false() { var behavior = new MutateOutgoingMessageBehavior(); var context = new TestableOutgoingLogicalMessageContext(); await behavior.Invoke(context, ctx => TaskEx.CompletedTask); var mutator = new MutatorThatIndicatesIfItWasCalled(); context.Builder.Register <IMutateOutgoingMessages>(() => mutator); await behavior.Invoke(context, ctx => TaskEx.CompletedTask); Assert.IsFalse(mutator.MutateOutgoingCalled); }
public async Task Should_not_call_MutateOutgoing_when_hasOutgoingMessageMutators_is_false() { var behavior = new MutateOutgoingMessageBehavior(new HashSet <IMutateOutgoingMessages>()); var context = new TestableOutgoingLogicalMessageContext(); await behavior.Invoke(context, ctx => Task.CompletedTask); var mutator = new MutatorThatIndicatesIfItWasCalled(); context.Services.AddTransient <IMutateOutgoingMessages>(sp => mutator); await behavior.Invoke(context, ctx => Task.CompletedTask); Assert.IsFalse(mutator.MutateOutgoingCalled); }
public async Task Should_invoke_all_explicit_mutators() { var mutator = new MutatorThatIndicatesIfItWasCalled(); var otherMutator = new MutatorThatIndicatesIfItWasCalled(); var behavior = new MutateOutgoingMessageBehavior(new HashSet <IMutateOutgoingMessages> { mutator, otherMutator }); var context = new TestableOutgoingLogicalMessageContext(); await behavior.Invoke(context, ctx => Task.CompletedTask); Assert.True(mutator.MutateOutgoingCalled); Assert.True(otherMutator.MutateOutgoingCalled); }
public async Task Should_not_call_MutateOutgoing_when_hasOutgoingTransportMessageMutators_is_false() { var behavior = new MutateOutgoingTransportMessageBehavior(new HashSet <IMutateOutgoingTransportMessages>()); var physicalContext = new TestableOutgoingPhysicalMessageContext(); physicalContext.Extensions.Set(new OutgoingLogicalMessage(typeof(FakeMessage), new FakeMessage())); await behavior.Invoke(physicalContext, ctx => Task.CompletedTask); var mutator = new MutatorThatIndicatesIfItWasCalled(); physicalContext.Services.AddTransient <IMutateOutgoingTransportMessages>(sp => mutator); await behavior.Invoke(physicalContext, ctx => Task.CompletedTask); Assert.IsFalse(mutator.MutateOutgoingCalled); }
public async Task Should_invoke_all_explicit_mutators() { var mutator = new MutatorThatIndicatesIfItWasCalled(); var otherMutator = new MutatorThatIndicatesIfItWasCalled(); var behavior = new MutateOutgoingTransportMessageBehavior(new HashSet <IMutateOutgoingTransportMessages> { mutator, otherMutator }); var physicalContext = new TestableOutgoingPhysicalMessageContext(); physicalContext.Extensions.Set(new OutgoingLogicalMessage(typeof(FakeMessage), new FakeMessage())); await behavior.Invoke(physicalContext, ctx => Task.CompletedTask); Assert.True(mutator.MutateOutgoingCalled); Assert.True(otherMutator.MutateOutgoingCalled); }
public async Task Should_invoke_both_explicit_and_container_provided_mutators() { var explicitMutator = new MutatorThatIndicatesIfItWasCalled(); var containerMutator = new MutatorThatIndicatesIfItWasCalled(); var behavior = new MutateOutgoingMessageBehavior(new HashSet <IMutateOutgoingMessages> { explicitMutator }); var context = new TestableOutgoingLogicalMessageContext(); context.Services.AddTransient <IMutateOutgoingMessages>(sp => containerMutator); await behavior.Invoke(context, ctx => Task.CompletedTask); Assert.True(explicitMutator.MutateOutgoingCalled); Assert.True(containerMutator.MutateOutgoingCalled); }
public async Task Should_invoke_both_explicit_and_container_provided_mutators() { var explicitMutator = new MutatorThatIndicatesIfItWasCalled(); var containerMutator = new MutatorThatIndicatesIfItWasCalled(); var behavior = new MutateIncomingTransportMessageBehavior(new HashSet <IMutateIncomingTransportMessages> { explicitMutator }); var context = new TestableIncomingPhysicalMessageContext(); context.Builder.Register <IMutateIncomingTransportMessages>(() => containerMutator); await behavior.Invoke(context, ctx => TaskEx.CompletedTask); Assert.True(explicitMutator.MutateIncomingCalled); Assert.True(containerMutator.MutateIncomingCalled); }
public async Task Should_invoke_both_explicit_and_container_provided_mutators() { var explicitMutator = new MutatorThatIndicatesIfItWasCalled(); var containerMutator = new MutatorThatIndicatesIfItWasCalled(); var behavior = new MutateOutgoingTransportMessageBehavior(new HashSet <IMutateOutgoingTransportMessages> { explicitMutator }); var physicalContext = new TestableOutgoingPhysicalMessageContext(); physicalContext.Extensions.Set(new OutgoingLogicalMessage(typeof(FakeMessage), new FakeMessage())); physicalContext.Builder.Register <IMutateOutgoingTransportMessages>(() => containerMutator); await behavior.Invoke(physicalContext, ctx => TaskEx.CompletedTask); Assert.True(explicitMutator.MutateOutgoingCalled); Assert.True(containerMutator.MutateOutgoingCalled); }