title: Unit testing if a method is creating a record in Database
body: <p>Just started learning and writing unit testing a day ago so this is probably too simple question:</p>
  
  <p>I have this method in my <code>DBTaskHanlder</code> class  that I want to do some unit for, I was able to write one for when ModelState is not valid but now for next one:</p>
  
  <pre><code>public bool CreateTask(ForgotPasswordViewModel fpModel)
  {
      if (!ModelState.IsValid)
      {
          return false;
      }
  
      try
      {
           CreateTaskFromModel(fpModel);
          _dbContext.SaveChanges();
          return true;
      }
      catch (Exception e)
      {
          var issue = e.ToString();
          throw;
      }
  }
  </code></pre>
  
  <p>That <code>CreateTaskFromModel</code> is a <code>private</code> method and well called its job is to create a new row in database on a table. 
  So I wanted to test when this method is called is one new row getting created in DB?
  Is it actually the correct thing to test? How to test ? I don't think we should hit and insert into the real database right? </p>
  
  <pre><code>   private void CreateTaskFromModel(ForgotPasswordViewModel fpModel)
      {
          var message = _dbContext.Create&lt;Message&gt;();          
          message.MessageType = "TASK".PadLeft(10);
          message.Assigned_User_K = fpModel.SendPasswordRequestTo.Trim();
          message.Assigned_Date = DateTime.Today;
          message.Source_User_K = string.Empty;
          message.Target_File_K = "WEBCFGPHRM";           
          message.Owner_User_K = string.Empty;
          message.Message_K = _keyGenerator.Get10ByteBase36Key();
  
          _dbContext.Messages.Add(message);
      }
  </code></pre>