Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to Raise events based on a matched type? #32

Open
denxorz opened this issue May 18, 2017 · 0 comments
Open

Is it possible to Raise events based on a matched type? #32

denxorz opened this issue May 18, 2017 · 0 comments

Comments

@denxorz
Copy link

denxorz commented May 18, 2017

Is it possible to raise an event based on a type found by It.Is? Put an example in the test below.

    [TestCase]
    public void Raise_NonStaticEventBasedOnMatch_OriginalEventInvokesSubscribers()
    {
        int invocationCount = 0;

        Smock.Run(context =>
        {
            ClassWithEvents instance = new ClassWithEvents();

            instance.TheEvent += (sender, args) => ++invocationCount;

            instance.RaiseTheEvent(EventArgs.Empty);
            context.Raise(() => It.IsAny<ClassWithEvents>().TheEvent += null, () => It.IsAny<ClassWithEvents>().TheEvent -= null, EventArgs.Empty);
        });

        Assert.AreEqual(2, invocationCount);
    }

Thanks for the great plugin.
Dennis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant