title: List of objects dissapears in the method i'm testing with Moq mocking and unittests in ASP.net
body: <p>Ok i'm having trouble to form a good qeustion so please don't flame me on that what i'm trying to do in my code is moqing a list of which i get 1 object in the list. This object is retrieved by a .find method in the moqed database. It however doesn't return values because somehow in the method the data dissappears and my Person object is left with null i'll post some screenshots that will hopefully explain what i'm trying to say together with the testing method i'm using:</p>
  
  <p>the method:</p>
  
  <pre><code>[TestMethod]
          public void TestDetails()
          {
              Person test = new Person();
              test.ID = 1;
              test.City = "Eindhoven Area, Netherlands.";
              test.Name = "Marijn van Donkelaar";
              test.LearntSkillsAndLevelOfSkills = "Java:7, C#:4, SQL:4, PLSQL:4, Software Documentation:4, Software Development:4, HTML:2, CSS:2, jQuery:1";
              test.ProfileImage = "/Images/hollemar.jpg";
              test.PhoneNr = "0612345678";
              test.SkillsToLearn = "ASP.net:2, JAVA:2";
              test.Email = "fraylight@gmail.com";
              Person test1 = new Person();
              test1.ID = 2;
              test1.City = "Eindhoven Area, Netherlands.";
              test1.Name = "Jan Pietjes";
              test1.LearntSkillsAndLevelOfSkills = "Java:7, C#:4, SQL:4, PLSQL:4, Software Documentation:4, Software Development:4, HTML:2, CSS:2, jQuery:1";
              test1.ProfileImage = "/Images/hollemar.jpg";
              test1.PhoneNr = "0612345678";
              test1.SkillsToLearn = "ASP.net:2, JAVA:2";
              test1.Email = "fraylight@gmail.com";
              Person test2 = new Person();
              test2.ID = 3;
              test2.City = "Eindhoven Area, Netherlands.";
              test2.Name = "Jasmine Test";
              test2.LearntSkillsAndLevelOfSkills = "Java:7, C#:4, SQL:4, PLSQL:4, Software Documentation:4, Software Development:4, HTML:2, CSS:2, jQuery:1";
              test2.ProfileImage = "/Images/hollemar.jpg";
              test2.PhoneNr = "0612345678";
              test2.SkillsToLearn = "ASP.net:2, JAVA:2";
              test2.Email = "fraylight@gmail.com";
  
              var data = new List&lt;Person&gt; { test, test1, test2 }.AsQueryable();
  
              var mockSet = new Mock&lt;DbSet&lt;Person&gt;&gt;();
              mockSet.As&lt;IQueryable&lt;Person&gt;&gt;().Setup(m =&gt; m.Provider).Returns(data.Provider);
              mockSet.As&lt;IQueryable&lt;Person&gt;&gt;().Setup(m =&gt; m.Expression).Returns(data.Expression);
              mockSet.As&lt;IQueryable&lt;Person&gt;&gt;().Setup(m =&gt; m.ElementType).Returns(data.ElementType);
              mockSet.As&lt;IQueryable&lt;Person&gt;&gt;().Setup(m =&gt; m.GetEnumerator()).Returns(data.GetEnumerator()); 
  
              var mockContext = new Mock&lt;PersonDBContext&gt;();
  
              mockContext.Setup(m =&gt; m.Persons).Returns(mockSet.Object);
  
  
              var service = new PersonController(mockContext.Object);
  
              ActionResult person = service.Details(1);
  
  
          }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/1vgan.png" alt="The first example in which you can see the data"></p>
  
  <p><img src="https://i.stack.imgur.com/PsMEH.png" alt="The second example in which you can no longer see the data"></p>
  
  <p>is there any particular reason for this? because i honestly don't see it. i figured it might be because the moq data only thinks it has to be called once and then dissappears but i have no idea... and i did check the data and saw that the ID that is given (1) is added to 1 of the objects and it's also visible in that passed on list</p>
  
  <p>thanks in advance, <br/>
  Marijn</p>