mardi 1 décembre 2015

Mocking a Single Bucket object in ElasticSearch using Moq

I'm using Moq to mock a SingleBucket object in ElasticSearch. Basically I need to have it return 5 documents (property .DocCount)

var sb = new Mock<SingleBucket>();
sb.SetupGet(x => x.DocCount).Returns(5);

I tried that and I get an exception:

{System.NotSupportedException: Invalid setup on a non-virtual
(overridable in VB) member: x => x.DocCount

What's wrong with this code? Seems to be ok to mock a property using SetupGet

I know I should mock either the interface or a virtual method. Is there any chance to mock that object property?

Aucun commentaire:

Enregistrer un commentaire