我想測試一個存儲庫,以防止某些錯誤的網絡行爲。我使用僞造的假貨MS的類,它看起來像這樣:在填充類中調用原始方法
ShimInputRepository
.AllInstances
.UpdateEngagementStringNullableOfInt64NullableOfInt32String = (xInst, xEngId, xTrimUri, xTargetVers, xComments) =>
{
if (xEngId != initializer.SeededEngagementsWithoutEmp[3].EngagementId)
{
return xInst.UpdateEngagement(xEngId, xTrimUri, xTargetVers, xComments); //Unfortunately, calls recursively same method (not the original one)
}
else
{
throw new Exception
(
"An error occurred while executing the command definition. See the inner exception for details.",
new Exception
(
"A transport-level error has occurred when receiving results from the server. (provider: Session Provider, error: 19 - Physical connection is not usable)"
)
);
}
};
我不知道如何從withing代碼調用原來的方法(目前遞歸調用同樣的方法)。
如何調用原始方法?
更新:我真正想實現的是在對此方法的特定調用(「if()...」語句)上引發異常,否則將調用轉發給原始實例。
你想調用哪種方法? – mbdavis
我實現的唯一一個,那就是「UpdateEngagement ...」 – user3284063
你想在同一個方法中調用它嗎?這是不可能的,自己調用的代碼永遠不會被達到。或者你想知道如何在該方法之外調用它 – mbdavis