Exemplo n.º 1
0
    // Test adding/removing delegate to a static event.
    static bool TestInvokeStaticEventMethod()
    {
        CheckEvent(funcToTest: (action) =>
                   VersionHandler.InvokeStaticEventAddMethod(typeof(Greeter), "staticEvent", action),
                   invokeEvent: Greeter.InvokeStaticEvent,
                   expectSuccess: true,
                   expectInvoked: true);

        CheckEvent(funcToTest: (action) =>
                   VersionHandler.InvokeStaticEventRemoveMethod(typeof(Greeter), "staticEvent",
                                                                action),
                   invokeEvent: Greeter.InvokeStaticEvent,
                   expectSuccess: true,
                   expectInvoked: false);

        CheckEvent(funcToTest: (action) =>
                   VersionHandler.InvokeStaticEventAddMethod(typeof(Greeter), "foo", action),
                   invokeEvent: Greeter.InvokeStaticEvent,
                   expectSuccess: false,
                   expectInvoked: false);

        CheckEvent(funcToTest: (action) =>
                   VersionHandler.InvokeStaticEventRemoveMethod(typeof(Greeter), "foo", action),
                   invokeEvent: Greeter.InvokeStaticEvent,
                   expectSuccess: false,
                   expectInvoked: false);

        return(true);
    }