Beispiel #1
0
        public async Task RejectCallsInnerMessageRejectWhenRejectForwarderIsNull()
        {
            using var receiver           = new FakeReceiver();
            using var forwardingReceiver = new ForwardingReceiver("foo", receiver, rejectForwarder: null);
            using var message            = new FakeReceiverMessage("Hello, world!");

            var forwardingMessage = new ForwardingReceiverMessage(forwardingReceiver, message);

            await forwardingMessage.RejectAsync().ConfigureAwait(false);

            message.HandledBy.Should().Be(nameof(IReceiverMessage.RejectAsync));
        }
Beispiel #2
0
        public async Task RejectHandlesInnerMessageAccordingToRejectOutcomeWhenRejectForwarderIsNotNull(ForwardingOutcome outcome)
        {
            using var forwarder = new FakeSender();

            using var receiver           = new FakeReceiver();
            using var forwardingReceiver = new ForwardingReceiver("foo", receiver, rejectForwarder: forwarder, rejectOutcome: outcome);
            using var message            = new FakeReceiverMessage("Hello, world!");

            var forwardingMessage = new ForwardingReceiverMessage(forwardingReceiver, message);

            await forwardingMessage.RejectAsync().ConfigureAwait(false);

            message.HandledBy.Should().Be($"{outcome}Async");
        }
Beispiel #3
0
        public async Task RejectSendsMessageToRejectForwarderWhenRejectForwarderIsNotNull()
        {
            using var forwarder = new FakeSender();

            using var receiver           = new FakeReceiver();
            using var forwardingReceiver = new ForwardingReceiver("foo", receiver, rejectForwarder: forwarder);
            using var message            = new FakeReceiverMessage("Hello, world!");

            var forwardingMessage = new ForwardingReceiverMessage(forwardingReceiver, message);

            await forwardingMessage.RejectAsync().ConfigureAwait(false);

            forwarder.SentMessages.Should().ContainSingle();
            forwarder.SentMessages[0].StringPayload.Should().Be("Hello, world!");
        }