-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add NATS server fixture and test improvements
Introduced a base NATS server fixture for test classes and updated test cases to utilize the fixture. This simplifies server management and ensures consistent URL handling. Also, enhanced tests to use unique prefixes for identifiers to improve reliability.
- Loading branch information
Showing
4 changed files
with
63 additions
and
32 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
tests/NATS.Client.Platform.Windows.Tests/BaseNatsServerFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace NATS.Client.Platform.Windows.Tests; | ||
|
||
public class BaseNatsServerFixture : IDisposable | ||
{ | ||
private readonly NatsServerProcess _server; | ||
private int _next; | ||
|
||
protected BaseNatsServerFixture(string? config = default) => _server = NatsServerProcess.Start(config: config); | ||
|
||
public string Url => _server.Url; | ||
|
||
public string GetNextId() => $"test{Interlocked.Increment(ref _next)}"; | ||
|
||
public void Dispose() => _server.Dispose(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/NATS.Client.Platform.Windows.Tests/NATS.Client.Platform.Windows.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters