Adds more packet tests (#176)

This commit is contained in:
Kamron Batman 2020-07-11 01:01:57 -07:00 committed by GitHub
parent 7d20cf7642
commit c0805850c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 149 additions and 2 deletions

View file

@ -0,0 +1,35 @@
using System;
using System.Buffers;
using Server.Network;
using Xunit;
namespace Server.Tests.Network.Packets
{
public class ObjectHelpResponseTests
{
[Fact]
public void TestObjectHelpResponse()
{
Serial s = 0x100;
string text = "This is some testing text";
Span<byte> data = new ObjectHelpResponse(s, text).Compile();
int length = 9 + text.Length * 2;
Span<byte> expectedData = stackalloc byte[length];
int pos = 0;
expectedData.Write(ref pos, (byte)0xB7); // Packet ID
expectedData.Write(ref pos, (ushort)length); // Length
expectedData.Write(ref pos, s);
expectedData.WriteBigUni(ref pos, text);
#if NO_LOCAL_INIT
expectedData.Write(ref pos, (ushort)0); // Terminator
#endif
AssertThat.Equal(data, expectedData);
}
}
}