public async Task JaegerUdpBatcher_IntegrationTest() { var validJaegerThriftPayload = Convert.FromBase64String(TestPayloadBase64); var memoryTransport = new InMemoryTransport(); using var jaegerUdpBatcher = new JaegerUdpBatcher( new JaegerExporterOptions { MaxFlushInterval = TimeSpan.FromHours(1) }, memoryTransport); jaegerUdpBatcher.Process = TestProcess; await jaegerUdpBatcher.AppendAsync(CreateTestPayloadJaegerSpan(), CancellationToken.None).ConfigureAwait(false); await jaegerUdpBatcher.FlushAsync(CancellationToken.None).ConfigureAwait(false); Assert.Equal(Convert.ToBase64String(validJaegerThriftPayload), Convert.ToBase64String(memoryTransport.ToArray())); memoryTransport.Reset(); await jaegerUdpBatcher.AppendAsync(CreateTestPayloadJaegerSpan(), CancellationToken.None).ConfigureAwait(false); await jaegerUdpBatcher.FlushAsync(CancellationToken.None).ConfigureAwait(false); // SeqNo is the second byte. validJaegerThriftPayload[2]++; Assert.Equal(Convert.ToBase64String(validJaegerThriftPayload), Convert.ToBase64String(memoryTransport.ToArray())); }
public void to_in_memory() { var settings = InMemoryTransport.ToInMemory <NodeSettings>(); settings.Inbound.ShouldEqual(new Uri("memory://node/inbound")); settings.Outbound.ShouldEqual(new Uri("memory://node/outbound")); }
public void create_from_graph_and_run_through_the_channel() { using (var graph = new ChannelGraph()) { var node = graph.ChannelFor<BusSettings>(x => x.Outbound); node.Uri = new Uri("memory://foo"); var transport = new InMemoryTransport(); transport.OpenChannels(graph); node.Channel.ShouldNotBeNull(); var envelope = new Envelope(); envelope.CorrelationId = Guid.NewGuid().ToString(); envelope.Headers["Foo"] = "Bar"; envelope.Data = new byte[] { 1, 2, 3, 4, 5 }; var receiver = new RecordingReceiver(); node.StartReceiving(receiver); node.Channel.Send(envelope.Data, envelope.Headers); Wait.Until(() => receiver.Received.Any(), timeoutInMilliseconds: 2000); var received = receiver.Received.Single(); received.CorrelationId.ShouldEqual(envelope.CorrelationId); received.ContentType.ShouldEqual(envelope.ContentType); received.Data.ShouldEqual(envelope.Data); } }
public async Task Should_be_asynchronous() { var shutdown = new CancellationTokenSource(); var inputAddress = new Uri("loopback://localhost/input_queue"); var transport = new InMemoryTransport(inputAddress, Environment.ProcessorCount); TaskCompletionSource<int> received = GetTask<int>(); IPipe<ReceiveContext> receivePipe = Pipe.New<ReceiveContext>(x => { x.UseFilter(new DelegateFilter<ReceiveContext>(context => { Console.WriteLine("Message: {0}", context.TransportHeaders.Get("MessageId", "N/A")); received.TrySetResult(1); })); }); ReceiveTransportHandle receiveHandle = ((IReceiveTransport)transport).Start(receivePipe); var sendEndpoint = new SendEndpoint(transport, new JsonMessageSerializer(), inputAddress, inputAddress, new SendPipe(new MessageTypeSendFilter(), Pipe.Empty<SendContext>())); await sendEndpoint.Send(new A(), TestCancellationToken); await received.Task; shutdown.Cancel(); await receiveHandle.Stop(); }
private void AddToQueue <T>(InMemoryTransport src, string dest, T message, Stream stream = null, bool evenIfDisconnected = false) { //if destination is considered disconnected --> drop the message so it never arrives if (( _disconnectedNodes.Contains(dest) || _disconnectedNodesFromSending.Contains(src.From) ) && evenIfDisconnected == false) { return; } var newMessage = new InMemoryMessageContext(src) { Destination = dest, Message = message, Stream = stream }; _messageQueue.AddOrUpdate(dest, new BlockingCollection <MessageContext> { newMessage }, (destination, envelopes) => { envelopes.Add(newMessage); return(envelopes); }); }
internal void SpinUp() { if (!_registry.IsValueCreated) { return; } var registry = _registry.Value; var nodeName = ReflectionHelper.GetProperty(_expression).Name; registry.NodeName = nodeName; registry.Channel(_expression).ReadIncoming(new ThreadScheduler(2)); registry.Handlers.DisableDefaultHandlerSource(); registry.Handlers.Include <SourceRecordingHandler>(); registry.AlterSettings <TransportSettings>(x => x.DebugEnabled = true); var container = new Container(); // Make it all be var harnessSettings = InMemoryTransport.ToInMemory <HarnessSettings>(); container.Configure(x => { x.For <HarnessSettings>().Use(harnessSettings); x.For <IListener>().Add <MessageWatcher>(); //x.For<ILogListener>().Add(new ScenarioLogListener(nodeName)); }); _uri = (Uri)ReflectionHelper.GetAccessor(_expression).GetValue(harnessSettings); _runtime = FubuTransport.For(registry).StructureMap(container).Bootstrap(); _serviceBus = container.GetInstance <IServiceBus>(); }
public async void JaegerThriftIntegrationTest_TAbstractBaseGeneratesConsistentThriftPayload() { var validJaegerThriftPayload = Convert.FromBase64String("goEBCWVtaXRCYXRjaBwcGAx0ZXN0IHByb2Nlc3MZHBgQdGVzdF9wcm9jZXNzX3RhZxUAGAp0ZXN0X3ZhbHVlAAAZHBab5cuG2OehhdwBFuPakI2n2cCVLhbUpdv9yJDPo4EBFpjckNKFzqHOsgEYBE5hbWUZHBUAFpvly4bY56GF3AEW49qQjafZwJUuFpCmrOGWyrWcgwEAFQIWgICz3saWvwUWgJycORl8GAlzdHJpbmdLZXkVABgFdmFsdWUAGAdsb25nS2V5FQZGAgAYCGxvbmdLZXkyFQZGAgAYCWRvdWJsZUtleRUCJwAAAAAAAPA/ABgKZG91YmxlS2V5MhUCJwAAAAAAAPA/ABgHYm9vbEtleRUEMQAYCXNwYW4ua2luZBUAGAZjbGllbnQAGSwWgICz3saWvwUZLBgDa2V5FQAYBXZhbHVlABgHbWVzc2FnZRUAGAZFdmVudDEAABaAgLPexpa/BRksGANrZXkVABgFdmFsdWUAGAdtZXNzYWdlFQAYBkV2ZW50MgAAAAAA"); using (var memoryTransport = new InMemoryTransport()) { var protocolFactory = new TCompactProtocol.Factory(); var thriftClient = new JaegerThriftClient(protocolFactory.GetProtocol(memoryTransport)); var spanData = CreateTestSpan(); var span = spanData.ToJaegerSpan(); var process = new Process("test process", new Dictionary <string, object> { { "test_process_tag", "test_value" } }); var batch = new Batch(process, new List <JaegerSpan> { span }); await thriftClient.EmitBatchAsync(batch, CancellationToken.None); var buff = memoryTransport.GetBuffer(); // all parts except spanId match (we can't control/mock span-id generation) Assert.Equal(validJaegerThriftPayload.AsSpan().Slice(0, 89).ToArray(), buff.AsSpan().Slice(0, 89).ToArray()); Assert.Equal(validJaegerThriftPayload.AsSpan().Slice(98).ToArray(), buff.AsSpan().Slice(98).ToArray()); byte [] spanIdBytes = new byte[8]; spanData.Context.SpanId.CopyTo(spanIdBytes); Assert.Equal(span.SpanId, BitConverter.ToInt64(spanIdBytes, 0)); // TODO: validate spanId in thrift payload } }
public void the_expected_subscriptions() { var graph = container.GetInstance <ChannelGraph>(); var actual = container.GetAllInstances <ISubscriptionRequirement>() .SelectMany(x => x.DetermineRequirements()).ToArray(); var expected = new Subscription[] { new Subscription(typeof(Message1)) { NodeName = "SubscribedService", Receiver = InMemoryTransport.ReplyUriForGraph(graph), Source = theSettings.Outbound }, new Subscription(typeof(Message3)) { NodeName = "SubscribedService", Receiver = InMemoryTransport.ReplyUriForGraph(graph), Source = theSettings.Outbound }, new Subscription(typeof(Message2)) { NodeName = "SubscribedService", Receiver = theSettings.Inbound, Source = theSettings.Upstream }, new Subscription(typeof(Message4)) { NodeName = "SubscribedService", Receiver = theSettings.Inbound, Source = theSettings.Upstream }, }; actual.ShouldHaveTheSameElementsAs(expected); }
public async Task InMemoryTest() { var transport = new InMemoryTransport(Scheduler.Default); var binding = new JTokenJsonBinding(); var realm = "some.realm"; var router = new WampHost(); router.RegisterTransport(transport, new[] { binding }); router.Open(); var calleeConnection = transport.CreateClientConnection(binding, Scheduler.Default); WampChannelFactory factory = new WampChannelFactory(); var callee = factory.CreateChannel(realm, calleeConnection, binding); await callee.Open(); await callee.RealmProxy.Services.RegisterCallee(new WampTest()); var callerConnection = transport.CreateClientConnection(binding, Scheduler.Default); var caller = factory.CreateChannel(realm, callerConnection, binding); await caller.Open(); var proxy = caller.RealmProxy.Services.GetCalleeProxy <IWampTest>(); var result = await proxy.Echo("1"); Assert.That(result, Is.EqualTo("1")); await caller.Close(WampErrors.CloseNormal, new GoodbyeDetails()); await callee.Close(WampErrors.CloseNormal, new GoodbyeDetails()); router.Dispose(); }
public void SendTest() { using (var transport = new InMemoryTransport()) { var delivered1 = new ManualResetEvent(false); var delivered2 = new ManualResetEvent(false); IMessagingSession messagingSession = transport.CreateSession(null); messagingSession.Subscribe(TEST_TOPIC, (message, ack) => { delivered1.Set(); Console.WriteLine("subscription1: message:" + message.Type); }, typeof(byte[]).Name); messagingSession.Subscribe(TEST_TOPIC, (message, ack) => { delivered2.Set(); Console.WriteLine("subscription2: message:" + message.Type); }, typeof(byte[]).Name); messagingSession.Send(TEST_TOPIC, new BinaryMessage { Bytes = new byte[] { 0x0, 0x1, 0x2 }, Type = typeof(byte[]).Name }, 0); Assert.That(delivered1.WaitOne(1000), Is.True, "message was not delivered to all subscribers"); Assert.That(delivered2.WaitOne(1000), Is.True, "message was not delivered to all subscribers"); Thread.Sleep(1000); } }
public void create_from_graph_and_run_through_the_channel() { using (var graph = new ChannelGraph()) { var node = graph.ChannelFor <BusSettings>(x => x.Outbound); node.Uri = new Uri("memory://foo"); var transport = new InMemoryTransport(); transport.OpenChannels(graph); node.Channel.ShouldNotBeNull(); var envelope = new Envelope(); envelope.CorrelationId = Guid.NewGuid().ToString(); envelope.Headers["Foo"] = "Bar"; envelope.Data = new byte[] { 1, 2, 3, 4, 5 }; var receiver = new RecordingReceiver(); node.StartReceiving(receiver, new RecordingLogger()); node.Channel.Send(envelope.Data, envelope.Headers); Wait.Until(() => receiver.Received.Any(), timeoutInMilliseconds: 2000); var received = receiver.Received.Single(); received.CorrelationId.ShouldEqual(envelope.CorrelationId); received.ContentType.ShouldEqual(envelope.ContentType); received.Data.ShouldEqual(envelope.Data); } }
public void AcknowledgeTest() { var delivered1 = new ManualResetEvent(false); var delivered2 = new ManualResetEvent(false); bool processedOnce = false; using (var transport = new InMemoryTransport()) { IMessagingSession messagingSession = transport.CreateSession(null); messagingSession.Subscribe(TEST_TOPIC, (message, ack) => { var receivedGuid = new Guid(message.Bytes); Console.WriteLine("subscription1: message {0} of type {1}", receivedGuid, message.Type); if (!processedOnce) { Console.WriteLine("Unack for the first delivery"); processedOnce = true; ack(false); delivered1.Set(); return; } Console.WriteLine("Ack for the second delivery"); delivered2.Set(); }, typeof(byte[]).Name); var guid = Guid.NewGuid(); messagingSession.Send(TEST_TOPIC, new BinaryMessage { Bytes = guid.ToByteArray(), Type = typeof(byte[]).Name }, 0); Assert.That(delivered1.WaitOne(1000), Is.True, "message was not delivered"); Assert.That(delivered2.WaitOne(1000), Is.True, "message was not delivered redelivered on unack"); } }
public async Task Should_be_asynchronous() { var shutdown = new CancellationTokenSource(); var inputAddress = new Uri("loopback://localhost/input_queue"); var transport = new InMemoryTransport(inputAddress, Environment.ProcessorCount); TaskCompletionSource <int> received = GetTask <int>(); IPipe <ReceiveContext> receivePipe = Pipe.New <ReceiveContext>(x => { x.UseFilter(new DelegateFilter <ReceiveContext>(context => { Console.WriteLine("Message: {0}", context.TransportHeaders.Get("MessageId", "N/A")); received.TrySetResult(1); })); }); ReceiveTransportHandle receiveHandle = ((IReceiveTransport)transport).Start(receivePipe); var sendEndpoint = new SendEndpoint(transport, new JsonMessageSerializer(), inputAddress, inputAddress); await sendEndpoint.Send(new A(), TestCancellationToken); await received.Task; shutdown.Cancel(); await receiveHandle.Stop(); }
public async Task ProcessAsync_MultipleCommands_MultipleReturns() { var commandProcessor = Helpers.CreateDefaultCommandProcessor( containerBuilder => { containerBuilder.RegisterType <AsyncIntCommandHandler>().As <IAsyncCommandHandler <AsyncIntCommand, int> >(); containerBuilder.RegisterType <LongCommandHandler>().As <IAsyncCommandHandler <LongCommand, long> >(); }, autofacCommandsBuilder => { }); var inMemoryTransport = new InMemoryTransport(); var commandProcessorClient = new CommandProcessorClient(new InMemoryCommandTransportClient(inMemoryTransport)); var commandProcessorServer = new CommandProcessorServer(commandProcessor, new InMemoryCommandTransportServer(inMemoryTransport)); await commandProcessorServer.StartAsync(); const long input1 = 5; var result1 = await commandProcessorClient.ProcessAsync(new LongCommand(input1)); Assert.Equal(input1, result1); const int input2 = 2; var result2 = await commandProcessorClient.ProcessAsync(new AsyncIntCommand(input2)); Assert.Equal(input2, result2); await commandProcessorServer.StopAsync(); }
public void to_in_memory_with_default_settings() { FubuTransport.SetupForInMemoryTesting <DefaultSettings>(); using (var runtime = FubuTransport.For <DefaultRegistry>().StructureMap().Bootstrap()) { var settings = InMemoryTransport.ToInMemory <NodeSettings>(); settings.Inbound.ShouldEqual(new Uri("memory://default/inbound")); settings.Outbound.ShouldEqual(new Uri("memory://node/outbound")); } }
public void Describe(Description description) { description.Properties[nameof(Enabled)] = Enabled.ToString(); description.Properties["Debugging Tracing Enabled"] = DebugEnabled.ToString(); description.Properties[nameof(DelayMessagePolling)] = $"{DelayMessagePolling} ms"; description.Properties[nameof(ListenerCleanupPolling)] = $"{ListenerCleanupPolling} ms"; description.Properties[nameof(SubscriptionRefreshPolling)] = $"{SubscriptionRefreshPolling} ms"; description.Properties[nameof(InMemoryTransport)] = InMemoryTransport.ToString(); }
public void SetUp() { var container = new Container(); settings = InMemoryTransport.ToInMemory <HarnessSettings>(); container.Inject(settings); runtime = FubuTransport.For <RoutedRegistry>().StructureMap(container).Bootstrap(); theRouter = runtime.Factory.Get <ISubscriptionCache>(); }
public ITransport CreateTransportFor(string from) { InMemoryTransport value; if (_transports.TryGetValue(from, out value)) { return(value); } value = new InMemoryTransport(this, from); _transports[from] = value; return(value); }
/// <summary> /// Initializes a new instance of <see cref="InMemoryWampHost"/> given the /// <see cref="IWampRealmContainer"/> associated with this host. /// </summary> /// <param name="realmContainer"></param> /// <param name="uriValidator"></param> public InMemoryWampHost(IWampRealmContainer realmContainer, IWampUriValidator uriValidator) : base(realmContainer, uriValidator) { mInternalBinding = new InMemoryBinding(); mInternalTransport = new InMemoryTransport(Scheduler.Immediate); this.RegisterTransport (mInternalTransport, mInternalBinding); }
public ModifyingChannelRegistry() { ServiceBus.Enable(true); ServiceBus.EnableInMemoryTransport(); Services.ReplaceService(InMemoryTransport.ToInMemory <BusSettings>()); Channel(x => x.Downstream).ModifyWith <FooModifier>(); Channel(x => x.Upstream).ModifyWith(new BarModifier()); Channel(x => x.Outbound).ReadIncoming(); }
public void SetUp() { theLogger = new SagaLogger(); theContainer = new Container(x => { x.For <SagaSettings>().Use(InMemoryTransport.ToInMemory <SagaSettings>()); x.For <SagaLogger>().Use(theLogger); x.For <IListener>().Add <MessageWatcher>(); }); theRuntime = FubuTransport.For <SagaTestRegistry>().StructureMap(theContainer).Bootstrap(); MessageHistory.ClearAll(); }
public void Dispatcher() { List <byte[]> outputs = new List <byte[]>(); var inputs = new string[] { "A", "BB", "CCC", "DDDD" }; Func <byte[], string> decode = t => Encoding.ASCII.GetString(t); Func <string, byte[]> encode = s => Encoding.ASCII.GetBytes(s); var testMessages = inputs .Select(encode) .ToObservable(); var stringDispatcher = new StringDispatcher(); stringDispatcher.Outputs.Subscribe((m) => { Console.WriteLine("Received " + m); stringDispatcher.Inputs.Publish(m + "!"); }); var transport = new InMemoryTransport(testMessages); var byteRequests = transport.Publish(); // ensure all subscriptions are done before starting. // Get strings from bytes var stringRequest = byteRequests.Select(decode); // Consume strings stringDispatcher.Consume(stringRequest); // Do operations var results = stringDispatcher.Inputs.Select(s => s + "$"); // Get bytes from strings var byteResponses = results.Select(encode).Do(r => outputs.Add(r)); // transport consumes the byte outputs. byteResponses.Subscribe(transport.Publish); //Start the transport byteRequests.Connect(); Assert.AreEqual(inputs.Length, outputs.Count); for (int i = 0; i < outputs.Count; i++) { byte[] o = outputs[i]; Assert.AreEqual(inputs[i] + "!$", decode(o)); } }
public void UnsubscribeTest() { using (var transport = new InMemoryTransport()) { var ev = new AutoResetEvent(false); IMessagingSession messagingSession = transport.CreateSession(null); IDisposable subscription = messagingSession.Subscribe(TEST_TOPIC, (message, ack) => ev.Set(), null); messagingSession.Send(TEST_TOPIC, new BinaryMessage { Bytes = new byte[] { 0x0, 0x1, 0x2 }, Type = null }, 0); Assert.That(ev.WaitOne(500), Is.True, "Message was not delivered"); subscription.Dispose(); Assert.That(ev.WaitOne(500), Is.False, "Message was delivered for canceled subscription"); } }
public void SetUp() { var registry = new RoutedRegistry(); var container = new Container(); settings = InMemoryTransport.ToInMemory <HarnessSettings>(); container.Inject(settings); registry.StructureMap(container); runtime = registry.ToRuntime(); theRouter = runtime.Get <ISubscriptionCache>(); }
/// public InMemoryTestHarness(IEnumerable <IEventBusTransport> transports, IOptions <InMemoryTestHarnessOptions> optionsAccessor) { // Ensure we have the InMemoryTransport resolved if (transports is null) { throw new ArgumentNullException(nameof(transports)); } transport = transports.OfType <InMemoryTransport>().SingleOrDefault(); if (transport == null) { throw new ArgumentException("The InMemoryTransport must be added. Ensure 'services.AddInMemoryTransport()' has been called.", nameof(transport)); } options = optionsAccessor?.Value ?? throw new ArgumentNullException(nameof(optionsAccessor)); }
internal JaegerExporter(JaegerExporterOptions options, TTransport clientTransport = null) { Guard.Null(options, nameof(options)); this.maxPayloadSizeInBytes = (!options.MaxPayloadSizeInBytes.HasValue || options.MaxPayloadSizeInBytes <= 0) ? JaegerExporterOptions.DefaultMaxPayloadSizeInBytes : options.MaxPayloadSizeInBytes.Value; this.protocolFactory = new TCompactProtocol.Factory(); this.clientTransport = clientTransport ?? new JaegerThriftClientTransport(options.AgentHost, options.AgentPort); this.thriftClient = new JaegerThriftClient(this.protocolFactory.GetProtocol(this.clientTransport)); this.memoryTransport = new InMemoryTransport(16000); this.memoryProtocol = this.protocolFactory.GetProtocol(this.memoryTransport); string serviceName = (string)this.ParentProvider.GetDefaultResource().Attributes.Where( pair => pair.Key == ResourceSemanticConventions.AttributeServiceName).FirstOrDefault().Value; this.Process = new Process(serviceName); }
private bool disposedValue; // To detect redundant dispose calls internal JaegerExporter(JaegerExporterOptions options, TTransport clientTransport = null) { if (options is null) { throw new ArgumentNullException(nameof(options)); } this.maxPayloadSizeInBytes = (!options.MaxPayloadSizeInBytes.HasValue || options.MaxPayloadSizeInBytes <= 0) ? JaegerExporterOptions.DefaultMaxPayloadSizeInBytes : options.MaxPayloadSizeInBytes.Value; this.protocolFactory = new TCompactProtocol.Factory(); this.clientTransport = clientTransport ?? new JaegerThriftClientTransport(options.AgentHost, options.AgentPort); this.thriftClient = new JaegerThriftClient(this.protocolFactory.GetProtocol(this.clientTransport)); this.memoryTransport = new InMemoryTransport(16000); this.memoryProtocol = this.protocolFactory.GetProtocol(this.memoryTransport); this.Process = new Process(options.ServiceName, options.ProcessTags); }
public void SetUp() { theLogger = new SagaLogger(); theContainer = new Container(x => { x.For <SagaSettings>().Use(InMemoryTransport.ToInMemory <SagaSettings>()); x.For <SagaLogger>().Use(theLogger); }); var registry = new SagaTestRegistry(); registry.StructureMap(theContainer); registry.Mode = "testing"; theRuntime = registry.ToRuntime(); }
public void Describe(Description description) { description.Properties[nameof(Enabled)] = Enabled.ToString(); description.Properties["Debugging Tracing Enabled"] = DebugEnabled.ToString(); description.Properties[nameof(DelayMessagePolling)] = $"{DelayMessagePolling} ms"; description.Properties[nameof(ListenerCleanupPolling)] = $"{ListenerCleanupPolling} ms"; description.Properties[nameof(SubscriptionRefreshPolling)] = $"{SubscriptionRefreshPolling} ms"; description.Properties[nameof(InMemoryTransport)] = InMemoryTransport.ToString(); var jsonSettings = new Description(); description.Children["Json Serializer Settings"] = jsonSettings; jsonSettings.Properties[nameof(JsonMessageSerializerSettings.TypeNameHandling)] = JsonMessageSerializerSettings.TypeNameHandling.ToString(); jsonSettings.Properties[nameof(JsonMessageSerializerSettings.PreserveReferencesHandling)] = JsonMessageSerializerSettings.PreserveReferencesHandling.ToString(); jsonSettings.Properties[nameof(JsonMessageSerializerSettings.ReferenceLoopHandling)] = JsonMessageSerializerSettings.ReferenceLoopHandling.ToString(); }
public async Task JaegerThriftIntegrationTest_TAbstractBaseGeneratesConsistentThriftPayload() { var validJaegerThriftPayload = Convert.FromBase64String(TestPayloadBase64); using var memoryTransport = new InMemoryTransport(); var protocolFactory = new TCompactProtocol.Factory(); var thriftClient = new JaegerThriftClient(protocolFactory.GetProtocol(memoryTransport)); var spanData = CreateTestSpan(); var span = spanData.ToJaegerSpan(); var process = TestProcess; var batch = new Batch(process, new List <JaegerSpan> { span }); await thriftClient.EmitBatchAsync(batch, CancellationToken.None); Assert.Equal(validJaegerThriftPayload, memoryTransport.ToArray()); }
public async Task ProcessAsync_AsyncException_ThrowsException() { var commandProcessor = Helpers.CreateDefaultCommandProcessor( containerBuilder => { containerBuilder.RegisterType <AsyncExceptionCommandHandler>().As <IAsyncCommandHandler <AsyncExceptionCommand, Unit> >(); }, autofacCommandsBuilder => { }); var inMemoryTransport = new InMemoryTransport(); var commandProcessorClient = new CommandProcessorClient(new InMemoryCommandTransportClient(inMemoryTransport)); var commandProcessorServer = new CommandProcessorServer(commandProcessor, new InMemoryCommandTransportServer(inMemoryTransport)); await commandProcessorServer.StartAsync(); await Assert.ThrowsAsync <TestException>(async() => await commandProcessorClient.ProcessAsync(new AsyncExceptionCommand())); }
public void SetUp() { theGraph = new ChannelGraph { Name = "FooNode" }; var requirement = new LocalSubscriptionRequirement <BusSettings>(x => x.Upstream); requirement.AddType(typeof(FooMessage)); requirement.AddType(typeof(BarMessage)); theLocalReplyUri = InMemoryTransport.ReplyUriForGraph(theGraph); theGraph.AddReplyChannel("Fake2", "fake2://2".ToUri()); theGraph.AddReplyChannel(InMemoryChannel.Protocol, theLocalReplyUri); theGraph.AddReplyChannel("Fake1", "fake1://1".ToUri()); theSubscriptions = requirement.Determine(theSettings, theGraph); }
public void can_be_used_after_clearing_all_messages() { using (var graph = new ChannelGraph()) { var node = graph.ChannelFor<BusSettings>(x => x.Outbound); node.Uri = new Uri("memory://foo"); var transport = new InMemoryTransport(); transport.OpenChannels(graph); var receiver = new RecordingReceiver(); node.StartReceiving(receiver); node.Channel.Send(new byte[] { 1, 2 }, new NameValueHeaders()); transport.ClearAll(); node.Channel.Send(new byte[] { 3, 4 }, new NameValueHeaders()); Wait.Until(() => receiver.Received.Count == 2); receiver.Received.ShouldHaveCount(2); } }