I have the following interface
that I like to fake:
public interface ElementSettings
{
ValueFormatter Formatter { get; }
IEnumerable<ValidationRule> GetValidationRules();
}
I would like to throw an exception, when the Formatter
is gotten. I tried it the following way:
var settings = Substitute.For<ElementSettings>();
var exception = new ArgumentException("alidsfjmlisa");
settings.When(s => { var tmp = s.Formatter; }).Throws(exception);
But I get allways a CouldNotSetReturnDueToNoLastCallException
in the last line of the code. I have read all the hints in the exception message, but can't find any misusage.