-
Notifications
You must be signed in to change notification settings - Fork 337
New issue
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 for customization order #1093
Comments
@zvirja I'm looking in to creating these unit tests, but I'm seeing different behavior than you specified in #1092
I'm seeing the AutoProperty callbacks being called before the 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);
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: