Browse Source

add test parameters to styled/direct binding tests for #855 and #824

pull/856/head
donandren 9 years ago
parent
commit
ce387271cc
  1. 26
      tests/Avalonia.Base.UnitTests/AvaloniaObjectTests_Binding.cs
  2. 29
      tests/Avalonia.Base.UnitTests/AvaloniaObjectTests_Direct.cs

26
tests/Avalonia.Base.UnitTests/AvaloniaObjectTests_Binding.cs

@ -385,8 +385,10 @@ namespace Avalonia.Base.UnitTests
}
}
[Fact]
public void SetValue_Should_Not_Cause_StackOverflow_And_Have_Correct_Values()
[Theory]
[InlineData(true)]
[InlineData(false)]
public void SetValue_Should_Not_Cause_StackOverflow_And_Have_Correct_Values(bool useXamlBinding)
{
var viewModel = new TestStackOverflowViewModel()
{
@ -401,12 +403,24 @@ namespace Avalonia.Base.UnitTests
// [~~Class1.DoubleValueProperty] = target[~~Class1.DoubleValueProperty]
//};
target.Bind(Class1.DoubleValueProperty, new Binding("Value") { Mode = BindingMode.TwoWay, Source = viewModel });
target.Bind(Class1.DoubleValueProperty,
new Binding("Value") { Mode = BindingMode.TwoWay, Source = viewModel });
var child = new Class1();
var child = new Class1()
if (useXamlBinding)
{
[~~Class1.DoubleValueProperty] = target[~~Class1.DoubleValueProperty]
};
child.Bind(Class1.DoubleValueProperty,
new Binding("DoubleValue")
{
Mode = BindingMode.TwoWay,
Source = target
});
}
else
{
child[!!Class1.DoubleValueProperty] = target[!!Class1.DoubleValueProperty];
}
Assert.Equal(1, viewModel.SetterInvokedCount);

29
tests/Avalonia.Base.UnitTests/AvaloniaObjectTests_Direct.cs

@ -440,8 +440,10 @@ namespace Avalonia.Base.UnitTests
Assert.Equal(BindingMode.OneWayToSource, bar.GetMetadata<Class2>().DefaultBindingMode);
}
[Fact]
public void SetValue_Should_Not_Cause_StackOverflow_And_Have_Correct_Values()
[Theory]
[InlineData(true)]
[InlineData(false)]
public void SetValue_Should_Not_Cause_StackOverflow_And_Have_Correct_Values(bool useXamlBinding)
{
var viewModel = new TestStackOverflowViewModel()
{
@ -456,12 +458,27 @@ namespace Avalonia.Base.UnitTests
// [~~Class1.DoubleValueProperty] = target[~~Class1.DoubleValueProperty]
//};
target.Bind(Class1.DoubleValueProperty, new Binding("Value") { Mode = BindingMode.TwoWay, Source = viewModel });
target.Bind(Class1.DoubleValueProperty, new Binding("Value")
{
Mode = BindingMode.TwoWay,
Source = viewModel
});
var child = new Class1();
var child = new Class1()
if (useXamlBinding)
{
[~~Class1.DoubleValueProperty] = target[~~Class1.DoubleValueProperty]
};
child.Bind(Class1.DoubleValueProperty,
new Binding("DoubleValue")
{
Mode = BindingMode.TwoWay,
Source = target
});
}
else
{
child[!!Class1.DoubleValueProperty] = target[!!Class1.DoubleValueProperty];
}
Assert.Equal(1, viewModel.SetterInvokedCount);

Loading…
Cancel
Save