I am not familiar with the integration tests. How can I write an Integration test for the following code? is the Integration test similar to the Unit test? Is it possible to Mock RestClient in Nsubstitute.
public class AttachProviderService : IAttachProviderService
{
private readonly ILogger<AttachProviderService> _logger;
private readonly string AdminRead;
private readonly RestClient adminReadClient;
private readonly int _apiTimeout;
public AttachProviderService(IConfiguration configuration, ILogger<AttachProviderService> logger)
{
_logger = logger;
this.AdminMgmtReadAPI = $"{configuration["AdminRead"]}api/SearchRead/";
this.adminReadClient = new RestClient(AdminRead);
this._apiTimeout = Convert.ToInt32(configuration["Timeout"]);
}
public async Task<List<AttachProviderSearchResultViewModel>> GetAttachProviderSearchList(AttachProviderSearchViewModel attachProviderSearch)
{
RestResponse<List<AttachProviderSearchResultViewModel>> response;
try
{
_logger.LogInformation($"AttachProviderService/GetAttachProviderSearchList start");
var request = new RestRequest(AdminReadAPIConstants.GetAttachProviderSearchList, Method.Post);
request.Timeout = _apiTimeout;
request.AddJsonBody(attachProviderSearch);
response = await adminReadClient.ExecuteAsync<List<AttachProviderSearchResultViewModel>>(request);
_logger.LogInformation($"AttachProviderService/GetAttachProviderSearchList end");
}
catch (Exception ex)
{
_logger.LogInformation($"AttachProviderService/GetAttachProviderSearchList end");
throw ex;
}
return response.Data;
}
}