From a813239e463d776ede95391b0f345b92af30cd7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Silva?= <2493377+askpt@users.noreply.github.com> Date: Thu, 14 Dec 2023 17:22:11 +0000 Subject: [PATCH] Refactor metrics assertions in MetricsHookTest.cs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com> --- .../MetricsHookTest.cs | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/test/OpenFeature.Contrib.Hooks.Otel.Test/MetricsHookTest.cs b/test/OpenFeature.Contrib.Hooks.Otel.Test/MetricsHookTest.cs index 7fc9ee0f..ffc83b2c 100644 --- a/test/OpenFeature.Contrib.Hooks.Otel.Test/MetricsHookTest.cs +++ b/test/OpenFeature.Contrib.Hooks.Otel.Test/MetricsHookTest.cs @@ -36,14 +36,14 @@ public void After_Test() // Assert Assert.True(hookTask.IsCompleted); - + // Assert metrics Assert.NotEmpty(exportedItems); - + // check if the metric is present in the exported items var metric = exportedItems.FirstOrDefault(m => m.Name == metricName); Assert.NotNull(metric); - + var noOtherMetric = exportedItems.All(m => m.Name == metricName); Assert.True(noOtherMetric); } @@ -72,18 +72,18 @@ public void Error_Test() // Assert Assert.True(hookTask.IsCompleted); - + // Assert metrics Assert.NotEmpty(exportedItems); - + // check if the metric is present in the exported items var metric = exportedItems.FirstOrDefault(m => m.Name == metricName); Assert.NotNull(metric); - + var noOtherMetric = exportedItems.All(m => m.Name == metricName); Assert.True(noOtherMetric); } - + [Fact] public void Finally_Test() { @@ -108,14 +108,14 @@ public void Finally_Test() // Assert Assert.True(hookTask.IsCompleted); - + // Assert metrics Assert.NotEmpty(exportedItems); - + // check if the metric feature_flag.evaluation_success_total is present in the exported items var metric = exportedItems.FirstOrDefault(m => m.Name == metricName); Assert.NotNull(metric); - + var noOtherMetric = exportedItems.All(m => m.Name == metricName); Assert.True(noOtherMetric); } @@ -145,17 +145,17 @@ public void Before_Test() // Assert Assert.True(hookTask.IsCompleted); - + // Assert metrics Assert.NotEmpty(exportedItems); - + // check if the metric is present in the exported items var metric1 = exportedItems.FirstOrDefault(m => m.Name == metricName1); Assert.NotNull(metric1); - + var metric2 = exportedItems.FirstOrDefault(m => m.Name == metricName2); Assert.NotNull(metric2); - + var noOtherMetric = exportedItems.All(m => m.Name == metricName1 || m.Name == metricName2); Assert.True(noOtherMetric); }