refactor: extract NATS.Server.Auth.Tests project
Move 50 auth/accounts/permissions/JWT/NKey test files from NATS.Server.Tests into a dedicated NATS.Server.Auth.Tests project. Update namespaces, replace private GetFreePort/ReadUntilAsync helpers with TestUtilities calls, replace Task.Delay with TaskCompletionSource in test doubles, and add InternalsVisibleTo. 690 tests pass.
This commit is contained in:
48
tests/NATS.Server.Auth.Tests/AccountStatsTests.cs
Normal file
48
tests/NATS.Server.Auth.Tests/AccountStatsTests.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using NATS.Server.Auth;
|
||||
|
||||
namespace NATS.Server.Auth.Tests;
|
||||
|
||||
public class AccountStatsTests
|
||||
{
|
||||
[Fact]
|
||||
public void Account_tracks_inbound_stats()
|
||||
{
|
||||
var account = new Account("test");
|
||||
account.IncrementInbound(1, 100);
|
||||
account.IncrementInbound(1, 200);
|
||||
account.InMsgs.ShouldBe(2);
|
||||
account.InBytes.ShouldBe(300);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Account_tracks_outbound_stats()
|
||||
{
|
||||
var account = new Account("test");
|
||||
account.IncrementOutbound(1, 50);
|
||||
account.IncrementOutbound(1, 75);
|
||||
account.OutMsgs.ShouldBe(2);
|
||||
account.OutBytes.ShouldBe(125);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Account_stats_start_at_zero()
|
||||
{
|
||||
var account = new Account("test");
|
||||
account.InMsgs.ShouldBe(0);
|
||||
account.OutMsgs.ShouldBe(0);
|
||||
account.InBytes.ShouldBe(0);
|
||||
account.OutBytes.ShouldBe(0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Account_stats_are_independent()
|
||||
{
|
||||
var account = new Account("test");
|
||||
account.IncrementInbound(5, 500);
|
||||
account.IncrementOutbound(3, 300);
|
||||
account.InMsgs.ShouldBe(5);
|
||||
account.OutMsgs.ShouldBe(3);
|
||||
account.InBytes.ShouldBe(500);
|
||||
account.OutBytes.ShouldBe(300);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user