Adding multiple MoledType attributes (for mscorlib) in AssemblyInfo.cs causes exception RRS feed

  • Question

  • I have a class that does multiple interactions with System.IO classes that I've moled. However, I can only seem to use ONE of these in my test project.

    The problem is that when I add MULTIPLE [assembly: MoledType()] attributes in either the test class or the AssemblyInfo class, I get: "ExecutionEngineException was unhandled: An unhandled exception of type 'System.ExecutionEngineException' occurred in Unknown Module."

    Here's exactly what I've been putting into the class/AssemblyInfo.cs:

    using Microsoft.Moles.Framework;
    [assembly: MoledType(typeof(System.IO.Directory))]
    [assembly: MoledType(typeof(System.IO.FileStream))]
    [assembly: MoledType(typeof(System.IO.File))]

    And my test code for usage:

    MDirectory.ExistsString = (x) => true;
    MFileStream.ConstructorStringFileModeFileAccessFileShareInt32 = (a, b, c, d, e, f) => new MFileStream();
    MFileStream.AllInstances.ReadByte = (a) => 0;
    MFile.CopyStringString = (a, b) => { };
    MFile.OpenStringFileMode = (a, b) => new MFileStream();

    So, if I ONLY add ONE assembly attribute here and comment the other moles out, that ONE works fine. It's only when I try to reference multiples that I get the exception.


    Friday, July 22, 2011 1:45 PM