1
鑑於這種接口:如何檢查收到的呼叫到索引與NSubstitute
public interface ITest
{
bool this[string parameter] { get; }
}
如何檢查索引接電話?
ITest test = Substitute.For<ITest>();
test.Received()["value"]; // Won't compile
鑑於這種接口:如何檢查收到的呼叫到索引與NSubstitute
public interface ITest
{
bool this[string parameter] { get; }
}
如何檢查索引接電話?
ITest test = Substitute.For<ITest>();
test.Received()["value"]; // Won't compile
編譯器錯誤是:
錯誤CS0201:只有分配,調用,遞增,遞減,在等待着,新對象表達式可以作爲一個聲明(CS0201)
要解決此問題,您可以執行虛擬分配:
ITest test = Substitute.For<ITest>();
var ignored = test.Received()["value"];