public void TestGetHandlerInterface_Type() { Assert.AreEqual( typeof(IPacketHandler <TestPacket>), PacketHandlerAttribute.GetHandlerInterface(typeof(TestClassPacketHandlerNoAttribute)) ); Assert.AreEqual( typeof(IPacketHandler <TestPacket>), PacketHandlerAttribute.GetHandlerInterface(typeof(TestClassPacketHandlerWithAttribute)) ); Assert.AreEqual( typeof(IPacketHandler <TestPacket2>), PacketHandlerAttribute.GetHandlerInterface(typeof(TestClassPacketHandlerWithAttribute2)) ); Assert.AreEqual( typeof(IPacketHandler <TestPacket>), PacketHandlerAttribute.GetHandlerInterface(typeof(TestClassPacketHandlerWithMismatchedAttribute)) ); // This specific handler is disallowed in the registry and filtered out elsewhere, // but PacketHandlerAttribute.GetHandlerInterface() allowing it is acceptable. Assert.AreEqual( typeof(IPacketHandler <IPacket>), PacketHandlerAttribute.GetHandlerInterface(typeof(TestClassPacketHandlerInvalidPacketType)) ); }
public void TestGetHandlerInterface_Type_NotHandler() => Assert.IsNull(PacketHandlerAttribute.GetHandlerInterface(typeof(TestClassNotPacketHandler)));
public void TestGetHandlerInterface_Type_null() => Assert.Throws <ArgumentNullException>(() => PacketHandlerAttribute.GetHandlerInterface(null));