Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Writing a test for the default tenant #3748


User avatar
0
justinp created

Hello,

I have built a new app service that I intend for the tenants to use to create a new object. I have also seeded the database for the default tenant with several objects to test and ensure the service. However, when I write a test, I get an error and the test fails.

Message: System.InvalidOperationException : Mapper not initialized. Call Initialize with appropriate configuration. If you are trying to use mapper instances through a container or otherwise, make sure you do not have any calls to the static Mapper.Map methods, and if you're using ProjectTo or UseAsDataSource extension methods, make sure you pass in the appropriate IConfigurationProvider instance.

Since this is a template, what is the procedure for testing tenant services?


3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @JustinP,

    Probably your problem is same with #3097@1f810ef6-7cd5-4b67-a512-b037a7a77cb3. Can you check that ?

    Thanks.

  • User Avatar
    0
    justinp created

    Thanks, and I do see what you are saying. If I'm returning a Dto, it should be checked against a Dto. In fact, I don't care as long as the collection isn't empty.

    //Act
    ListResultDto<PatientListDto> patients = _patientAppService.GetPatients(new GetPatientInput());
    
    //Assert
    patients.Items.Count.ShouldBeGreaterThan(0);
    

    Message: System.IO.FileNotFoundException : Could not load the specified file.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    What I'm saying is, you should use: ObjectMapper.Map<Entity>(input); instead of using input.MapTo. Have you tried that ?

    Thanks.