How to create a test double for DataLakeDirectoryClient object of Azure.Storage.Files.DataLake c# library?

My code is accessing or precisely downloading the file from Azure’s DataLake Storage Gen2. That file is placed by an upstream system of our application. The files are organized hierarchy of directories.

A typical hierarchy of the file will be:
sample-container/process_Id_12/task_id_34/year2024/month7/day10/file.csv

The functionality of my Subject Under test (GetFiles method) is navigating to correct directory, identify the correct file by a pattern and finally get it as stream.

using Azure.Storage.Files.DataLake;

public class DataLakeService
{
   //this object is pointing to the directory "sample-container/process_Id_12/"
   private DataLakeDirectoryClient downloadClient;

   private readonly string taskid = "task_id_34";
   public DataLakeService(DataLakeDirectoryClient dataLakeDirectoryClient)
   {
        this.downloadClient = dataLakeDirectoryClient;
   }

   public IAsyncEnumerable<Stream> GetFiles(DateTime processingDate)
   {
       DataLakeDirectoryClient dir = downloadClient.GetSubDirectoryClient(taskid)
                                             .GetSubDirectoryClient($"year{processingDate.Year}")
                                             .GetSubDirectoryClient($"month{processingDate.Month}");

       if(!dir.Exists()){
           return AsyncEnumerable.Empty<Stream>();
       }
       var pathItems = dir.GetPathsAsync(true);
       await foreach(var pathItem in pathItems)
       {
            string absoluteFullPathToFile = pathItem.Name; //e.g., sample-container/process_Id_12/task_id_34/year2024/month7/day10/file.csv
            string fileName = System.IO.Path.GetFileName(absoluteFullPathToFile);
            if(!IsRegexPatternMatch(fileName))
            {
                 continue;
            }
            var continer = downloadClient.GetParentFileSystemClient();
            string pathToDirectory = System.IO.Path.GetDirectoryName(absoluteFullPathToFile);
            var directoryClient = container.GetDirectoryClient(pathToDirectory);
            var fileClient = directoryClient.GetFileClient(fileName);
            yield return await fileClient.OpenReadAsync();
       }


   }
}

My dotnet 6 application is using NUnit 3.12.0 , Moq 4.14.5 frameworks. To test GetFiles method, I have mocked **DataLakeDirectoryClient **dependency using Moq. But it feels like I am deceiving myself with the mock setups for DataLakeDirectoryClient‘s method calls.

The thing I stuck with is to setup a protected method of base class of DataLakeDirectoryClient.

DataLakeDirectoryClient class is derived from DataLakePathClient
That particular protected method of base class is invoked in through a Extenstion method of base class (the extension method GetParentFileSystemClient’s definition)

I tried as below:

using Nunit.Framework;
using Moq;
public class DataLakeService
{
    public async Task GetFiles_WhenSingleFileInStorage_ThenReturnAStream()
    {
        //Arrange
        var mockDirectoryClient = new Mock<DataLakeDirectoryClient>();
        mockDirectoryClient
              .Setup(dc => dc.GetSubDirectoryClient(It.IsAny<string>()))
              .Returns(mockDirectoryClient.Object);
        mockDirectoryClient
              .Setup(dc => dc.Exists(default(CancelationToken)))
              .Returns(Response.FromValue(true, Mock.Of<Response>()));

        mockDirectoryClient
              .Setup(dc => dc.GetPathsAsync(true, false, default))
              .Returns(() => {
                  var pathItem1 = DataLakeModelFactory
                   .PathItem("sample-container/process_Id_12/task_id_34/year2024/month7/day10/file.csv",
                               false, new DateTime(2024, 7, 10), ETag.All, 256, "", "", "");
                  var pathItem2 = DataLakeModelFactory
                   .PathItem("sample-container/process_Id_12/task_id_34/year2024/month7/day10/file.txt",
                               false, new DateTime(2024, 7, 10), ETag.All, 256, "", "", "");
                  var page1 = Page<PathItem>.FromValues(values: new[] { pathItem1, pathItem2 },
                                       continuationToken: null, response: Mock.Of<Response>());

                  return AsyncPageable<PathItem>.FromPages(new[] { page1 });

               });
         var mockFileSystemClient = new Mock<DataLakeFileSystemClient>();
         mockFileSystemClient.Setup(fsc => fsc.GetDirectoryClient(It.IsAny<string>()))
                    .Returns(mockDirectoryClient.Object);

         var mockFileClient = new Mock<DataLakeFileClient>();
         Stream stream = BinaryData.FromString("This is a line.n This is the second linen").ToStream();
         mockFileClient.Setup(fc => fc.OpenReadAsync(0, default, default, default))
                .Returns(Task.FromResult(stream));
         mockDirectoryClient
              .Setup(dc => dc.GetFileClient(It.IsAny<string>()))
              .Returns(mockFileClient.Object);

         // DataLakeDirectoryClient's GetParentFileSystemClient method get invoked in the SUT
         // To set up that method, I have tried both below

         mockDirectoryClient.Protected()
              .Setup<DataLakeFileSystemClient>("GetParentDataLakeFileSystemClientCore")
              .Returns(mockFileSystemClient.Object);

         //Error for above is "No protected method DataLakeDirectoryClient.GetParentDataLakeFileSystemClientCore found whose signature is compatible with the provided arguments ()."

         mockDirectoryClient
              .Setup(dc => dc.GetParentFileSystemClient())
              .Returns(mockFileSystemClient.Object);
         // Error: "Unsupported expression : dc => dc.GetParentFileSystemClient()
         // Extension meethods(here: SpecializedDataLakeExtensions.GetParentFileSystemClient) May not be used in setup / verification expression "
      
            
        //Act
        //Assert
    }
}

So How to set up the call to this extension method or protected member of base class ?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật