Add Test for IPacket & PacketIdAttribute
This commit is contained in:
parent
852d3adfdf
commit
3c7a83f7f5
1 changed files with 18 additions and 0 deletions
18
Server.Tests/PacketTests.cs
Normal file
18
Server.Tests/PacketTests.cs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace Server.Tests;
|
||||||
|
|
||||||
|
public class PacketTests
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void TestPacketInheritingIPacket()
|
||||||
|
{
|
||||||
|
var allTypes = AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => x.GetTypes())
|
||||||
|
.Where(x => x.IsAssignableTo(typeof(Server.Packets.IPacket)) && x.IsClass);
|
||||||
|
if (!allTypes.Any())
|
||||||
|
true.Should().BeTrue("There have been no types found which can be checked");
|
||||||
|
else
|
||||||
|
allTypes.All(t => t.GetCustomAttributes<Server.Packets.PacketIdAttribute>().Any())
|
||||||
|
.Should().BeTrue("All types inheriting from IPacket should have the PacketIdAttribute attribute.");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue