I have done something like the following
public class Foo
{
public Bar { get; set; }
}
public class Bar
{
internal Bar(string id)
{}
}
public static class Bars
{
public static class TypeOne
{
public static readonly SimpleBar = new Bar("id-for-type1-simple-bar");
}
}
now, I added an InternalsVisibleTo to my in my unit-test-assembly to be able to access the internal Bar ctor and then I did:
var fixture = new Fixture();
fixture.Register(() => new Bar(fixture.CreateAnonymous<string>()));
var foo = fixture.CreateAnonymous<Foo>();
Question:
Was that the "right" way to utilize AutoFixture or is there a better one?
Couldn't you just do something like this instead?
fixture.Inject(Bars.TypeOne.SimpleBar);
This is all public. No need for InternalsVisibleTo, I think...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With