This is a migrated thread and some comments may be shown as answers.

MockingContainer-generated mocks not compatible with Raise

1 Answer 88 Views
JustMock Free Edition
This is a migrated thread and some comments may be shown as answers.
Isaac Abraham
Top achievements
Rank 1
Isaac Abraham asked on 20 Nov 2013, 01:25 PM
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.

1 Answer, 1 is accepted

Sort by
0
Kaloyan
Telerik team
answered on 22 Nov 2013, 01:24 PM
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;
    }
}
 
    [TestMethod]
    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());
         
        Assert.IsTrue(eventRaised);
    }
 and it passed.

Could you please provide a code sample of the issue?

Thank you for the understanding in advance.

Regards,
Kaloyan
Telerik
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.
Tags
JustMock Free Edition
Asked by
Isaac Abraham
Top achievements
Rank 1
Answers by
Kaloyan
Telerik team
Share this question
or