title: How do I unit test a method to add an item to a database?
body: <p>I have an item and I am adding it to the database using this method:</p>
  
  <pre><code>public Messages addItem(Item item)
  {
  
      Messages resultMessage = Messages.Success;
  
      using (IUnitOfWork unitOfWork = new UnitOfWork())
      {
          IItemRepository itemRep = new ItemRepository(unitOfWork);
  
          try
          {
              itemRep.Insert(item);
  
              unitOfWork.Commit();
          }
          catch (Exception e)
          {
              Console.WriteLine(e.StackTrace);
              resultMessage = Messages.DB_Failure;
          }
      }    
      return resultMessage;   
  }
  </code></pre>
  
  <p>Now I have to make write a unit test for this method to check if the item is being added to the database. I have no idea how I should do that, can someone help me?</p>