本文介绍了如何在Visual Studio Express中手动使用Mole?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我搜索了"Moles"和"Visual Studio Express"标签,没有发现任何问题.这可能意味着我是唯一尝试与Moles一起使用Express的人:)

在Express中,没有诸如添加痣装配"或添加mscorlib"之类的选项.

在手动添加一些通常由VS处理的引用之后,我设法获得了有关DateTime Y2Kbug的教程.因此,这意味着我可以在System或mscorlib中使用任何预模制的东西,这将很有用.

我的问题是我似乎无法在SUT中破坏自己的任何类或方法.我不相信编译器会看到任何包含要摩尔的程序集的.moles文件.

我通过尝试使用以下方法从Y2kbug教程中排除DateTime来证明(?)这一点:

<MoleGeneration>
    <Types>
        <Remove FullName="DateTime!" />
    </Types>
</MoleGeneration>

但是"bug"却像往常一样被断言:)

是否可以通过使用我在本论坛中看到的东西来生成我需要的非系统痣:stackoverflow.com/questions/6272217/microsoft-moles-dynamically-instrument

Call Microsoft.Moles.Framework.Moles.MoleRuntime.SetMole(Delegate _stub, object _receiver, MethodInfo method);

如果我使用"SetMole"方法,这是否意味着我不需要反正看不到的汇编"文件?如果是这样,可以给出一些使用"SetMole"的示例. (我不是技术人员.)

根据Mike Christian的建议,我使用了moles.exe OrigValueP.dll.这在MolesAssemblies子文件夹中创建了OrigValueP.Moles.dll.

添加OrigValueP.Moles.dll作为对测试项目的引用.

在对象浏览器中查看OrigValueP.Moles.我现在看到MOrigValue.AllInstances.因此,这是向前迈出的一大步.

但是,我没有看到与我的方法相当的Moles:

public string TestString() { return "Original value"; }

[与命令"moles.exe OrigValueP.Moles.dll"有关的行已删除,因为MC提示我正在尝试摩尔痣".

所以,我有一个问题(我将继续尝试回答这个问题):为什么没有针对TestString()的Moled方法?

解决方案

[整个答案已附加到原始问题中.对不起,一团糟.]

I searched for tags "Moles" and "Visual Studio Express", and found no questions. That probably means I'm the only person trying to use Express with Moles :)

In Express, there are no options such as "Add moles assembly", or "Add mscorlib".

I've managed to get the tutorial for the DateTime Y2Kbug working after manually adding a couple of references that would normally be handled by VS. So, that means that I can mole any of the pre-moled stuff in System or mscorlib, which will be useful.

My problem is that I cannot seem to mole any of my own classes or methods in the SUT. I don't believe that the compiler sees any of the .moles file that contains the assemblies to mole.

I proved (?) this by attempting to exclude DateTime from the Y2kbug tutorial, using:

<MoleGeneration>
    <Types>
        <Remove FullName="DateTime!" />
    </Types>
</MoleGeneration>

But the "bug" was asserted as usual :)

Is it possible to generate non-System moles as I need them by using something I saw in this forum: stackoverflow.com/questions/6272217/microsoft-moles-dynamically-instrument

Call Microsoft.Moles.Framework.Moles.MoleRuntime.SetMole(Delegate _stub, object _receiver, MethodInfo method);

If I use the "SetMole" method, does that mean that I don't need "assembly" files which are not seen anyway? If so, would it be possible to give some examples of the use of "SetMole". (I'm not a techie.)

As suggested by Mike Christian, I used moles.exe OrigValueP.dll. This created OrigValueP.Moles.dll in the MolesAssemblies subfolder.

Add OrigValueP.Moles.dll as a reference to the test project.

View OrigValueP.Moles in the Object Browser. I now see MOrigValue.AllInstances. So that's a huge step forward.

However, I don't see any Moles equivalent of my method:

public string TestString() { return "Original value"; }

[Deleted lines relating to the command, "moles.exe OrigValueP.Moles.dll", because MC suggested I'm "attempting to mole the mole assembly".]

So, I have one question (which I will continue to try to answer myself): Why was there no Moled method for TestString()?

解决方案

[This whole answer has been appended to the original question. Sorry for all the mess.]

这篇关于如何在Visual Studio Express中手动使用Mole?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 09:48