0

Is it possible to implement something like this with autofixture injection?

        // Fixture setup
        var fields = _fixture.CreateMany<CsvDbUpdateFieldModel>(1).ToList();
        _fixture.Inject(fields);

        var kvp = _fixture.CreateMany<KeyValuePair<int, IList<CsvDbUpdateFieldModel>>>(1);
        _fixture.Inject(kvp);

        var dictionary = _fixture.Create<IDictionary<int, IList<CsvDbUpdateFieldModel>>>();
        _fixture.Inject(dictionary);

        ...

What I want is to get a Dictionary with one kvp, with IList<CsvDbUpdateFieldModel> containing 1 element, which declared before. But now AutoFixture create IList<CsvDbUpdateFieldModel> with 3 randomly generated items, which probably not that I want. May be some details of AutoFixture Dictionary creation should help me..

I know how to create only one, and how to build dictionary from scratch. I ask how to force AutoFixture to use injected before kvp to automatically build dictionary, using injection mechanism

AuthorProxy
  • 7,946
  • 3
  • 27
  • 40
  • See also http://stackoverflow.com/q/37511519/126014 – Mark Seemann Oct 10 '16 at 18:36
  • See also http://stackoverflow.com/q/19286476/126014 – Mark Seemann Oct 10 '16 at 18:37
  • See also http://stackoverflow.com/q/5555054/126014 – Mark Seemann Oct 10 '16 at 18:37
  • all of this is not that I ask, @MarkSeemann is there anyway to force autofixture use before injected list of kvp to automatically create dictionary, without zipping, merging or manually constructing the dictionary? – AuthorProxy Oct 11 '16 at 08:43
  • As far as I know is `Inject` used for Mocks (AutoMoq). You should try `Freeze()` instead.You know that MarkSeemann is the author of Autofixture – Jehof Oct 11 '16 at 09:06
  • @Jehof you also can use it like in this answer http://stackoverflow.com/questions/29270580/createmany-where-only-1-element-contains-certain-value/39973891#39973891, I just trying to figure how it all works, and I think it's something dictionary specific and how autofixture create it internally, because in simple cases everythink works – AuthorProxy Oct 11 '16 at 09:21

0 Answers0