feat: add structured logging, Shouldly assertions, CPM, and project documentation
- Add Microsoft.Extensions.Logging + Serilog to NatsServer and NatsClient - Convert all test assertions from xUnit Assert to Shouldly - Add NSubstitute package for future mocking needs - Introduce Central Package Management via Directory.Packages.props - Add documentation_rules.md with style guide, generation/update rules, component map - Generate 10 documentation files across 5 component folders (GettingStarted, Protocol, Subscriptions, Server, Configuration/Operations) - Update CLAUDE.md with logging, testing, porting, agent model, CPM, and documentation guidance
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using NATS.Server;
|
||||
|
||||
namespace NATS.Server.Tests;
|
||||
@@ -15,7 +16,7 @@ public class ServerTests : IAsyncDisposable
|
||||
{
|
||||
// Use random port
|
||||
_port = GetFreePort();
|
||||
_server = new NatsServer(new NatsOptions { Port = _port });
|
||||
_server = new NatsServer(new NatsOptions { Port = _port }, NullLoggerFactory.Instance);
|
||||
}
|
||||
|
||||
public async ValueTask DisposeAsync()
|
||||
@@ -54,7 +55,7 @@ public class ServerTests : IAsyncDisposable
|
||||
using var client = await ConnectClientAsync();
|
||||
var response = await ReadLineAsync(client);
|
||||
|
||||
Assert.StartsWith("INFO ", response);
|
||||
response.ShouldStartWith("INFO ");
|
||||
await _cts.CancelAsync();
|
||||
}
|
||||
|
||||
@@ -84,7 +85,7 @@ public class ServerTests : IAsyncDisposable
|
||||
var n = await sub.ReceiveAsync(buf, SocketFlags.None);
|
||||
var msg = Encoding.ASCII.GetString(buf, 0, n);
|
||||
|
||||
Assert.Contains("MSG foo 1 5\r\nHello\r\n", msg);
|
||||
msg.ShouldContain("MSG foo 1 5\r\nHello\r\n");
|
||||
await _cts.CancelAsync();
|
||||
}
|
||||
|
||||
@@ -110,7 +111,7 @@ public class ServerTests : IAsyncDisposable
|
||||
var n = await sub.ReceiveAsync(buf, SocketFlags.None);
|
||||
var msg = Encoding.ASCII.GetString(buf, 0, n);
|
||||
|
||||
Assert.Contains("MSG foo.bar 1 5\r\n", msg);
|
||||
msg.ShouldContain("MSG foo.bar 1 5\r\n");
|
||||
await _cts.CancelAsync();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user