title: How to mock up dbcontext?
body: <p>I am using Entity Framework 7 in .net core 1.0 rc2. Here is the class.</p>
  
  <pre><code>public class ApplicationDbContext : DbContext
  {
      public ApplicationDbContext(DbContextOptions&lt;ApplicationDbContext&gt; options) : base(options)
      {
  
      }
      public DbSet&lt;Blog&gt; Blogs { get; set; }
  }
  </code></pre>
  
  <p>Then inject the <code>ApplicationDbContext</code> to a class</p>
  
  <pre><code>public class BtnValidator
  {
      private readonly ApplicationDbContext _dbContext;
      public BtnValidator(ApplicationDbContext dbContext)
      {
          _dbContext = dbContext;
      }
  }
  </code></pre>
  
  <p>Not sure how to mock it in unit test method.</p>
  
  <pre><code>[Fact]
  public void Ensure_Proper_Btn_Validated_Return_True()
  {
      var dbContext = mockup(ApplicationDbContext); //how
  
      var validator = new BtnValidator(dbContext);
      var results = validator.IsValid("1234");
      Assure.True(results);
  }
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>In <code>BtnValidator</code>, I have code to access the <code>dbContext</code>.</p>
  
  <pre><code>public IsValid(string ID)
  {
      var results = _dbContext.Blogs.First(x =&gt; x.ID);
      // 
  }
  </code></pre>