Skip to content

Commit

Permalink
A bit of testing
Browse files Browse the repository at this point in the history
  • Loading branch information
ThadHouse committed Feb 9, 2024
1 parent 2166cd7 commit 3bfc5cc
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ntcore/NetworkTableInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace NetworkTables;
* kept to the NetworkTableInstance returned by this function to keep it from being garbage
* collected.
*/
public sealed partial class NetworkTableInstance : IEquatable<NetworkTableInstance?>, IEqualityOperators<NetworkTableInstance?, NetworkTableInstance?, bool>
public sealed partial class NetworkTableInstance : IDisposable, IEquatable<NetworkTableInstance?>, IEqualityOperators<NetworkTableInstance?, NetworkTableInstance?, bool>
{
private static readonly ConcurrentDictionary<NtInst, NetworkTableInstance> s_instances = new();

Expand Down
33 changes: 33 additions & 0 deletions test/ntcore.test/LoggerTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System.Runtime.InteropServices;
using Xunit;

namespace NetworkTables.Test;

public class LoggerTest
{
[Fact]
public void AddMessageTest()
{
using var instance = NetworkTableInstance.Create();
List<NetworkTableEvent> msgs = [];
instance.AddLogger((int)NtLogLevel.Info, 100, msgs.Add);

instance.StartClient4("client");
instance.SetServer("127.0.0.1", 10000);

// Wait for client to report it's started, then wait another 0.1 sec
int count = 0;
while (!instance.GetNetworkMode().HasFlag(NetworkMode.Client4))
{
Thread.Sleep(100);
count++;
if (count > 30)
{
Assert.Fail("Failed to converge");
}
}
Thread.Sleep(100);

Assert.NotEmpty(msgs);
}
}

0 comments on commit 3bfc5cc

Please sign in to comment.