我只是在学习如何通过 MSTest 使用 Moq。在现有应用程序中,我有以下要测试的方法:
/// <summary>
/// Return the marker equipment Id value give a coater equipment Id value.
/// </summary>
/// <param name="coaterEquipmentId">The target coater</param>
/// <returns>The marker equipment Id value</returns>
internal static string GetMarkerEquipmentId(string coaterEquipmentId)
{
return CicApplication.CoaterInformationCache
.Where(row => row.CoaterEquipmentId == coaterEquipmentId)
.Select(row => row.MarkerEquipmentId)
.First();
}
CicApplication对象是具有名为CoaterInformationCache的属性的“全局”对象,该属性是 CoaterInformation 类的列表。
我假设我需要以某种方式模拟 CicApplication.CoaterInformationCache,并且我可能需要将此方法传递给包含 CoaterInformation 类列表的接口,而不是通过仅包含运行时值的全局对象访问列表?
非常感谢