confluentinc / confluent-kafka-dotnet

Confluent's Apache Kafka .NET client
https://github.com/confluentinc/confluent-kafka-dotnet/wiki
Apache License 2.0
2.78k stars 847 forks source link

IAdminClient mocking with extension methods #2227

Open mlapaglia opened 1 month ago

mlapaglia commented 1 month ago

Description

Are there any ways to use Moq with the IAdminClient extension methods? I am trying to test code that has a admin client calling DescribeTopicsAsync but can't mock due to it being an extension method.

How to reproduce

latest confluent nuget package.

var mockedAdminClient = new Mock<IAdminClient>();
mockedAdminClient.Setup(x => x.DescribeTopicsAsync(arguments);
//fails because `DescribeTopicsAsync` is static method.

AdminClient is internal, but DescribeTopicsAsync just turns around and calls the same method on the class

Checklist

Please provide the following information: