using System.Reflection;

namespace Server.Tests;

[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute]
public class PacketTests
{
	[Fact]
	public void TestPacketInheritingIPacket()
	{
		var allTypes = AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => x.GetTypes())
			.Where(x => x.IsAssignableTo(typeof(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<Packets.PacketIdAttribute>().Any())
				.Should().BeTrue("All types inheriting from IPacket should have the PacketIdAttribute attribute.");
	}
}