Move TLS, OCSP, WebSocket, Networking, and IO test files from NATS.Server.Tests into a dedicated NATS.Server.Transport.Tests project. Update namespaces, replace private GetFreePort/ReadUntilAsync with shared TestUtilities helpers, extract TestCertHelper to TestUtilities, and replace Task.Delay polling loops with PollHelper.WaitUntilAsync/YieldForAsync for proper synchronization.
54 lines
1.5 KiB
C#
54 lines
1.5 KiB
C#
using NATS.Server.WebSocket;
|
|
using Shouldly;
|
|
|
|
namespace NATS.Server.Transport.Tests.WebSocket;
|
|
|
|
public class WsConstantsTests
|
|
{
|
|
[Fact]
|
|
public void OpCodes_MatchRfc6455()
|
|
{
|
|
WsConstants.TextMessage.ShouldBe(1);
|
|
WsConstants.BinaryMessage.ShouldBe(2);
|
|
WsConstants.CloseMessage.ShouldBe(8);
|
|
WsConstants.PingMessage.ShouldBe(9);
|
|
WsConstants.PongMessage.ShouldBe(10);
|
|
}
|
|
|
|
[Fact]
|
|
public void FrameBits_MatchRfc6455()
|
|
{
|
|
WsConstants.FinalBit.ShouldBe((byte)0x80);
|
|
WsConstants.Rsv1Bit.ShouldBe((byte)0x40);
|
|
WsConstants.MaskBit.ShouldBe((byte)0x80);
|
|
}
|
|
|
|
[Fact]
|
|
public void CloseStatusCodes_MatchRfc6455()
|
|
{
|
|
WsConstants.CloseStatusNormalClosure.ShouldBe(1000);
|
|
WsConstants.CloseStatusGoingAway.ShouldBe(1001);
|
|
WsConstants.CloseStatusProtocolError.ShouldBe(1002);
|
|
WsConstants.CloseStatusPolicyViolation.ShouldBe(1008);
|
|
WsConstants.CloseStatusMessageTooBig.ShouldBe(1009);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(WsConstants.CloseMessage)]
|
|
[InlineData(WsConstants.PingMessage)]
|
|
[InlineData(WsConstants.PongMessage)]
|
|
public void IsControlFrame_True(int opcode)
|
|
{
|
|
WsConstants.IsControlFrame(opcode).ShouldBeTrue();
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(WsConstants.TextMessage)]
|
|
[InlineData(WsConstants.BinaryMessage)]
|
|
[InlineData(0)]
|
|
public void IsControlFrame_False(int opcode)
|
|
{
|
|
WsConstants.IsControlFrame(opcode).ShouldBeFalse();
|
|
}
|
|
}
|