0

Int64RangePartitionInformation - how can I create object? I want to use object in my unit test. When I attempt to create object using var c = new Int64RangePartitionInformation(); compiler throws me error 'Int64RangePartitionInformation' does not contain a constructor that takes 0 arguments"

I don't see any constructor for this class either. How this type of non-instantiable class is implemented? If I want to , how can i instantiate it?

Datha
  • 655
  • 1
  • 5
  • 12

3 Answers3

0

One solution, although not very nice, is:

FormatterServices.GetUninitializedObject(
    typeof(Int64RangePartitionInformation)) as Int64RangePartitionInformation;
jamesmus
  • 319
  • 1
  • 9
0

Since you're testing, you could create a mock and use that. For instance with Moq, you could do

var partitionInformation = new Mock<Int64RangePartitionInformation>().Object;
DoSomething(partitionInformation);
Hans Kilian
  • 18,948
  • 1
  • 26
  • 35
0

If you wish to mock Int64RangePartitionInformation, you can use the ServiceFabric.Mocks library and create mock of Int64RangePartitionInformation as

var mockPartitionInfo = MockQueryPartitionFactory.CreateIntPartitonInfo();

NuGet package: ServiceFabric.Mocks

GitHub link

Vivek Sharma
  • 1,912
  • 1
  • 13
  • 15