Ejemplo n.º 1
0
        public void OverrideFactoryValues()
        {
            var config = new RabbitConfiguration
            {
                Username  = "******",
                Password  = "******",
                Hostnames = new List <string> {
                    "localhost"
                },
                VirtualHost = "/ex",
                AutomaticRecoveryEnabled         = false,
                NetworkRecoveryIntervalInSeconds = 5,
                TopologyRecoveryEnabled          = false,
                RequestedHeartBeat = 20
            };
            var service  = new ExposedRabbitService(config);
            var factory1 = service.ExposedFactory;

            factory1.UserName.Should().Be(config.Username);
            factory1.Password.Should().Be(config.Password);

            factory1.VirtualHost.Should().Be("/ex");
            factory1.AutomaticRecoveryEnabled.Should().BeFalse();
            factory1.NetworkRecoveryInterval.Should().Be(TimeSpan.FromSeconds(5));
            factory1.TopologyRecoveryEnabled.Should().BeFalse();
            factory1.RequestedHeartbeat.Should().Be(TimeSpan.FromSeconds(20));

            service.Dispose();
        }
Ejemplo n.º 2
0
        public void NoHostnamesProvided()
        {
            var config = new RabbitConfiguration
            {
                Password = "******",
                Username = "******",
            };
            var service = new ExposedRabbitService(config);

            service.Invoking(y => y.ExposedFactory).Should().Throw <ArgumentNullException>();

            service.Dispose();
        }
Ejemplo n.º 3
0
        public void NoPasswordProvided()
        {
            var config = new RabbitConfiguration
            {
                Username  = "******",
                Hostnames = new List <string> {
                    "localhost"
                }
            };
            var service = new ExposedRabbitService(config);

            service.Invoking(y => y.ExposedFactory).Should().Throw <InvalidCredentialException>();

            service.Dispose();
        }
Ejemplo n.º 4
0
        public void DefaultFactoryValues()
        {
            var service  = new ExposedRabbitService(ExposedRabbitService.validConfig);
            var factory1 = service.ExposedFactory;

            factory1.UserName.Should().Be(ExposedRabbitService.validConfig.Username);
            factory1.Password.Should().Be(ExposedRabbitService.validConfig.Password);

            factory1.VirtualHost.Should().Be(ConnectionFactory.DefaultVHost);
            factory1.AutomaticRecoveryEnabled.Should().BeTrue();
            factory1.NetworkRecoveryInterval.Should().Be(TimeSpan.FromSeconds(10));
            factory1.TopologyRecoveryEnabled.Should().BeTrue();
            factory1.RequestedHeartbeat.Should().Be(TimeSpan.FromSeconds(5));

            service.Dispose();
        }
Ejemplo n.º 5
0
        public void SingletonAttributes()
        {
            var service = new ExposedRabbitService(ExposedRabbitService.validConfig);

            var factory1    = service.ExposedFactory;
            var connection1 = service.ExposedConnection;
            var channel1    = service.ExposedChannel;


            var factory2    = service.ExposedFactory;
            var connection2 = service.ExposedConnection;
            var channel2    = service.ExposedChannel;

            service.Dispose();

            factory1.Should().BeSameAs(factory2);
            connection1.Should().BeSameAs(connection2);
            channel1.Should().BeSameAs(channel2);
        }
Ejemplo n.º 6
0
        public void CloseConnection()
        {
            var service     = new ExposedRabbitService(ExposedRabbitService.validConfig);
            var factory1    = service.ExposedFactory;
            var connection1 = service.ExposedConnection;
            var channel1    = service.ExposedChannel;

            service.Close();
            var factory2    = service.ExposedFactory;
            var connection2 = service.ExposedConnection;
            var channel2    = service.ExposedChannel;

            connection1.IsOpen.Should().BeFalse();
            channel1.IsClosed.Should().BeTrue();

            factory1.Should().NotBeSameAs(factory2);
            connection1.Should().NotBeSameAs(connection2);
            channel1.Should().NotBeSameAs(channel2);

            service.Dispose();
        }
Ejemplo n.º 7
0
 public void CreateBasicService()
 {
     handler = new MessageProcessor();
     // Get the channel so it can be purged before each test
     basicService = new ExposedRabbitService(ExposedRabbitService.validConfig);
 }