Browse Source

#1798 Test for binding checkbox with three state.

pull/1799/head
MonkAlex 8 years ago
parent
commit
e69f3c7f85
  1. 26
      tests/Avalonia.Controls.UnitTests/Primitives/ToggleButtonTests.cs

26
tests/Avalonia.Controls.UnitTests/Primitives/ToggleButtonTests.cs

@ -44,15 +44,41 @@ namespace Avalonia.Controls.Primitives.UnitTests
Assert.False(toggleButton.IsChecked);
}
[Fact]
public void ToggleButton_ThreeState_Checked_Binds_To_Nullable_Bool()
{
var threeStateButton = new ToggleButton();
var source = new Class1();
threeStateButton.DataContext = source;
threeStateButton.Bind(ToggleButton.IsCheckedProperty, new Binding(nameof(Class1.NullableFoo)));
source.NullableFoo = true;
Assert.True(threeStateButton.IsChecked);
source.NullableFoo = false;
Assert.False(threeStateButton.IsChecked);
source.NullableFoo = null;
Assert.Null(threeStateButton.IsChecked);
}
private class Class1 : NotifyingBase
{
private bool _foo;
private bool? nullableFoo;
public bool Foo
{
get { return _foo; }
set { _foo = value; RaisePropertyChanged(); }
}
public bool? NullableFoo
{
get { return nullableFoo; }
set { nullableFoo = value; RaisePropertyChanged(); }
}
}
}
}

Loading…
Cancel
Save