MockingContainer-generated mocks not compatible with Raise

2 posts, 0 answers
  1. Isaac Abraham
    Isaac Abraham avatar
    21 posts
    Member since:
    Sep 2009

    Posted 20 Nov 2013 Link to this post

    If I have a MockingContainer and use Get<T> on it, and then try to Mock.Raise on an event of T, I receive an error: Unable to specify which event was deduced in the parameter. If I replace that with the same type generated by Mock.Create<T>, it works.
  2. Kaloyan
    Kaloyan avatar
    880 posts

    Posted 22 Nov 2013 Link to this post

    Hello Isaac,

    I tried the following test:
    public interface IAccount
        event EventHandler<EventArgs> DepositMade;
    public class BankTransation
        readonly IAccount _fromAccount;
        public BankTransation(IAccount acc)
            this._fromAccount = acc;
        public void ShouldArrangeRaisesBehavior()
            var container = new MockingContainer<BankTransation>();
            bool eventRaised = false;
            container.Get<IAccount>().DepositMade += delegate(object sender, EventArgs args)
                eventRaised = true;
            Mock.Raise(() => container.Get<IAccount>().DepositMade += null, new EventArgs());
     and it passed.

    Could you please provide a code sample of the issue?

    Thank you for the understanding in advance.

    Share what you think about JustTrace & JustMock with us, so we can become even better! You can use the built-in feedback tool inside JustTrace, our forums, or our JustTrace or JustMock portals.
Back to Top