Building a customized instance fails on circular references
See original GitHub issue [TestFixture]
public class TestAutoFixture4
{
[Test]
[AutoMoqData]
public void CreatingAnDummyObjectShouldNotThrow(IFixture fixture)
{
fixture.Invoking(x => x.Create<DummyObject>()).ShouldNotThrow();
}
[Test]
[AutoMoqData]
public void BuildingAnDummyObjectShouldNotThrow(IFixture fixture)
{
fixture.Invoking(x => x.Build<DummyObject>().Create()).ShouldNotThrow();
}
}
public class DummyObject
{
public Guid Id { get; set; }
public DummyObject CircularRef { get; set; }
}
public class AutoMoqDataAttribute : AutoDataAttribute
{
public AutoMoqDataAttribute()
: base(new Fixture()
.Customize(
new DummyCustomization()
))
{ }
}
public class DummyCustomization : ICustomization
{
public void Customize(IFixture fixture)
{
fixture.Customize<DummyObject>(c =>
c.Without(x => x.CircularRef)
);
}
}
Just updated AutoFixture from 3.50.6 to 4.0.0.
The above code works perfectly on 3.50.6, but only the first test (using fixture.Create) passes using 4.0.0 (.NET 4.6.2, NUnit3.7.1, FluentAssertions 4.19.4).
The test using fixture.Build fails, even if the injected customization specifies not to resolve the circular reference.
Did I miss something in the changelog or is it a bug ?
Thanks in advance 😃
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Resolve build errors due to circular dependency amongst ...
The reason this fix is bad is because the next person to #include "A.h" will have to declare B before they can use...
Read more >code quality - What's wrong with circular references?
Circular object references can crash naïve recursive algorithms (such as serializers, visitors and pretty-printers) with stack overflows.
Read more >How To Find and Remove Circular References in Excel
Create a new circular reference after removing previous instances. Open a workbook with an unresolved circular reference. The error message ...
Read more >Multiple Component Instances - Circular Reference Error
I have created a Component that is basically a Gallery of Buttons - it has input Parameters of "Items" (Single column Table of...
Read more >Remove or allow a circular reference
You remove all circular references in all open workbooks, and then create a new circular reference. You close all workbooks, create a new...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If you rewrite your customization as following, all the tests will start to pass:
Therefore, yep, it should fix your issue 😉 Also this approach doesn’t look too cumbersome, so should be acceptable.
Please let me know if you have further questions on your question.
@Dev-I-Ant Awesome, thanks for the feedback! 😃