A small point ... In materials like:
var ciudades_fixture = fixture.Build<Ciudad>().CreateMany<Ciudad>();
The second type arg is not needed and should be:
var ciudades_fixture = fixture.Build<Ciudad>().CreateMany();
I really understand why you need FakeDbSet , and the article is a bit TL, DR ... In general, I try to avoid falsification and dropping of ORM bits and instead refers to interfaces that return POCOs to the maximum extent.
Aside ... The reason that the usual syntax for initializing a list works is because DBFixture has Add (and IEnumerable ). AutoFixture does not have a history for this template directly (after all, it is the syntax of the compiler and is not particularly reflective or conforms to any other conventions), but you can use AddManyTo as long as there is ICollection to play. Fortunately, in the FakeDbSet test, as in the article, the following gives us: -
public ObservableCollection<T> Local { get { return _data; } }
Since ObservableCollection<T> comes from ICollection<T> , you should be able to:
var ciudades = new FakeDbSet<Cuidad>(); fixture.AddManyTo(ciudades.Local); var mockData = new Mock<IContext>(); mockData.Setup(m => m.Ciudades).Returns(ciudades);
You can connect the setting to make it more beautiful, but at least you have a way to control it. Another option is to implement ICollection something (or add support from a setter that accepts IEnumerable<T> , and create an AF parent object, causing this collection to fill up.
Long side note: in your original question, you actually have:
fixture.Build<FakeDbSet<Ciudad>>().CreateMany()
Now the problem is getting clearer: you're asking for autofocus to generate a lot of FakeDbSet<Ciudad> s, which you don't want.