Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat are the principles behind AutoFixture's declarative way of setting up a fixture?
    text
    copied!<p>I have previously asked a similar <a href="https://stackoverflow.com/questions/16145284/autofixture-how-to-express-the-following-code-declaratively">question</a> on SO to which I got an answer. At the time, for the sake of expediency, I mechanically applied the answer but now I'm trying to get a handle on how the mechanism for declaratively setting up a fixture is.</p> <p>So, I am currently looking at <a href="http://blog.ploeh.dk/2009/04/23/DealingWithTypesWithoutPublicConstructors/" rel="nofollow noreferrer">Mark Seemann's Dealing With Types Without Public Constructors blog post</a> and converting it to be declarative. It is very similar to my original query but I can't get it to work. Please note that the code given is not actually production code and that this is a learning exercise. </p> <p>Now if it helps, I've got the <a href="https://github.com/DavidSSL/AutoFixtureDeclarative/tree/0.0.1" rel="nofollow noreferrer">imperative code</a> up on GitHub and the code in question is reproduced below: </p> <pre><code>[Fact] public static void CanOverrideCtorArgs() { var fixture = new Fixture(); var knownText = "This text is not anonymous"; fixture.Register&lt;int, IMyInterface&gt;( i =&gt; new FakeMyInterface( i, knownText ) ); var sut = fixture.Create&lt;MyClass&gt;(); } </code></pre> <p>This is the code similar to the one given in this <a href="http://blog.ploeh.dk/2009/04/23/DealingWithTypesWithoutPublicConstructors/" rel="nofollow noreferrer">post</a>.</p> <p>Hence, my question is what should I know/read in order to <em>convert this snippet of imperative code to be declarative</em>. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload