How to to fix Lambda expression?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NewToOracle
    New Member
    • Feb 2009
    • 15

    How to to fix Lambda expression?

    Hi,

    Can anybody please help me to fix below error.

    Code:
    Isolate.Whencalled[B](()=> myfakeObject[/B].Method1()).WillReturn("Method1");
    At the myfakeObject it is showing Error Message:
    ")" Expected

    At the Closing paranthesis of Whencalled it is showing Error Message : Invalid expression Term ")"

    Thanks!
  • balabaster
    Recognized Expert Contributor
    • Mar 2007
    • 798

    #2
    Just a hunch as I have no way to test this. I dunno what Isolate.WhenCal led is doing as I haven't seen the signature, but as a lambda, could you be treating the method as a delegate? i.e. remove the brackets:

    Code:
    Isolate.WhenCalled(() => myFakeObject.Method1).WillReturn("Method1");
    Usually in cases where you're referencing a delegate, you are pointing to the method, not calling the method. Similar to:

    Code:
    delegate mydlg = myFakeObject.Method1; //Notice no trailing brackets on Method1 which would indicate immediate invocation.
    mydlg.Invoke();

    Comment

    Working...