Exemple #1
0
        public void MessageCount_WhenCalled_WithExistentQueueName_ItWillReturnsInt_10()
        {
            var dateTimeProvider     = new Mock <IDateTimeProvider>();
            var logger               = new Mock <ILogger>();
            var configurationManager = new Mock <IConfigurationManager>();

            configurationManager.Setup(x => x.Get <string>("QueueUri")).Returns("amqp://*****:*****@localhost:5672");

            var model = new Mock <IModel>();

            model.Setup(x => x.MessageCount("Test")).Returns(10);
            var connection = new Mock <IConnection>();

            connection.Setup(x => x.CreateModel()).Returns(model.Object);
            var connectionManager = new Mock <IRabbitMqConnectionManager>();

            connectionManager.Setup(x => x.Connection).Returns(connection.Object);

            var queueName = "Test";

            IQueueWrapper rabbitMqWrapper = new RabbitMqWrapper(dateTimeProvider.Object, logger.Object, configurationManager.Object, connectionManager.Object, _metrics);

            rabbitMqWrapper.Start();

            uint result = rabbitMqWrapper.MessageCount(queueName);

            Assert.AreEqual(10u, result);
        }
Exemple #2
0
        public void MessageCount_WhenCalled_WithoutModel_RaisesException()
        {
            var dateTimeProvider     = new Mock <IDateTimeProvider>();
            var logger               = new Mock <ILogger>();
            var configurationManager = new Mock <IConfigurationManager>();

            configurationManager.Setup(x => x.Get <string>("QueueUri")).Returns((string)null);

            var connectionManager = new Mock <IRabbitMqConnectionManager>();

            var rabbitMqWrapper = new RabbitMqWrapper(dateTimeProvider.Object, logger.Object, configurationManager.Object, connectionManager.Object, _metrics);
            var queueName       = "Test";

            uint result = rabbitMqWrapper.MessageCount(queueName);

            Assert.AreEqual(1u, result);
        }