NSubstitute Substitute Azure storage blob DownloadContentAsync()

I'm using azure blob container to download container content and do some stuff, here is my code:

public async Task<IEnumerable<MyData>> ReadBlobContent(BlobClient blob)
    var blobContent = await blob.DownloadContentAsync();
    var blobContentAsString = Encoding.UTF8.GetString(blobContent.Value.Content.ToArray());
    var jsonSerializerOptions = new JsonSerializerOptions
        PropertyNameCaseInsensitive = true
    return JsonSerializer.Deserialize<IEnumerable<MyData>>(blobContentAsString, jsonSerializerOptions);

I want to test the behavior of this code which is already called somewhere else, I'm using .NET Core 3.1 with xUnit and NSubstitute

I'm stuck with substituting the download process, I already did this:

_blobClient = Substitute.For<BlobClient>();
_blobContainerClient = Substitute.For<BlobContainerClient>();

_blobDownloadResult = Substitute.For<Response<BlobDownloadResult>>();

   .Returns(Substitute.For<Func<NSubstitute.Core.CallInfo, BlobDownloadResult>>());

    .Returns(Substitute.For<BinaryData>()); //here it throws System.NullReferenceException: 'Object reference not set to an instance of an object.'


Always the result value returned from the download is null, I want to mock it so that I could retrieve the download content and do the needed assertions.

Could you please challenge me on this issue?

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum