Example #1
0
        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))
                );
        }
Example #2
0
 public void TestGetHandlerInterface_Type_NotHandler() =>
 Assert.IsNull(PacketHandlerAttribute.GetHandlerInterface(typeof(TestClassNotPacketHandler)));
Example #3
0
 public void TestGetHandlerInterface_Type_null() =>
 Assert.Throws <ArgumentNullException>(() => PacketHandlerAttribute.GetHandlerInterface(null));