public void TestGetPacketType_MethodInfo_MismatchedAttribute() => Assert.Throws <ArgumentException>( () => PacketHandlerAttribute.GetPacketType( typeof(TestPacketHandlerMethods).GetMethod( nameof(TestPacketHandlerMethods.HandleWithMismatchedAttribute) ) ) );
public void TestIsValidHandler_MethodInfo_MismatchedAttribute() => Assert.IsFalse( PacketHandlerAttribute.IsValidHandler( typeof(TestPacketHandlerMethods).GetMethod( nameof(TestPacketHandlerMethods.HandleWithMismatchedAttribute) ) ) );
public void TestGetPacketType_MethodInfo_InvalidPacketParameterType() => Assert.Throws <ArgumentException>( () => PacketHandlerAttribute.GetPacketType( typeof(TestPacketHandlerMethods).GetMethod( nameof(TestPacketHandlerMethods.HandleInvalidPacketParameterType) ) ) );
public void TestIsValidHandler_MethodInfo_InvalidPacketParameterType() => Assert.IsFalse( PacketHandlerAttribute.IsValidHandler( typeof(TestPacketHandlerMethods).GetMethod( nameof(TestPacketHandlerMethods.HandleInvalidPacketParameterType) ) ) );
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 TestIsValidHandler_MethodInfo() { Assert.IsTrue( PacketHandlerAttribute.IsValidHandler( typeof(TestPacketHandlerMethods).GetMethod(nameof(TestPacketHandlerMethods.HandleWithAttribute)) ) ); Assert.IsTrue( PacketHandlerAttribute.IsValidHandler( typeof(TestPacketHandlerMethods).GetMethod(nameof(TestPacketHandlerMethods.HandleWithAttribute2)) ) ); }
public void TestGetPacketType_Type() { Assert.AreEqual( typeof(TestPacket), PacketHandlerAttribute.GetPacketType(typeof(TestClassPacketHandlerNoAttribute)) ); Assert.AreEqual( typeof(TestPacket), PacketHandlerAttribute.GetPacketType(typeof(TestClassPacketHandlerWithAttribute)) ); Assert.AreEqual( typeof(TestPacket2), PacketHandlerAttribute.GetPacketType(typeof(TestClassPacketHandlerWithAttribute2)) ); }
public void TestGetPacketType_MethodInfo() { Assert.AreEqual( typeof(TestPacket), PacketHandlerAttribute.GetPacketType( typeof(TestPacketHandlerMethods).GetMethod(nameof(TestPacketHandlerMethods.HandleNoAttribute)) ) ); Assert.AreEqual( typeof(TestPacket), PacketHandlerAttribute.GetPacketType( typeof(TestPacketHandlerMethods).GetMethod(nameof(TestPacketHandlerMethods.HandleWithAttribute)) ) ); Assert.AreEqual( typeof(TestPacket2), PacketHandlerAttribute.GetPacketType( typeof(TestPacketHandlerMethods).GetMethod(nameof(TestPacketHandlerMethods.HandleWithAttribute2)) ) ); }
public void TestGetPacketType_Type_null() => Assert.Throws <ArgumentNullException>(() => PacketHandlerAttribute.GetPacketType(default(Type)));
public void TestIsValidHandler_Type() { Assert.IsTrue(PacketHandlerAttribute.IsValidHandler(typeof(TestClassPacketHandlerWithAttribute))); Assert.IsTrue(PacketHandlerAttribute.IsValidHandler(typeof(TestClassPacketHandlerWithAttribute2))); }
public void TestGetHandlerInterface_Type_NotHandler() => Assert.IsNull(PacketHandlerAttribute.GetHandlerInterface(typeof(TestClassNotPacketHandler)));
public void TestGetPacketType_Type_MismatchedAttribute() => Assert.Throws <ArgumentException>( () => PacketHandlerAttribute.GetPacketType(typeof(TestClassPacketHandlerWithMismatchedAttribute)) );
public void TestIsValidHandler_Type_NoAttribute() => Assert.IsTrue( PacketHandlerAttribute.IsValidHandler(typeof(TestClassPacketHandlerNoAttribute)) );
public void TestIsValidHandler_MethodInfo_NoAttribute() => Assert.IsTrue( PacketHandlerAttribute.IsValidHandler( typeof(TestPacketHandlerMethods).GetMethod(nameof(TestPacketHandlerMethods.HandleNoAttribute)) ) );
public void TestIsValidHandler_MethodInfo_null() => Assert.Throws <ArgumentNullException>(() => PacketHandlerAttribute.GetPacketType(default(MethodInfo)));
public void TestGetPacketType_Type_NotPacketHandlerImplementation() => Assert.Throws <ArgumentException>( () => PacketHandlerAttribute.GetPacketType(typeof(TestClassNotPacketHandler)) );
public void TestGetPacketType_Type_InvalidPacketType() => Assert.Throws <ArgumentException>( () => PacketHandlerAttribute.GetPacketType(typeof(TestClassPacketHandlerInvalidPacketType)) );
public void TestIsValidHandler_Type_MismatchedAttribute() => Assert.IsFalse( PacketHandlerAttribute.IsValidHandler(typeof(TestClassPacketHandlerWithMismatchedAttribute)) );
public void TestIsValidHandler_Type_InvalidPacketType() => Assert.IsFalse( PacketHandlerAttribute.IsValidHandler(typeof(TestClassPacketHandlerInvalidPacketType)) );
public void TestGetHandlerInterface_Type_null() => Assert.Throws <ArgumentNullException>(() => PacketHandlerAttribute.GetHandlerInterface(null));