Skip to content

Commit

Permalink
Rename, add NonParallelizable
Browse files Browse the repository at this point in the history
  • Loading branch information
luiscantero committed Jul 22, 2024
1 parent fa6fbd0 commit 1d8bd90
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions tests/MetricsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ namespace OpcPlc.Tests;
using System;
using System.Collections.Generic;
using System.Diagnostics.Metrics;
using Meters = OpcPlc.MetricsHelper;

/// <summary>
/// Tests for Metrics.
/// </summary>
[NonParallelizable]
internal class MetricsTests
{
private readonly MeterListener _meterListener;
Expand Down Expand Up @@ -62,7 +62,7 @@ public void TearDown()
public void TestAddSessionCount()
{
var sessionId = Guid.NewGuid().ToString();
Meters.AddSessionCount(sessionId.ToString());
MetricsHelper.AddSessionCount(sessionId.ToString());
_metrics.TryGetValue("opc_plc_session_count", out var counter).Should().BeTrue();
counter.Should().Be(1);
}
Expand All @@ -72,15 +72,15 @@ public void TestAddSubscriptionCount()
{
var sessionId = Guid.NewGuid().ToString();
var subscriptionId = Guid.NewGuid().ToString();
Meters.AddSubscriptionCount(sessionId, subscriptionId);
MetricsHelper.AddSubscriptionCount(sessionId, subscriptionId);
_metrics.TryGetValue("opc_plc_subscription_count", out var counter).Should().BeTrue();
counter.Should().Be(1);
}

[Test]
public void TestAddMonitoredItemCount()
{
Meters.AddMonitoredItemCount(1);
MetricsHelper.AddMonitoredItemCount(1);
_metrics.TryGetValue("opc_plc_monitored_item_count", out var counter).Should().BeTrue();
counter.Should().Be(1);
}
Expand All @@ -90,17 +90,16 @@ public void TestAddPublishedCount()
{
var sessionId = Guid.NewGuid().ToString();
var subscriptionId = Guid.NewGuid().ToString();
Meters.AddPublishedCount(sessionId, subscriptionId, 1, 0);
MetricsHelper.AddPublishedCount(sessionId, subscriptionId, 1, 0);
_metrics.TryGetValue("opc_plc_published_count_with_type", out var counter).Should().BeTrue();
counter.Should().Be(1);
}

[Test]
public void TestRecordTotalErrors()
{
Meters.RecordTotalErrors("operation");
MetricsHelper.RecordTotalErrors("operation");
_metrics.TryGetValue("opc_plc_total_errors", out var counter).Should().BeTrue(); ;
counter.Should().Be(1);
}
}

0 comments on commit 1d8bd90

Please sign in to comment.