FactoryGirl.NET icon indicating copy to clipboard operation
FactoryGirl.NET copied to clipboard

Get Factory definitions from a namespace or an assembly

Open lgcrespo opened this issue 13 years ago • 2 comments

I know that in the real ruby version, you just call FactoryGirl define method anywhere in a file and that adds the factory and makes it ready to be used.

However, given that in .NET we need to have a class to put code inside, that technique suggests to have a static class with the factory definitions inside a constructor perhaps or have some group of classes that contain inside a group of factory definitions.

Perhaps it could be useful to have a method like FactoryGirl.AddDefinitionsFromNamespace() or FactoryGirl.AddDefinitionsFromAssembly() and a group of methods like that, and define some interface to register factories, like:

public interface IFactoryDefinition<T>{
    public Func Define();
}

or something like that. What do you think?

lgcrespo avatar Apr 02 '12 20:04 lgcrespo

Sorry just posted using my other user, this is my personal one

leoasis avatar Apr 02 '12 20:04 leoasis

In the past, I've just explicitly called some static helper methods in a test assembly startup class. I could see something like this being useful in a larger project.

JamesKovacs avatar Apr 18 '12 04:04 JamesKovacs