I am a .NET guy, and I'm mostly C # code.
Starting with C # 3.0, we can use lambda expressions and expression trees to use static reflection . For example, you can implement GetMethodNamein the following snippet to return the name of the method passed in the parameter:
string methodName = GetMethodName( o => o.DoSomething());
Console.WriteLine(methodName);
Now, when I look at samples of Mockito (or EasyMock) in the java world, I see:
LinkedList mockedList = mock(LinkedList.class);
when(mockedList.get(0)).thenReturn("first");
How it works?
How does the method work when? How to interpret it mockedList.get(0)as a call to the get method with 0 passed as a parameter, and not as a value?
source
share