コード例 #1
0
        public async Task ReportMetricAsync_InputDoesNotContainMeasuredMetric_ThrowsException()
        {
            // Arrange
            var metricName                    = BogusGenerator.Name.FirstName();
            var metricDescription             = BogusGenerator.Lorem.Sentence();
            var systemMetricConfigOptions     = BogusAtlassianStatuspageMetricSinkConfigurationGenerator.GetSinkConfiguration();
            var atlassianStatuspageClientMock = new Mock <IAtlassianStatuspageClient>();
            var metricSink                    = new AtlassianStatuspageMetricSink(atlassianStatuspageClientMock.Object, systemMetricConfigOptions, NullLogger <AtlassianStatuspageMetricSink> .Instance);

            // Act & Assert
            // ReSharper disable once ExpressionIsAlwaysNull
            await Assert.ThrowsAsync <ArgumentNullException>(() => metricSink.ReportMetricAsync(metricName, metricDescription, null));
        }
コード例 #2
0
        public async Task ReportMetricAsync_InputDoesNotContainMetricName_ThrowsException(string metricName)
        {
            // Arrange
            var metricDescription             = BogusGenerator.Lorem.Sentence();
            var metricValue                   = BogusGenerator.Random.Double();
            var scrapeResult                  = ScrapeResultGenerator.Generate(metricValue);
            var systemMetricConfigOptions     = BogusAtlassianStatuspageMetricSinkConfigurationGenerator.GetSinkConfiguration();
            var atlassianStatuspageClientMock = new Mock <IAtlassianStatuspageClient>();
            var metricSink = new AtlassianStatuspageMetricSink(atlassianStatuspageClientMock.Object, systemMetricConfigOptions, NullLogger <AtlassianStatuspageMetricSink> .Instance);

            // Act & Assert
            // ReSharper disable once ExpressionIsAlwaysNull
            await Assert.ThrowsAsync <ArgumentException>(() => metricSink.ReportMetricAsync(metricName, metricDescription, scrapeResult));
        }
コード例 #3
0
        public async Task ReportMetricAsync_InputDoesNotContainMetricDescription_Succeeds(string metricDescription)
        {
            // Arrange
            var metricName                    = BogusGenerator.Name.FirstName();
            var metricValue                   = BogusGenerator.Random.Double();
            var measuredMetric                = MeasuredMetric.CreateWithoutDimension(metricValue);
            var scrapeResult                  = ScrapeResultGenerator.GenerateFromMetric(measuredMetric);
            var systemMetricConfigOptions     = BogusAtlassianStatuspageMetricSinkConfigurationGenerator.GetSinkConfiguration();
            var atlassianStatuspageClientMock = new Mock <IAtlassianStatuspageClient>();
            var metricSink                    = new AtlassianStatuspageMetricSink(atlassianStatuspageClientMock.Object, systemMetricConfigOptions, NullLogger <AtlassianStatuspageMetricSink> .Instance);

            // Act & Assert
            // ReSharper disable once ExpressionIsAlwaysNull
            await metricSink.ReportMetricAsync(metricName, metricDescription, scrapeResult);
        }
コード例 #4
0
        public async Task ReportMetricAsync_GetsValidInputWithMetricValueAndPromitorToSystemMetricMapping_SuccessfullyWritesMetric()
        {
            // Arrange
            var promitorMetricName            = BogusGenerator.Name.FirstName();
            var systemMetricId                = BogusGenerator.Name.FirstName();
            var metricDescription             = BogusGenerator.Lorem.Sentence();
            var metricValue                   = BogusGenerator.Random.Double();
            var measuredMetric                = MeasuredMetric.CreateWithoutDimension(metricValue);
            var scrapeResult                  = ScrapeResultGenerator.GenerateFromMetric(measuredMetric);
            var systemMetricConfigOptions     = BogusAtlassianStatuspageMetricSinkConfigurationGenerator.GetSinkConfiguration(systemMetricId: systemMetricId, promitorMetricName: promitorMetricName);
            var atlassianStatuspageClientMock = new Mock <IAtlassianStatuspageClient>();
            var metricSink = new AtlassianStatuspageMetricSink(atlassianStatuspageClientMock.Object, systemMetricConfigOptions, NullLogger <AtlassianStatuspageMetricSink> .Instance);

            // Act
            await metricSink.ReportMetricAsync(promitorMetricName, metricDescription, scrapeResult);

            // Assert
            atlassianStatuspageClientMock.Verify(mock => mock.ReportMetricAsync(systemMetricId, metricValue), Times.Once());
        }
コード例 #5
0
        public async Task ReportMetricAsync_GetsValidInputWithPromitorMetricThatIsNotMappedToSystemMetricId_DoesNotWriteMetric()
        {
            // Arrange
            const double expectedDefaultValue = 0;
            var          promitorMetricName   = BogusGenerator.Name.FirstName();
            var          systemMetricId       = BogusGenerator.Name.FirstName();
            var          metricDescription    = BogusGenerator.Lorem.Sentence();
            double?      metricValue          = null;
            // ReSharper disable once ExpressionIsAlwaysNull
            var measuredMetric                = MeasuredMetric.CreateWithoutDimension(metricValue);
            var scrapeResult                  = ScrapeResultGenerator.GenerateFromMetric(measuredMetric);
            var systemMetricConfigOptions     = BogusAtlassianStatuspageMetricSinkConfigurationGenerator.GetSinkConfiguration(promitorMetricName: promitorMetricName);
            var atlassianStatuspageClientMock = new Mock <IAtlassianStatuspageClient>();
            var metricSink = new AtlassianStatuspageMetricSink(atlassianStatuspageClientMock.Object, systemMetricConfigOptions, NullLogger <AtlassianStatuspageMetricSink> .Instance);

            // Act
            await metricSink.ReportMetricAsync(promitorMetricName, metricDescription, scrapeResult);

            // Assert
            atlassianStatuspageClientMock.Verify(mock => mock.ReportMetricAsync(systemMetricId, expectedDefaultValue), Times.Never);
        }