title: How to mock up Get Functions with lots of properties returned?
body: <p>I am fairly new to writing unit tests but get the general idea behind it and why we should do it. I have been looking around for an answer to this because what I am currently doing seems a bit cumbersome.</p>
  <p><strong>Relevant Info:</strong></p>
  <ul>
  <li>Using Moq V 4.16.0</li>
  <li>Using Unit of Work / Generic Repo Pattern</li>
  <li>MVC 5.2.7</li>
  </ul>
  <p><strong>My Problem:</strong></p>
  <p>So the issue I am facing is lets say I have a &quot;service&quot; called <strong>OrderService</strong>. Lets say this service has a function called <strong>GetOrders()</strong> where all it does it query the db, transform it into a VM, and returns all the order data.</p>
  <p>The problem I am having is my view model has about 20+ properties and when trying to write the unit test for this I think I am going to have to initialize every single variable. See code below.</p>
  <p><strong>GetOrders:</strong></p>
  <pre><code>public IEnumerable&lt;OrderViewModel&gt; GetOrders()
      {
          return _unitOfWork.OrderRepository.Get().Select(x =&gt; new OrderViewModel
          {
              ActualDraftingHours = x.ActualDraftingHours,
              ActualEngineeredHours = x.ActualEngineeredHours,
              CreatedAt = x.CreatedAt,
              Comments = x.Comments,
              CustomerId = x.CustomerId,
              EstimatedCompletionDate = x.EstimatedCompletionDate,
              EstimatedHours = x.EstimatedHours,
              SalesOrderNumber = x.SalesOrderNumber,
              EstimatedHoursChangedComment = x.EstimatedHoursChangedComment,
              EstimatedHoursChanged = x.EstimatedHoursChanged,
              PullUpDate = x.PullUpDate,
              OrderTotal = x.OrderTotal,
              EstimatedStartDate = x.EstimatedStartDate,
              StatusId = x.StatusId,
              PulledUp = !string.IsNullOrEmpty(x.PullUpComment),
              RequestTypeId = x.RequestTypeId,
              ScheduledById = x.ScheduledById,
              ScheduledCompletionDate = x.ScheduledCompletionDate,
              CheckedOutById = x.CheckedOutById,
              PullUpComment = x.PullUpComment,
              ActualCompletionDate = x.ActualCompletionDate,
              Id = x.Id
          }).ToList();
      }
  </code></pre>
  <p><strong>Unit Test</strong></p>
  <pre><code>[TestMethod]
      public void TestGetOrders()
      {
          //Arrange
          var now = DateTime.Now;
          List&lt;Order&gt; MockScheduledOrders = new List&lt;Order&gt;(); //List of orders returned from repo
          MockScheduledOrders.Add(new Order { ScheduledCompletionDate = now.AddDays(1),ActualDraftingHours = 5, ActualEngineeredHours = 6,.... });
          MockScheduledOrders.Add(new Order { ScheduledCompletionDate = now.AddDays(2), ActualDraftingHours = 5, ActualEngineeredHours = 8, .... });
          MockScheduledOrders.Add(new Order { ScheduledCompletionDate = now.AddDays(3), ActualDraftingHours = 4, ActualEngineeredHours = 6, .... });
          MockScheduledOrders.Add(new Order { ScheduledCompletionDate = now.AddDays(4), ActualDraftingHours = 5, ActualEngineeredHours = 7, .... });
          MockScheduledOrders.Add(new Order { ScheduledCompletionDate = now.AddDays(5), ActualDraftingHours = 9, ActualEngineeredHours = 2, .... });
          MockScheduledOrders.Add(new Order { ScheduledCompletionDate = now.AddDays(5), ActualDraftingHours = 5, ActualEngineeredHours = 6, .... });
          //var Expected = ...VM version of above
          var unitOfWorkMock = new Mock&lt;IUnitOfWork&gt;();
          unitOfWorkMock.Setup(x =&gt; x.OrderRepository.Get()).Returns(MockScheduledOrders).Verifiable();
          IOrderService service = new OrderService(unitOfWorkMock.Object);
  
          //Act
          var actual = service.GetOrders();
  
          //Assert
          //For loop and assert that Expected[i].Property = MockScheduledOrders[i].property
      }
  </code></pre>
  <p>Basically what I am asking is if there is a better way  to test Get functions that may return lots of data? Am I just doing this completely wrong or is there some best practice approach that can be recommended? I just feel initializing 20+ properties for every value in a list seems a bit excessive.</p>
  <p>I want to basically test that every property is assigned to and returned in the GetOrders function. Any recommendation or advice on general practice or tools available to help with this sort of thing would be fantastic!</p>
  <p>Thank you,</p>