Getting the following error trying to use CallTo()
and .Returns()
on methods of interfaces.
Severity Code Description Project File Line Suppression State Error CS1929 'IReturnValueArgumentValidationConfiguration' does not contain a definition for 'Returns' and the best extension method overload 'ReturnValueConfigurationExtensions.Returns(IReturnValueConfiguration>, string)' requires a receiver of type 'IReturnValueConfiguration>' CareControls.Ivis.Tests G:\Ivis\CareControls.Ivis.Tests\Framework\AbIo\TimerHandlerTests.cs 105 Active
Here is the test: I added comments to show what kind each type was and where the compiler errors were occurring.
[Fact]
public void Reads_AbPlc_at_each_inputs_label()
{
var abPlc = A.Fake<AbPlc>(); // interface
var input1 = A.Fake<ToggleUi>(); // interface
var input2 = A.Fake<ToggleUi>(); // interface
var w2 = A.Fake<MethodWeb>(); // class
var f = this.fixture;
input1.Label = f.Create<string>();
input2.Label = f.Create<string>();
A.CallTo(() => this.ui.Inputs)
.Returns(new LinkedListLot<ToggleUi>(
new[]
{
input1,
input2
}));
var a = f.Create<bool>();
A.CallTo(() => input1.GetHashCode())
.Returns(0xFF); // error
A
.CallTo(() => abPlc.Read(input1.Label))
.Returns(false); // error
A.CallTo(() => w2.RegisterDependency(null, null))
.Returns(false); // compiles fine
var w = this.web;
w.RegisterDependency(new UiReaderWriter());
w.RegisterDependency(abPlc);
this.handler.Handle(
this.ui);
A
.CallTo(() => abPlc.Read(input1.Label))
.MustHaveHappened();
A
.CallTo(() => abPlc.Read(input2.Label))
.MustHaveHappened();
}
One last comment: these interface methods are not extension methods.
Edit 1: I believe properties of interfaces worked fine.
Edit 2: actually included error and updated GetHashCode() call to actually reflect GetHashCode() sig.