lundi 11 février 2019

Mock GetAllAsync method of CosmosDBSqlRepository for xUnit

I have some functionality which is to be tested based on the result got by executing GetAllAsync method of CosmosDBSqlRepository class.

Code:

provisionDetails = await cosmosDBRepositoryClient.GetProvisionRepository()
    .GetAllAsync(filterExpressions.DuplicateAmiReferenceExpression(duplicateAmiRefFilter), token)
    .ConfigureAwait(false);

duplicateAmiRefResult.AmiDuplicateReference = (provisionDetails != null && provisionDetails.Any());
duplicateAmiRefResult.ErrorCode = FCConstants.ErrorCode_0;
return new OkObjectResult(duplicateAmiRefResult);

Signature of GetProvisionRepository function

public CosmosDBSqlRepository<IDeviceIotHubDetails> GetProvisionRepository()

I have tried all the possible ways, but could not able to mock below piece of code. Please suggest me to proceed further.

Mockable line

cosmosDBRepositoryClient.GetProvisionRepository().GetAllAsync

Aucun commentaire:

Enregistrer un commentaire