2022-12-29 11:12:54 +00:00
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
|
|
|
|
namespace Server.Tests;
|
|
|
|
|
|
2022-12-29 12:33:16 +00:00
|
|
|
|
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute]
|
2022-12-29 11:12:54 +00:00
|
|
|
|
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.");
|
|
|
|
|
}
|
|
|
|
|
}
|