예제 #1
0
        public ITransport Create(string inputQueueAddress)
        {
            var transport = new InMemTransport(_network, inputQueueAddress);

            transport.Initialize();
            return(transport);
        }
예제 #2
0
        public async Task VeryBasicTransactionThing()
        {
            const string destinationQueueName = "another-queue";

            var network = new InMemNetwork();

            network.CreateQueue(destinationQueueName);

            var transport = new InMemTransport(network, "test-queue");

            transport.Initialize();

            using (var scope = new RebusTransactionScope())
            {
                var headers = new Dictionary <string, string> {
                    { Headers.MessageId, Guid.NewGuid().ToString() }
                };

                await transport.Send(
                    destinationAddress : destinationQueueName,
                    message : new TransportMessage(headers, new byte[] { 1, 2, 3 }),
                    context : scope.TransactionContext
                    );

                Assert.That(network.Count(destinationQueueName), Is.EqualTo(0),
                            $"Expected ZERO messages in queue '{destinationQueueName}' at this point, because the scope was not completed");

                await scope.CompleteAsync();
            }

            Assert.That(network.Count(destinationQueueName), Is.EqualTo(1),
                        $"Expected 1 message in queue '{destinationQueueName}' at this point, because the scope is completed now");
        }