jeudi 15 mars 2018

Testing FabricClient object

I need to test a method that depends on the object System.Fabric.FabricClient. Specifically, the method reads a list of Partitions from this object:

ServicePartitionList partitions = await this.fabricClient.QueryManager.GetPartitionListAsync(serviceName);

Then, the method goes through the list and obtains data for each partition.

foreach (Partition partition in partitions)
{
    // ... code to verify
    LowKey = ((Int64RangePartitionInformation)partition.PartitionInformation).LowKey;
    PartitionId = partition.PartitionInformation.Id;
    Health = partition.HealthState;
    // ... code to verify
}

I'm using moq library for mock interfaces but I can't use it with this concrete class.

I've tried wrapping the FabricClient with an interface but all the objects implicated are abstract or sealed and I have been unable to instantiate these objects.

I also tried to use ServiceFabric.Mocks but I had no luck. I think FabricClient needs the service running to work.

As a summary, what I need is that the FabricClient object does not throw me any errors when I try to read the partition list and, if possible, get fake values from it.

Aucun commentaire:

Enregistrer un commentaire