Exemple #1
0
 static void Main(string[] args)
 {
     var bus = new CommandBus("http://localhost.fiddler:9302/Commands");
     bus.Post(new PrintMessage
                 {
                     Message = "Hello world"
                 });
 }
 public void Should_successfully_send_command()
 {
     var bus = new CommandBus(URL);
     bus.Post(new PrintMessage
     {
         Message = "Hello world"
     });
 }
        public void Should_successfully_send_command()
        {
            Action send = () =>
            {
                var bus = new CommandBus(URL, new Client.Avanced.ZazConfiguration
                {
                    ConfigureHttp = h =>
                    {
                        h.Credentials = new NetworkCredential("supr", "booper");
                    }
                });
                bus.Post(new FooCommand
                {
                    Message = "Hello world"
                });
            };

            send.ShouldThrow<Exception>();
        }
        public void Given_command_server_runnig()
        {
            var instance = new CommandsService(new ServerContext
            (
                registry: new FooCommandRegistry(),
                broker: new DelegatingCommandBroker((cmd, ctx) =>
                {
                    _postedCommand = cmd;
                    _ctx = ctx;

                    return Task.Factory.StartNew(() => {});
                })
            ));
            var config = ConfigurationHelper.CreateConfiguration(instance);

            SimpleBasicAuthenticationHandler.Configure(config, cred => cred.UserName == "supr" && cred.Password == "booper");

            _host = new HttpServiceHost(typeof(CommandsService), config, new Uri(URL));
            _host.Open();

            // Client side

            var bus = new CommandBus(URL, new Client.Avanced.ZazConfiguration
            {
                ConfigureHttp = h =>
                {
                    h.Credentials = new NetworkCredential("supr", "booper");
                }
            });
            bus.Post(new FooCommand
            {
                Message = "Hello world"
            });

            // Close host
            _host.Close();
        }