public void SetUp()
        {
            actionWasInvoked = false;
            actionThreadName = "Not set";

            var parser = new ConnectionStringParser();
            var configuration = parser.Parse("host=localhost");
            var connection = MockRepository.GenerateStub<IPersistentConnection>();
            var channelFactory = MockRepository.GenerateStub<IPersistentChannelFactory>();
            channel = MockRepository.GenerateStub<IPersistentChannel>();

            Action<IModel> action = x =>
                {
                    actionWasInvoked = true;
                    actionThreadName = Thread.CurrentThread.Name;
                };

            channelFactory.Stub(x => x.CreatePersistentChannel(connection)).Return(channel);
            channel.Stub(x => x.InvokeChannelAction(null)).IgnoreArguments().WhenCalled(
                x => ((Action<IModel>)x.Arguments[0])(null));

            dispatcher = new ClientCommandDispatcher(configuration, connection, channelFactory);

            dispatcher.InvokeAsync(action).Wait();
        }
 public void SetUp()
 {
     var parser = new ConnectionStringParser();
     var configuration = parser.Parse("host=localhost");
     logger = MockRepository.GenerateStub<IEasyNetQLogger>();
     dispatcherFactory = new ConsumerDispatcherFactory(configuration, logger);
 }
        public void The_validate_method_should_apply_AMQPconnection_idempotently()
        {
            ConnectionConfiguration connectionConfiguration = new ConnectionStringParser().Parse("amqp://amqphost:1234/");
            connectionConfiguration.Validate(); // Simulates additional call to .Validate(); made by some RabbitHutch.CreateBus(...) overloads, in addition to call within ConnectionStringParser.Parse().

            connectionConfiguration.Hosts.Count().ShouldEqual(1);
            connectionConfiguration.Hosts.Single().Host.ShouldEqual("amqphost");
            connectionConfiguration.Hosts.Single().Port.ShouldEqual(1234);
        }
示例#4
0
        /// <summary>
        /// Creates a new instance of RabbitBus.
        /// </summary>
        /// <param name="connectionString">
        /// The EasyNetQ connection string. Example:
        /// host=192.168.1.1;port=5672;virtualHost=MyVirtualHost;username=MyUsername;password=MyPassword;requestedHeartbeat=10
        /// 
        /// The following default values will be used if not specified:
        /// host=localhost;port=5672;virtualHost=/;username=guest;password=guest;requestedHeartbeat=0
        /// </param>
        /// <param name="registerServices">
        /// Override default services. For example, to override the default IEasyNetQLogger:
        /// RabbitHutch.CreateBus("host=localhost", x => x.Register&lt;IEasyNetQLogger&gt;(_ => myLogger));
        /// </param>
        /// <returns>
        /// A new RabbitBus instance.
        /// </returns>
        public static IBus CreateBus(string connectionString, Action<IServiceRegister> registerServices)
        {
            Preconditions.CheckNotNull(connectionString, "connectionString");
            Preconditions.CheckNotNull(registerServices, "registerServices");

            var connectionStringParser = new ConnectionStringParser();

            var connectionConfiguration = connectionStringParser.Parse(connectionString);

            return CreateBus(connectionConfiguration, registerServices);
        }
 public void SetUp()
 {
     var logger = new ConsoleLogger();
     var eventBus = new EventBus();
     var parser = new ConnectionStringParser();
     var configuration = parser.Parse("host=localhost");
     var hostSelectionStrategy = new RandomClusterHostSelectionStrategy<ConnectionFactoryInfo>();
     var connectionFactory = new ConnectionFactoryWrapper(configuration, hostSelectionStrategy);
     connection = new PersistentConnection(connectionFactory, logger, eventBus);
     persistentChannel = new PersistentChannel(connection, logger, configuration, new EventBus());
 }
        public void SetUp()
        {
            var eventBus = new EventBus();
            var logger = new ConsoleLogger();
            var parser = new ConnectionStringParser();
            var configuration = parser.Parse("host=localhost");
            var hostSelectionStrategy = new DefaultClusterHostSelectionStrategy<ConnectionFactoryInfo>();
            var connectionFactory = new ConnectionFactoryWrapper(configuration, hostSelectionStrategy);
            connection = new PersistentConnection(connectionFactory, logger, eventBus);
            var persistentChannelFactory = new PersistentChannelFactory(logger, configuration, eventBus);

            dispatcher = new ClientCommandDispatcher(connection, persistentChannelFactory);
        }
        public void Should_not_have_case_sensitive_keys()
        {
            const string connectionStringAlternateCasing =
                "Host=192.168.1.1:1001,my.little.host:1002;VirtualHost=Copa;UserName=Copa;" +
                "Password=abc_xyz;Port=12345;RequestedHeartbeat=3";

            var parsed = new ConnectionStringParser().Parse(connectionStringAlternateCasing);
            parsed.Hosts.First().Host.ShouldEqual("192.168.1.1");
            parsed.Hosts.First().Port.ShouldEqual(1001);
            parsed.VirtualHost.ShouldEqual("Copa");
            parsed.UserName.ShouldEqual("Copa");
            parsed.Password.ShouldEqual("abc_xyz");
            parsed.Port.ShouldEqual(12345);
            parsed.RequestedHeartbeat.ShouldEqual(3);
        }
        public void SetUp()
        {
            var parser = new ConnectionStringParser();
            var configuration = parser.Parse("host=localhost");
            var connection = MockRepository.GenerateStub<IPersistentConnection>();
            var channelFactory = MockRepository.GenerateStub<IPersistentChannelFactory>();
            channel = MockRepository.GenerateStub<IPersistentChannel>();

            channelFactory.Stub(x => x.CreatePersistentChannel(connection)).Return(channel);
            channel.Stub(x => x.InvokeChannelAction(null)).IgnoreArguments().WhenCalled(
                x => ((Action<IModel>)x.Arguments[0])(null));

            dispatcher = new ClientCommandDispatcher(configuration, connection, channelFactory);

        }
示例#9
0
        /// <summary>
        /// Creates a new instance of RabbitBus.
        /// </summary>
        /// <param name="connectionString">
        /// The EasyNetQ connection string. Example:
        /// host=192.168.1.1;port=5672;virtualHost=MyVirtualHost;username=MyUsername;password=MyPassword;requestedHeartbeat=10
        /// 
        /// The following default values will be used if not specified:
        /// host=localhost;port=5672;virtualHost=/;username=guest;password=guest;requestedHeartbeat=0
        /// </param>
        /// <param name="registerServices">
        /// Override default services. For example, to override the default IEasyNetQLogger:
        /// RabbitHutch.CreateBus("host=localhost", x => x.Register&lt;IEasyNetQLogger&gt;(_ => myLogger));
        /// </param>
        /// <returns>
        /// A new RabbitBus instance.
        /// </returns>
        public static IBus CreateBus(string connectionString, Action<IServiceRegister> registerServices)
        {
            if(connectionString == null)
            {
                throw new ArgumentNullException("connectionString");
            }
            if(registerServices == null)
            {
                throw new ArgumentNullException("registerServices");
            }

            var connectionStringParser = new ConnectionStringParser();

            var connectionConfiguration = connectionStringParser.Parse(connectionString);

            return CreateBus(connectionConfiguration, registerServices);
        }
示例#10
0
文件: ENQUtils.cs 项目: c0d3m0nky/mty
        public static IBus GetBus(string virtualHost = "")
        {
            IBus bus;

            if (Busses.ContainsKey(virtualHost))
            {
                bus = Busses[virtualHost];
            }
            else
            {
                var conn = new ConnectionStringParser().Parse(RabbitConn);

                conn.VirtualHost = virtualHost;

                bus = RabbitHutch.CreateBus(conn.ToString());

                Busses.Add(virtualHost, bus);    
            }

            return bus;
        }
 public void SetUp()
 {
     connectionStringParser = new ConnectionStringParser();
 }