We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add unit tests to ensure the order in which With(), Do() and auto-properties are assigned, so we ensure to not accidentally change that behavior.
With()
Do()
The text was updated successfully, but these errors were encountered:
@zvirja I'm looking in to creating these unit tests, but I'm seeing different behavior than you specified in #1092
The order of the callback invocations is following: Constructor Do() callbacks With callbacks AutoProperties callbacks
The order of the callback invocations is following:
Constructor Do() callbacks With callbacks AutoProperties callbacks
I'm seeing the AutoProperty callbacks being called before the .With() callbacks. Can you elaborate on what the expected order is?
.With()
Here's my repro:
[Fact] public void BuilderStepsRunInCorrectOrder() { // Arrange var fixture = new Fixture(); var expectedSequence = new[] { BuildStepTest.Step.Constructor, BuildStepTest.Step.DoCallback, BuildStepTest.Step.PropertyOneWithCallback, BuildStepTest.Step.PropertyTwoAutoProperty, }; // Act var buildSetTest = fixture.Build<BuildStepTest>() .Do(o => o.InvokableMethod()) .With(o => o.PropertyOne, BuildStepTest.SpecialValue.SpecificInstance) .Create(); // Assert Assert.Equal(expectedSequence, BuildStepTest.Sequence); } class BuildStepTest { public static readonly List<Step> Sequence = new List<Step>(); public class SpecialValue { public static readonly SpecialValue SpecificInstance = new SpecialValue(); } public enum Step { Constructor, DoCallback, PropertyOneWithCallback, PropertyOneAutoProperty, PropertyTwoWithCallback, PropertyTwoAutoProperty, } public SpecialValue PropertyOne { get => null; set { if (ReferenceEquals(value, SpecialValue.SpecificInstance)) Sequence.Add(Step.PropertyOneWithCallback); else Sequence.Add(Step.PropertyOneAutoProperty); } } public SpecialValue PropertyTwo { get => null; set { if (ReferenceEquals(value, SpecialValue.SpecificInstance)) Sequence.Add(Step.PropertyTwoWithCallback); else Sequence.Add(Step.PropertyTwoAutoProperty); } } public BuildStepTest() { Sequence.Add(Step.Constructor); } public void InvokableMethod() { Sequence.Add(Step.DoCallback); } }
Sorry, something went wrong.
zvirja
No branches or pull requests
Add unit tests to ensure the order in which
With()
,Do()
and auto-properties are assigned, so we ensure to not accidentally change that behavior.The text was updated successfully, but these errors were encountered: