title: Automapper cannot convert to a type
body: <p>I am getting "Cannot Convert type 'PlanEntity' to 'TDestination'" compile time error while mocking my auto mapper in Unit Tests. </p>
  
  <pre><code>public TDestination Map&lt;TSource, TDestination&gt;(TSource source) where TDestination : class
              {
                  var value = source as PlanEntity;
                  if (value != null)
                  {
                      return (TDestination)value;
                  }
  
                  return null;
  
              }
  </code></pre>
  
  <p>However when I map IEnumerable it is running just fine. </p>
  
  <pre><code>public TDestination Map&lt;TDestination&gt;(object source) where TDestination : class
              {
                  var value = source as IEnumerable&lt;PlanEntity&gt;;
  
                  if (value != null)
                  {
                      var results = value.Select(i =&gt;
                          new PlanModel
                          {
                              Id = i.Id,
                              Name = i.Name
                          });
  
                      return (TDestination)results;
                  }
  
                  return null;
              }
  </code></pre>
  
  <p>I have also tried doing this but it is giving the same error. </p>
  
  <pre><code>public TDestination Map&lt;TSource, TDestination&gt;(TSource source) where TDestination : class
              {
                  var value = source as PlanEntity;
                  if (value != null)
                  {
                      var planModel = new PlanModel
                      {
                          Id = value.Id,
                          Name = value.Name
                      };
                      return (TDestination)planModel;
                  }
  
                  return null;
  
              }
  </code></pre>
  
  <p>There are three overrides in my mockMapper class. </p>
  
  <pre><code>TDestination Map&lt;TSource, TDestination&gt;(TSource source) where TDestination : class;
  TDestination Map&lt;TSource, TDestination&gt;(TSource source, TDestination destination) where TDestination : class;
  TDestination Map&lt;TDestination&gt;(object source) where TDestination : class;
  </code></pre>
  
  <p>Can anyone help me out with this ?</p>