title: How do I setup this (Moq Setup)
body: <p>I want to test my part of code that returns the users password question. So I have made a mockup of the Membership provider using Moq.</p>
  
  <p>I don't think I need to show you the actual code just the test part of it.</p>
  
  <pre><code>// Arrange
  var membershipMock = new Mock&lt;MembershipProvider&gt;();
  membershipMock.Setup(m =&gt; m.GetUser("test", false).PasswordQuestion).Returns("Password");
  authentication.Authenticate.Provider = membershipMock.Object;
  
  // Act
  var actual = authentication.PasswordRecoveryStep1(It.IsAny&lt;string&gt;());
  
  // Assert
  Assert.That(actual, Is.EqualTo("Password"));
  </code></pre>
  
  <p>So when I run this in Nunit I get this:</p>
  
  <pre><code>Test.Controllers.AuthenticationControllerTest.Test_If_Password_Recovery_Setp1_Returns_Users_PasswordQuestion:
  System.NotSupportedException : Only property accesses are supported in intermediate invocations on a setup. Unsupported expression m.GetUser("test", False).
  
  at Moq.Mock.AutoMockPropertiesVisitor.VisitMethodCall(MethodCallExpression m)
  at Moq.ExpressionVisitor.Visit(Expression exp)
  at Moq.Mock.AutoMockPropertiesVisitor.VisitMemberAccess(MemberExpression m)
  at Moq.ExpressionVisitor.Visit(Expression exp)
  at Moq.Mock.AutoMockPropertiesVisitor.SetupMocks(Expression expression)
  at Moq.Mock.GetInterceptor(LambdaExpression lambda, Mock mock)
  at Moq.Mock.&lt;&gt;c__DisplayClass15`2.&lt;SetupGet&gt;b__14()
  at Moq.PexProtector.Invoke[T](Func`1 function)
  at Moq.Mock.SetupGet[T1,TProperty](Mock mock, Expression`1 expression)
  at Moq.Mock.&lt;&gt;c__DisplayClass12`2.&lt;Setup&gt;b__11()
  at Moq.PexProtector.Invoke[T](Func`1 function)
  at Moq.Mock.Setup[T1,TResult](Mock mock, Expression`1 expression)
  at Moq.Mock`1.Setup[TResult](Expression`1 expression)
  at Test.Controllers.AuthenticationControllerTest.Test_If_Password_Recovery_Setp1_Returns_Users_PasswordQuestion() in D:\MvcApplication9\Test\Controllers\AuthenticationControllerTest.cs:line 186
  </code></pre>
  
  <p>So I am guessing it is something because of the property that I am trying to access. I am not sure how to set it up. I am not very good with lambdas (and have not been able to find a tutorial on them yet) so I am not sure if I could some how arrange it differently to make it work.</p>
  
  <p>Or if I just totally missed the mark.</p>