2

Is it possible to either create an object by type, for example:

Type typeToCreate = typeof(TestModel);
Fixture fixture = new Fixture();
var item = fixture.Create(typeToCreate)

Or something where I can pass an already created object and it is filled, for example:

fixture.Fill(myAlreadyCreatedObject);

I could only manage to create items by generics, like fixture.Create<MyType>(). This works fine, but generics sometimes limit you if the type is determined at runtime.

Karl Cassar
  • 6,043
  • 10
  • 47
  • 84

1 Answers1

0

Yes, that's possible with AutoFixture.

You may want to look at this answer which shows an example of it.

Community
  • 1
  • 1
Nikos Baxevanis
  • 10,868
  • 2
  • 46
  • 80