Created
March 27, 2015 07:50
-
-
Save phillip-haydon/7dfa736ba70bfb34297e to your computer and use it in GitHub Desktop.
Autofixture Base Types and Recursion.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestFixture] | |
public class TestStuffs | |
{ | |
[Test, Category(TestCategories.Unit)] | |
public void Fail() | |
{ | |
var fixture = new Fixture().Customize(new TestCustomization()); | |
var result = fixture.Create<TestClass>(); | |
} | |
public abstract class TestClassBase | |
{ | |
public IList<Node> Nodes { get; set; } | |
} | |
public class TestClass : TestClassBase | |
{ | |
} | |
public class Node | |
{ | |
public TestClassBase Parent { get; set; } | |
} | |
public class TestCustomization : ICustomization | |
{ | |
public void Customize(IFixture fixture) | |
{ | |
fixture.Customizations.Add(new TypeRelay(typeof(TestClassBase), typeof(TestClass))); | |
//How to prevent recursion??? | |
//fixture.Customize<TestClass>(x => x.With(f => f.Nodes, fixture.Build<Node>(n => n.Without(u => u.Parent)))); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment