Create the Service instance with mapping in unity test

Viewed 22

I'm developing a unit test using xUnit I'am having a syntax problem on creating an instance of my service layers in my test method it shows the following message error

There is no argument given that corresponds to the required formal parameter 'mapper' of 'MunicipioAppService.MunicipioAppService

I've tried putting mapper into the parameters but didn't work

How I'm creating the instance

  [Fact]
    public async Task SearchState_ObterPorId_RetornarComSucesso()
    {
        //Arrange
        var mockStateRepo = new MockStateRepository()
                   .MockGetByID(new State());

        var stateService = new StateAppService(mockStateRepo); //Error

        //Act
        var result = StateService.ObterPorID(54);

    }

My AppService Class

 public class StateAppService : AppService<StateViewModel, IStateRepository, State>, IStateAppService
{
    public StateAppService(IStateRepository repository, IMapper mapper, INotificationHandler notificationHandler)
        : base(notificationHandler)
    {

        SetRepository(repository);
        SetMapper(mapper);
    }

    public IEnumerable<StateViewModel> ObterPorID(long stateId)
    {
        return Mapper.Map<IEnumerable<StateViewModel>>(Repository.ObterPorID(stateId));
    }
   
}
0 Answers
Related