title: Moq not resolving ICollection reference
body: <p>I am using Moq.4.2.1507.0118 and I'm having a problem that I have not seen before. The situation is that I have two classes in my model (A and B) with a one to many relationship. For example:</p>
  
  <pre><code>[Table("A")]
  public partial class A
  {
  
      public A()
      {
          this.theB = new HashSet&lt;B&gt;();
      }
  
      [Key]
      public int AId{ get; set; }
      public string Name{ get; set; }
  
      public virtual ICollection&lt;B&gt; theB{ get; set; }
  
  }
  
  [Table("B")]
  public partial class B
  {
      [Key]
      public int BId{ get; set; }
      public int AId{ get; set; }
      public virtual A theA { get; set; }
  }
  </code></pre>
  
  <p>Of course I also have the DbSet's defined in the DbContext.</p>
  
  <p>Then, in my test code, I have:</p>
  
  <pre><code>    [TestMethod]
      public void SomeTest()
      {
          var theAs = new List&lt;A&gt;
          {
              new A{ AId=1, Name="test" }
          };
          var theBs= new List&lt;B&gt;
          {
              new B{ BId=1, AId=1, theA=theAs[0] }
          };
  
          var ASet= new Mock&lt;DbSet&lt;A&gt;&gt;().SetupData(theAs);
          var BSet= new Mock&lt;DbSet&lt;B&gt;&gt;().SetupData(theBs);
  
          var context = new Mock&lt;MyContext&gt;();
          context.Setup(s =&gt; s.A).Returns(ASet.Object);
          context.Setup(s =&gt; s.B).Returns(BSet.Object);
  
          var m = new ClassThatImTesting(context);
          m.someMethod("test");
      }
  </code></pre>
  
  <p>Normally I would see that this is enough to let A and B know about each other in the mock context. However, in the method that I'm testing, if I run something like this:</p>
  
  <pre><code>var result = context.A.Where(x =&gt; x.theB.Count() &gt; 0).FirstOrDefault();
  </code></pre>
  
  <p>I get null. Since I've done this in so many other tests without a problem, I'm having a hard time seeing what I've done to trip this up. Any ideas would be helpful! I've simplified this example from my actual code, so please forgive syntax errors.</p>