Esempio n. 1
0
        public void PurgeQueue_WhenCalledWithoutStart_RaisesException()
        {
            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>();
            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 rabbitMqWrapper = new RabbitMqWrapper(dateTimeProvider.Object, logger.Object, configurationManager.Object, connectionManager.Object, _metrics);

            rabbitMqWrapper.PurgeQueue();
        }
Esempio n. 2
0
        public void PurgeQueue_WhenCalledAfterStart_CallsModelQueuePurge()
        {
            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>();
            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 rabbitMqWrapper = new RabbitMqWrapper(dateTimeProvider.Object, logger.Object, configurationManager.Object, connectionManager.Object, _metrics);

            rabbitMqWrapper.Start();
            rabbitMqWrapper.PurgeQueue();

            model.Verify(x => x.QueuePurge(It.IsAny <string>()), Times.Once);
        }