c# - Moq Concrete Class with Internal Constructor -


i'm attempting moq concrete class has internal constructor, i.e., in myassembly have

public class myclass {      internal myclass(){}      // other methods including factory instance method } 

then in test in `testassembly' have

var mock = new mock<myclass>(); 

in myassembly have added following assemblyinfo.cs

[assembly: internalsvisibleto("testassembly")] 

but setting testassembly friend of myassembly, moq still throws error

castle.dynamicproxy.invalidproxyconstructorargumentsexception can not instantiate proxy of class: civica.metadata.models.entities.stage. not find parameterless constructor. 

should moq able create mocks using internal constructors in manner?

see advanced features section of moq quickstart.

mocking internal types of project: add following assembly attribute (typically assemblyinfo.cs) project containing internal types:

// assembly default dynamic assembly generated castle dynamicproxy,  // used moq. paste in single line.  [assembly:internalsvisibleto("dynamicproxygenassembly2,publickey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -