我正在使用Microsoft Fakes来填充几个WindowsAzure组件进行测试.按照vs 2012中的建议: Shims 编译,我更新了我的.fakes文件,只生成我实际需要的垫片:
<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/" Diagnostic="false">
<Assembly Name="Microsoft.WindowsAzure.Storage" Version="2.1.0.0"/>
<StubGeneration>
<Clear/>
</StubGeneration>
<ShimGeneration>
<Clear/>
<Add FullName="Microsoft.WindowsAzure.Storage.CloudStorageAccount"/>
<Add FullName="Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient"/>
<Add FullName="Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer"/>
<Add FullName="Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob"/>
<Add FullName="Microsoft.WindowsAzure.Storage.Queue.CloudQueueClient"/>
<Add FullName="Microsoft.WindowsAzure.Storage.Queue.CloudQueue"/>
</ShimGeneration>
</Fakes>
Run Code Online (Sandbox Code Playgroud)
但我仍然得到"一些假货无法生成......"的警告.正在生成所有指定的填充程序,并且对上述任何行进行注释会导致我的测试项目无法构建.如果我打开诊断程序,我会看到许多消息,例如:
Warning 2 Cannot generate shim for Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient+<>c__DisplayClass1: type is not supported because of internal limitations.
Run Code Online (Sandbox Code Playgroud)
一切正常,我只想抑制警告,以免混淆我们的CI服务器.是否有非诊断消息的警告编号,我可以直接在测试项目中忽略?
我试图在VS 2012终极中制作一个垫片,如MSDN网站中所述:
[TestClass]
public class TestClass1
{
[TestMethod]
public void TestCurrentYear()
{
int fixedYear = 2000;
using (ShimsContext.Create())
{
// Arrange:
// Detour DateTime.Now to return a fixed date:
System.Fakes.ShimDateTime.NowGet =
() =>
{ return new DateTime(fixedYear, 1, 1); };
// Instantiate the component under test:
var componentUnderTest = new MyComponent();
// Act:
int year = componentUnderTest.GetTheCurrentYear();
// Assert:
// This will always be true if the component is working:
Assert.AreEqual(fixedYear, year);
}
}
}
Run Code Online (Sandbox Code Playgroud)
请参阅http://msdn.microsoft.com/en-us/library/hh549176.aspx
但是当我编译我的测试项目时,我在输出中得到了一个概念:
警告:无法生成一些假货.有关完整的详细信息,请将此文件中Fakes元素的Diagnostic属性设置为"true"并重建项目.
我该如何解决此警告?