public void Starting_a_socket_server() { TraceLogger.Configure(LogLevel.Debug); _startingEventReceived = new Future <ServerStarting>(); _runningEventReceived = new Future <ServerRunning>(); _input = new ChannelAdapter(); _connection = _input.Connect(x => { x.AddConsumerOf <ServerStarting>() .UsingConsumer(_startingEventReceived.Complete) .HandleOnCallingThread(); x.AddConsumerOf <ServerRunning>() .UsingConsumer(_runningEventReceived.Complete) .HandleOnCallingThread(); }); ServerUri = new Uri("http://localhost:8008/Topshelf"); _server = new HttpServer(ServerUri, new ThreadPoolFiber(), _input, new[] { new VersionConnectionHandler(), }); _server.Start(); }
public void A_command_line() { TraceLogger.Configure(LogLevel.Debug); CommandLineText = "-name:phatboyg -password:really_long_one --secure"; Elements = new MonadicCommandLineParser().Parse(CommandLineText); }
public void Sending_a_message_to_an_nhibernate_backed_state_machine() { TraceLogger.Configure(LogLevel.Debug); _newValue = new Random().Next(1, 500000) / 100m; using (ISession session = SessionFactory.OpenSession()) using (ITransaction transaction = session.BeginTransaction()) { session.CreateQuery("Delete TestStateMachineInstance").ExecuteUpdate(); transaction.Commit(); } var input = new ChannelAdapter(); using (input.Connect(x => { x.AddConsumersFor <TestStateMachineInstance>() .BindUsing <TestStateMachineInstanceBinding, int>() .HandleOnCallingThread() .CreateNewInstanceBy(id => new TestStateMachineInstance(id)) .PersistUsingNHibernate() .UseSessionProvider(() => SessionFactory.OpenSession()); })) { _networkTypes = input.Flatten().Select(c => c.GetType()); var future = new Future <int>(); TestStateMachineInstance.CompletedLatch = new CountdownLatch(1, future.Complete); // input.Send(new UpdateOrder { Id = 47 }); input.Send(new CreateOrder { Id = 27 }); input.Send(new UpdateOrder { Id = 27, Value = _newValue, }); input.Send(new CompleteOrder { Id = 27, }); future.WaitUntilCompleted(5.Seconds()).ShouldBeTrue(); } }
public void Sending_a_message_to_an_nhibernate_backed_state_machine() { TraceLogger.Configure(LogLevel.Debug); _newValue = new Random().Next(1, 500000) / 100m; var input = new ChannelAdapter(); using (input.Connect(x => { x.AddConsumersFor <TestStateMachineInstance>() .BindUsing <TestStateMachineInstanceBinding, int>() .HandleOnCallingThread() .CreateNewInstanceBy(id => new TestStateMachineInstance(id)) .PersistInMemoryUsing(_cache); })) { _networkTypes = input.Flatten().Select(c => c.GetType()); var future = new Future <int>(); TestStateMachineInstance.CompletedLatch = new CountdownLatch(1, future.Complete); // input.Send(new UpdateOrder { Id = 47, Value = _newValue, }); input.Send(new CreateOrder { Id = 27 }); input.Send(new UpdateOrder { Id = 27, Value = _newValue, }); input.Send(new CompleteOrder { Id = 27, }); future.WaitUntilCompleted(5.Seconds()).ShouldBeTrue(); } }
public void Should_result_in_no_waiting_actions_in_the_queue() { TraceLogger.Configure(LogLevel.Debug); Fiber fiber = new ThreadPoolFiber(); var called = new Future <bool>(); 10.Times(() => fiber.Add(() => Thread.Sleep(100))); fiber.Add(() => called.Complete(true)); Stopwatch timer = Stopwatch.StartNew(); fiber.Shutdown(8.Seconds()); timer.Stop(); called.IsCompleted.ShouldBeTrue(); timer.ElapsedMilliseconds.ShouldBeLessThan(2000); }
public void Should_properly_arrive_at_the_destination() { TraceLogger.Configure(LogLevel.Debug); _log = Logger.GetLogger <Sending_a_message_to_a_remote_channel_via_wcf>(); _log.Debug("Starting"); var serviceUri = new Uri("net.pipe://localhost/pipe"); string pipeName = "test"; var future = new Future <TestMessage>(); var message = new TestMessage { Id = Guid.NewGuid(), Name = "Alpha", }; UntypedChannel adapter = new ChannelAdapter(); using (var remote = new WcfChannelHost(new SynchronousFiber(), adapter, serviceUri, pipeName)) { _log.Debug("Remote channel adapter created"); using (adapter.Connect(x => { x.AddConsumerOf <TestMessage>() .UsingConsumer(m => future.Complete(m)); })) { var client = new WcfChannelProxy(new SynchronousFiber(), serviceUri, pipeName); _log.Debug("Client created"); client.Send(message); future.WaitUntilCompleted(2.Seconds()).ShouldBeTrue(); } } future.Value.ShouldNotBeNull(); future.Value.ShouldEqual(message); future.Value.ShouldNotBeTheSameAs(message); }
public void Starting_a_socket_server() { TraceLogger.Configure(LogLevel.Info); _startingEventReceived = new Future <ServerStarting>(); _runningEventReceived = new Future <ServerRunning>(); _input = new ChannelAdapter(); _connection = _input.Connect(x => { x.AddConsumerOf <ServerStarting>() .UsingConsumer(_startingEventReceived.Complete) .HandleOnCallingThread(); x.AddConsumerOf <ServerRunning>() .UsingConsumer(_runningEventReceived.Complete) .HandleOnCallingThread(); }); _uri = new Uri("tcp://0.0.0.0:8008"); _server = new SocketServer(_uri, new ThreadPoolFiber(), _input); _server.Start(); }
public void Should_property_adapt_itself_to_a_channel_network() { TraceLogger.Configure(LogLevel.Debug); ILogger log = Logger.GetLogger <Sending_a_message_through_a_wcf_channel>(); log.Debug("Starting"); var serviceUri = new Uri("net.pipe://localhost/Pipe"); string pipeName = "Test"; Channel <TestMessage> adapter = new ChannelAdapter <TestMessage>(); using (var host = new WcfChannelHost <TestMessage>(adapter, serviceUri, pipeName)) { log.Debug("Host started"); var future = new Future <TestMessage>(); using (adapter.Connect(x => { x.AddConsumer(m => { log.Debug(l => l.Write("Received: {0}", m.Value)); future.Complete(m); }); })) { var client = new WcfChannelProxy <TestMessage>(new SynchronousFiber(), serviceUri, pipeName); log.Debug("Client started"); client.Send(new TestMessage("Hello!")); future.WaitUntilCompleted(2.Seconds()).ShouldBeTrue(); log.Debug("Complete"); } } }
public void Configuration_values_are_read_from_a_series_of_json_files() { TraceLogger.Configure(LogLevel.Debug); if (File.Exists("global.json")) { File.Delete("global.json"); } if (File.Exists("local.json")) { File.Delete("local.json"); } if (File.Exists("config.json")) { File.Delete("config.json"); } const string globalConf = @"{ key1: ""global-value-1"", key2: ""global-value-2""}"; const string localConf = @"{ key1: ""local-value-1""}"; const string configConf = @"{ key3: ""config-value-3""}"; File.AppendAllText("global.json", globalConf); File.AppendAllText("local.json", localConf); File.AppendAllText("config.json", configConf); _binder = ConfigurationBinderFactory.New(x => { // least specific to most specific // I assume that is reasonable x.AddJsonFile("global.json"); x.AddJsonFile("local.json"); x.AddJsonFile("config.json"); }); }
public void Setup() { TraceLogger.Configure(LogLevel.Debug); _serializer = new FastTextSerializer(); }
public void SetupAll() { TraceLogger.Configure(LogLevel.Debug); }
public void A_trace_logger_is_configured() { TraceLogger.Configure(LogLevel.Info); }