I'm trying to get nsubstitute to mock an instance of IStringLocalizer
like this
var mock = Substitute.For<IStringLocalizer<SomeClass>>();
mock["Foo"].Returns("Bar");
Assert.That(mock["Foo"], Is.EqualTo("Bar"));
How can I do this?
I'm trying to get nsubstitute to mock an instance of IStringLocalizer
like this
var mock = Substitute.For<IStringLocalizer<SomeClass>>();
mock["Foo"].Returns("Bar");
Assert.That(mock["Foo"], Is.EqualTo("Bar"));
How can I do this?
Try this:
In documentation of
IStringLocalizer
you can see that indexer of this type are returnsLocalizedString
which can not be explicit/implicit cast toSystem.String
so you need to specify explicitly newLocalizedString
forReturns
method.