Skip to content

Commit

Permalink
Refactor metrics assertions in MetricsHookTest.cs
Browse files Browse the repository at this point in the history
Signed-off-by: André Silva <[email protected]>
  • Loading branch information
askpt committed Dec 14, 2023
1 parent fcaea28 commit a813239
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions test/OpenFeature.Contrib.Hooks.Otel.Test/MetricsHookTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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()
{
Expand All @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit a813239

Please sign in to comment.