鼠创建不会创建所有对象 [英] Moles creation does not create all objects

查看:90
本文介绍了鼠创建不会创建所有对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在尝试为某些单元测试创​​建模型时,我注意到某些功能并未被模型化".某些功能出现在xxx.moles.xml文件中,而其他功能则没有.

While trying to create a mole for some unit tests I noticed that some functions were not being 'moled'. Some functions were appearing in the xxx.moles.xml file while others were not.

为解决此问题,我尝试重新安装"Pex and Moles",删除MolesAssembly文件夹中的文件,重新启动计算机等.

To resolve this issue, I've tried reinstalling 'Pex and Moles', deleted files in the MolesAssembly folder, restarted the computer, etc.

最后,我只是打开了一个控制台窗口,并从命令提示符处运行了moles.exe命令.

Finally, I simply opened a console window and ran the moles.exe command from the command prompt.

"c:\program files\microsoft moles\bin\moles.exe" assembly.dll /op:"MolesAssemblies" /msbuild:"c:\windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe"

我第一次运行此消息,我收到一条消息:

The first time I ran this, I received a message:

摩尔:信息:编译:程序集元数据哈希保持不变, 跳过代码生成.

Moles : info : compilation : assembly metadata hash unchanged, skipping code generation.

在删除MolesAssemblies文件夹中的痣之后,我再次运行moles.exe命令,并且我的所有功能现在都出现在xxx.moles.dll和xxx.moles.xml文件中.

After deleting the moles in the MolesAssemblies folder, I ran the moles.exe command again and all my functions are now appearing in the xxx.moles.dll and xxx.moles.xml files.

有人知道为什么在Visual Studio 2010中构建时无法生成痣,但在命令提示符下却能正常工作吗?

Does anyone know why the mole generation does not work when building inside Visual Studio 2010, but it works perfectly from the command prompt?

推荐答案

我发现了问题...我之前修改了.moles文件,仅添加了某些类.我只需要添加更多的"TypeName",就包括了类/函数.

I found the issue...I modified the .moles file before and only certain classes were added. I simply had to add more 'TypeName' and the classes/functions were included.

使用moles.exe命令起作用"的原因是因为我没有使用.moles文件(我只是引用了程序集).我更改了moles.exe的参数,使其包含.moles文件和程序集,结果与Visual Studio生成的输出相同.一旦我发现代码的其他部分坏了,我就意识到.moles文件是不正确的.

The reason that it 'worked' by using the moles.exe command was because I did not use the .moles file (I simply referenced the assembly). I changed the parameters for moles.exe to include the .moles file and the assembly and the results were identical to the output generated by Visual Studio. Once I notice that other parts of the code was breaking, I realized that the .moles file was incorrect.

我有这样的东西...

I had something like this...

<Moles xmlns="http://schemas.microsoft.com/moles/2010/" >
  <Assembly Name="Assembly.name" />
    <StubGeneration>
        <Types>
            <Clear />
            <Add FullName="Fullname_1_0" />
        </Types>
    </StubGeneration>
    <MoleGeneration>
        <Types>
            <Clear />
            <Add FullName ="Fullname_1_0" />
        </Types>
    </MoleGeneration> 
</Moles>

我需要第二个添加"

<Moles xmlns="http://schemas.microsoft.com/moles/2010/" >
  <Assembly Name="Assembly.name" />
    <StubGeneration>
        <Types>
            <Clear />
            <Add FullName="Fullname_1_0" />
        </Types>
    </StubGeneration>
    <MoleGeneration>
        <Types>
            <Clear />
            <Add FullName ="Fullname_1_0" />
            <Add TypeName="AdditionalClass"/>
        </Types>
    </MoleGeneration> 
</Moles>

这篇关于鼠创建不会创建所有对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆