Appccelerate.EventBroker.ReflectionMethodHandleProblem.DoesNotIntroduceGhostMethodsThroughRegistrationAndHandlingEvents C# (CSharp) Method

DoesNotIntroduceGhostMethodsThroughRegistrationAndHandlingEvents() private method

        public void DoesNotIntroduceGhostMethodsThroughRegistrationAndHandlingEvents()
        {
            this.testee = new EventBroker();

            ITestPublisher testPublisher = new MyPublisher();
            ITestSubscriber testSubscriber = new MySubscriber();

            int initialMethodCount = testSubscriber.GetType().GetMethods().GetLength(0);

            this.testee.Register(testPublisher);

            int methodCountAfterRegisteringPublisher = testSubscriber.GetType().GetMethods().GetLength(0);

            this.testee.Register(testSubscriber);

            int methodCountAfterRegisteringSubscriber = testSubscriber.GetType().GetMethods().GetLength(0);

            testPublisher.FireEvent();

            int methodCountAfterFiringEvent = testSubscriber.GetType().GetMethods().GetLength(0);

            methodCountAfterRegisteringPublisher.Should().Be(initialMethodCount, "registration of publisher should not introduce ghost methods");
            methodCountAfterRegisteringSubscriber.Should().Be(initialMethodCount, "registration of subscriber should not introduce ghost methods");
            methodCountAfterFiringEvent.Should().Be(initialMethodCount, "calling handler method should not introduce ghost methods");

            testSubscriber.MyValue.Should().Be(6);
        }