title: MV3 Test Project with Moq, how to return an object when certain expression is used?
body: <p>Here is my code:</p>
  
  <pre><code>    [TestMethod]
      public void LoginUnregisteredUserShouldFail()
      {
          Mock&lt;IRepository&lt;User&gt;&gt; _repo = new Mock&lt;IRepository&lt;User&gt;&gt;();
          UserServiceForTest target = new UserServiceForTest(_repo.Object, new HashingService());
  
          var unregisteredTestUser = new User() { Email = "a", Nombre = "test", Password = "test" };
          var registeredHashedTestUser = new User() { Email = "test@test.com", Nombre = "test", Password = "qUqP5cyxm6YcTAhz05Hph5gvu9M=" };
          Expression&lt;Func&lt;User, bool&gt;&gt; expression = a =&gt; a.Email == "a";
          _repo.Setup(a =&gt; a.Single(It.Is&lt;Expression&lt;Func&lt;User,bool&gt;&gt;&gt;(l =&gt; l.ToString() == expression.ToString()))).Returns(unregisteredTestUser);
          Assert.IsFalse(target.ValidateCredentials(unregisteredTestUser));
      }
  </code></pre>
  
  <p>I want to query the Single method of my repo, matching Email, and I want the result to be the specified User.</p>
  
  <p>I dont know what I'm doing wrong but I always receive null.</p>
  
  <p>EDIT:
  My implementation is the following: </p>
  
  <pre><code>    private string GetUserPasswordFromDbByUserName(string userName)
      {
          Expression&lt;Func&lt;User, bool&gt;&gt; ax = a =&gt; a.Email == userName;
          var axx = ax.ToString();
          var user = _repo.Single(ax);
          if (user != null)
              return user.Password;
          else
              return string.Empty;
      }
  </code></pre>
  
  <p>It receives a string userName and for some reason, the .ToString() returns 'a => (a.Email == value(Casita.Services.UserService+&lt;>c__DisplayClass5).userName)' instead of 'a => (a.Email == "a")'. Makes no sense to me, but I'm guessing this is the reason the comparison is failing.</p>