title: How do I setup MOQ without Repository? System.NullReferenceException: 'Object reference not set to an instance of an object
body: <p>This is the constructor of my test class</p>
  <pre><code>public IngestServiceTest()
  {
      IConfiguration configuration = new ConfigurationBuilder().AddJsonFile(&quot;appsettings.test.json&quot;).Build();
      _logger = LoggerFactory.Create(builder =&gt; builder.AddConsole()).CreateLogger&lt;object&gt;();
      
      var fileProcessLogDbSetMock = new Mock&lt;DbSet&lt;FileProcessLog&gt;&gt;();
      mockDowJonesContext.Setup(s =&gt; s.FileProcessLogs).Returns(fileProcessLogDbSetMock.Object);
      ingestService = new IngestService(mockDowJonesContext.Object, configuration, _logger);
  }
  </code></pre>
  <p>But it hits <code>System.NullReferenceException: 'Object reference not set to an instance of an object.'</code> at <code>mockDowJonesContext.Setup(s =&gt; s.FileProcessLogs).Returns(fileProcessLogDbSetMock.Object);</code></p>
  <p>I see many tutorial but it is with Repository but mine is without Repository.</p>