title: DotNet Core Console Application: AutoMapper
body: <p>Hello I am using AutoMapper in DotNet Core Console Application</p>
  
  <p>StartUp file:</p>
  
  <pre><code>public class StartUp
  {
      public  void ConfigureServices(IServiceCollection services) {  
      services.AddAutoMapper();  
  }  
  }
  </code></pre>
  
  <p>Mapping File:</p>
  
  <pre><code>public class MappingProfile: Profile {  
      public MappingProfile() {  
           CreateMap &lt; Employee, EmployeeModel &gt; ().ForMember(dest =&gt; dest.Address, opts =&gt; opts.MapFrom(src =&gt; new Address {  
              City = src.City, State = src.State   }));  
      }  
  }  
  </code></pre>
  
  <p>UnitTest Class:</p>
  
  <pre><code> public class UnitTest1
      {
           private readonly IMapper _mapper;  
          public UnitTest1(IMapper mapper)
          {
               _mapper = mapper;  
          }
  
          [Fact]
          public void Test1()
          {  
  
              Employee  emp = new Employee ();  
              emp.Id=1;
              emp.Name="Test";
             var empmodel = _mapper.Map &lt; Employee, EmployeeModel &gt; (emp);  
             Assert.Equal(empmodel.Name,"Test");
              Assert.Equal(empmodel.Id,1);
  
          }
      }
  </code></pre>
  
  <p>Reference Link: <a href="https://www.c-sharpcorner.com/article/how-to-implement-automapper-in-asp-net-core-mvc-application/" rel="nofollow noreferrer">https://www.c-sharpcorner.com/article/how-to-implement-automapper-in-asp-net-core-mvc-application/</a></p>
  
  <p>I am Getting below error on running test file: 
  Error Message:</p>
  
  <blockquote>
    <p>The following constructor parameters did not have matching fixture
    data: IMapper mapper</p>
  </blockquote>
  
  <p>Thank you </p>