public async Task Invoke_Should_Be_Fail()
        {
            Metrics.SuppressDefaultMetrics();

            PrometheusMiddleware prometheusMiddleware = new PrometheusMiddleware(
                _requestDelegateMock.Object,
                _iLoggerMock.Object,
                _iQueueServiceMock.Object,
                _iTopicServiceMock.Object,
                _iSubscriptionServiceMock.Object,
                _iOptionsMock.Object);

            var context = new DefaultHttpContext();

            context.Request.Path = "/metrics";

            await prometheusMiddleware.Invoke(context);

            var lines = await GetMetrics();

            Assert.Contains(lines, s => s == "azureservicebusexporter_up 0");
        }
        public async Task Invoke_Should_Be_Successful()
        {
            Metrics.SuppressDefaultMetrics();

            PrometheusMiddleware prometheusMiddleware = new PrometheusMiddleware(
                _requestDelegateMock.Object,
                _iLoggerMock.Object,
                _iQueueServiceMock.Object,
                _iTopicServiceMock.Object,
                _iSubscriptionServiceMock.Object,
                _iOptionsMock.Object,
                _iServicebusNamespace.Object);

            var context = new DefaultHttpContext();

            context.Request.Path = "/metrics";

            _iQueueServiceMock.Setup(x => x.CreateMetricsAsync(It.IsAny <IServiceBusNamespace>())).ReturnsAsync(new List <GaugeModel>()
            {
                new GaugeModel()
                {
                    Name        = "Queue",
                    Help        = "Queue Help",
                    Labels      = new [] { "env" },
                    LabelValues = new [] { "dev" },
                    Value       = 200
                }
            });

            _iSubscriptionServiceMock.Setup(x => x.CreateMetricsAsync(It.IsAny <IServiceBusNamespace>())).ReturnsAsync(new List <GaugeModel>()
            {
                new GaugeModel()
                {
                    Name        = "Subscription",
                    Help        = "Subscription Help",
                    Labels      = new [] { "env" },
                    LabelValues = new [] { "dev" },
                    Value       = 300
                }
            });

            _iTopicServiceMock.Setup(x => x.CreateMetricsAsync(It.IsAny <IServiceBusNamespace>())).ReturnsAsync(new List <GaugeModel>()
            {
                new GaugeModel()
                {
                    Name        = "Topic",
                    Help        = "Topic Help",
                    Labels      = new [] { "env" },
                    LabelValues = new [] { "dev" },
                    Value       = 400
                }
            });

            await prometheusMiddleware.Invoke(context);

            var lines = await GetMetrics();

            Assert.Contains(lines, s => s == "Queue{env=\"dev\"} 200");
            Assert.Contains(lines, s => s == "Subscription{env=\"dev\"} 300");
            Assert.Contains(lines, s => s == "Topic{env=\"dev\"} 400");
            Assert.Contains(lines, s => s == "azureservicebusexporter_up 1");
            Assert.Contains(lines, s => s.StartsWith("scrape_duration_milliseconds "));

            _iQueueServiceMock.Verify(x => x.CreateMetricsAsync(It.IsAny <IServiceBusNamespace>()), Times.Once);
            _iSubscriptionServiceMock.Verify(x => x.CreateMetricsAsync(It.IsAny <IServiceBusNamespace>()), Times.Once);
            _iTopicServiceMock.Verify(x => x.CreateMetricsAsync(It.IsAny <IServiceBusNamespace>()), Times.Once);
        }