Adds testing (#118)

This commit is contained in:
Kamron Batman 2020-04-27 19:27:05 -07:00 committed by GitHub
parent e200f37e75
commit 60ee5eadd2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 143 additions and 13 deletions

View file

@ -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);
}
}
}

View file

@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
<PackageReference Include="coverlet.collector" Version="1.2.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Scripts\Scripts.csproj" />
<ProjectReference Include="..\Server\Server.csproj" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,24 @@
using System;
using Server.Misc;
namespace Server.Tests
{
public class ServerFixture : IDisposable
{
public Mobile mobile { get; }
public ServerFixture()
{
// Configure / Initialize
MapDefinitions.Configure();
World.Load();
mobile = new Mobile(0x1);
}
public void Dispose()
{
}
}
}