Skip to content

Commit

Permalink
add tests to cover client ServerInfoReceived
Browse files Browse the repository at this point in the history
  • Loading branch information
jpdillingham committed Feb 19, 2024
1 parent f521c55 commit 06b2176
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/Soulseek.Tests.Unit/SoulseekClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,41 @@ public void Does_Not_Throw_When_GlobalMessageReceived_And_No_Handler_Bound(strin
}
}

[Trait("Category", "ServerInfoReceived")]
[Theory(DisplayName = "Raises ServerInfoReceived on receipt"), AutoData]
public void Raises_ServerInfoReceived_On_Receipt(ServerInfo info)
{
var handlerMock = new Mock<IServerMessageHandler>();

using (var s = new SoulseekClient(serverMessageHandler: handlerMock.Object))
{
ServerInfo args = default;
s.ServerInfoReceived += (sender, e) => args = e;

handlerMock.Raise(m => m.ServerInfoReceived += null, this, info);

Assert.NotNull(args);
Assert.Equal(info.ParentMinSpeed, args.ParentMinSpeed);
Assert.Equal(info.ParentSpeedRatio, args.ParentSpeedRatio);
Assert.Equal(info.WishlistInterval, args.WishlistInterval);
Assert.Equal(info.IsSupporter, args.IsSupporter);
}
}

[Trait("Category", "ServerInfoReceived")]
[Fact(DisplayName = "Does not throw when ServerInfoReceived and no handler bound")]
public void Does_Not_Throw_When_ServerInfoReceived_And_No_Handler_Bound()
{
var handlerMock = new Mock<IServerMessageHandler>();

using (var s = new SoulseekClient(serverMessageHandler: handlerMock.Object))
{
var ex = Record.Exception(() => handlerMock.Raise(m => m.ServerInfoReceived += null, this, info));

Assert.Null(ex);
}
}

[Trait("Category", "MessageRead")]
[Fact(DisplayName = "MessageRead invokes HandleMessageRead")]
public void MessageRead_Invokes_HandleMessageRead()
Expand Down

0 comments on commit 06b2176

Please sign in to comment.