这是我的界面
public interface IWork
{
string GetIdentifierForItem(Information information);
}
Run Code Online (Sandbox Code Playgroud)
和我的班级
public class A : IWork
{
[ImportMany]
public IEnumerable<Lazy<IWindowType, IWindowTypeInfo>> WindowTypes { get; set; }
public string GetIdentifierForItem(Information information)
{
string identifier = null;
string name = information.TargetName;
// Iterating through the Windowtypes
// searching the 'Name' and then return its ID
foreach (var windowType in WindowTypes)
{
if (name == windowType.Metadata.Name)
{
identifier = windowType.Metadata.UniqueID;
break;
}
}
return identifier;
}
}
Run Code Online (Sandbox Code Playgroud)
问题:我想对方法进行单元测试GetIdentifierForItem
以下是我试图解决的问题 -
(1)创建一个模拟Lazy并设置它需要在属性获取时返回的值
var …