我需要在抽象類中測試CheckWarehouseAvailability
私有方法。私有方法的單元測試c#
public abstract class BaseAPI
{
private void CheckWarehouseAvailability(Order order)
{
//codes here
}
}
public class Processor : BaseAPI
{
}
這裏是我的TestMethod的
Processor pro = new Processor();
PrivateObject privBase = new PrivateObject(pro, new PrivateType(typeof(BaseAPI)));
var retVal = privBase.Invoke("CheckWarehouseAvailability(order)");
Assert.AreEqual(true, retVal);
當我運行的測試方法,我得到這個錯誤:An exception of type 'System.MissingMethodException' occured in mscorlib.dll but was not handled in user code
的參數('order')需要調用之前構造和傳遞「Invoke」的附加參數。就像它當前編寫的那樣,您試圖調用一個包含字符串「(order)」作爲其名稱一部分的方法。 – dlatikay