.net - MoqAutoMocker and primitive constructor parameters -


i avid user of structuremap moqautomocker, sometimes, however, run "old friend" of ours. assume class "validator"

public class validator {    private string _connectionstring;    private ieventmachine _eventmachine;     public validator(string connectionstring, ieventmachine eventmachine)    {       _connectionstring = connectionstring;       _eventmachine = eventmachine;    } }  

the class above doesn't matter, in fact, raise few eyebrows, i'm making post, not think of better example off tip of nose. point contains mix of primitive datatypes ( connectionstring) , interfaces (eventmachine) - during unit testing, typically set expectations, such as:

[testmethod] public void validate_whencalled_publishesenterevent() {     // arrange     var instance = new moqautomocker<validator>();     var eventmachinemock = mock.get(automock.get<ieventmachine>());      // act     instance.validate();      // assert     eventmachinemock.verify(m => m.publish( it.isany<string>(), times.once());         } 

so, question is: above not work, because moqautomocker fails accept connectionstring argument, cannot find interface (or other primitive matter). question simply: there way tell moqautomocker value should be?

in advance, reading.

no, dont beleive there way - limitation of automocker.

we tend avoid primitive constructor params in favor of settings objects (see how handle application configuration)


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -