Adds testing (#118)
This commit is contained in:
parent
e200f37e75
commit
60ee5eadd2
10 changed files with 143 additions and 13 deletions
|
|
@ -0,0 +1,36 @@
|
|||
using System;
|
||||
using System.Buffers.Binary;
|
||||
using Server.Network;
|
||||
using Xunit;
|
||||
|
||||
namespace Server.Tests.Network.Packets
|
||||
{
|
||||
public class DamageOldPacketTests : IClassFixture<ServerFixture>
|
||||
{
|
||||
private Mobile mobile;
|
||||
|
||||
public DamageOldPacketTests(ServerFixture fixture) => mobile = fixture.mobile;
|
||||
|
||||
[Theory]
|
||||
[InlineData(10, 10)]
|
||||
[InlineData(-5, 0)]
|
||||
[InlineData(1024, 255)]
|
||||
public void TestDamagePacketOld(int inputAmount, byte expectedAmount)
|
||||
{
|
||||
DamagePacketOld packet = new DamagePacketOld(mobile, inputAmount);
|
||||
|
||||
Span<byte> data = packet.Compile(false, out int length).AsSpan(0, length);
|
||||
|
||||
byte[] expectedData = {
|
||||
0xBF, // Packet
|
||||
0x00, 0x0B, // Length
|
||||
0x00, 0x22, // Sub-packet
|
||||
0x01, // Command
|
||||
0x00, 0x00, 0x00, 0x01, // Serial
|
||||
expectedAmount // Amount
|
||||
};
|
||||
|
||||
Assert.Equal(data.ToArray(), expectedData);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue