我正在为VSTO excel工作簿项目创建单元测试用例。我在thisworkbook.cs文件中有以下方法。
public void ValidateOnOpen(ICredentials credential)
{
if (credential != null)
{
WorkbookSettings.WindowsCredentials = credential;
}
else
{
this.Save();
Application.Quit();
this.Close();
}
}
当我为此方法创建单元测试用例时,代码如下所示。
[TestMethod()]
public void ValidateOnOpenTest()
{
Factory factory = null;
IServiceProvider serviceProvider = null;
ThisWorkbook target = new ThisWorkbook(factory, serviceProvider);
ICredentials credential = null;
target.ValidateOnOpen(credential);
}
请告诉我如何使用Factory和Iserviceprovider初始化以下行
ThisWorkbook target = new ThisWorkbook(factory, serviceProvider);
谢谢, 苏雷什