c# - AutoFixture: how to CreateAnonymous from a System.Type -


i need create object autofixture using nothing more system.type. however, there doesn't appear overload of createanonymous() takes type. expect compile time generic t. there way convert system.type t?

edit usage details:

i'm using automapper, has hook injecting components support complex mapping scenarios:

void constructservicesusing(system.func<type,object> constructor) 

as can see signature, clients can register func automapper invokes anytime needs injected service (mostly valueresolver implementations).

in production builds, method calls structuremap container retrieve component. however, when unit testing mapping code, must provide stub implementations otherwise automapper throws exception. since i'm using autofixture + moq automocking container, seems natural let af new hydrated stub, can concentrate on writing unit test code.

it's possible, intentionally hidden, since should very need this:

var specimen = new specimencontext(fixture).resolve(type); 

there tons of extensibility points in autofixture that, more not, provide better alternative weakly typed create method. trying accomplish?


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -