Browse Source

Add more tests.

One failing.
pull/10590/head
Steven Kirk 3 years ago
parent
commit
183fed8985
  1. 27
      tests/Avalonia.Controls.UnitTests/ItemsControlTests.cs

27
tests/Avalonia.Controls.UnitTests/ItemsControlTests.cs

@ -26,9 +26,36 @@ namespace Avalonia.Controls.UnitTests
ItemsSource = new[] { "foo", "bar" },
};
Assert.NotSame(target.ItemsSource, target.Items);
Assert.Equal(target.ItemsSource, target.Items);
}
[Fact]
public void Cannot_Set_ItemsSource_With_Items_Present()
{
var target = new ItemsControl
{
Template = GetTemplate(),
ItemTemplate = new FuncDataTemplate<string>((_, __) => new Canvas()),
Items = { "foo", "bar" },
};
Assert.Throws<InvalidOperationException>(() => target.ItemsSource = new[] { "baz" });
}
[Fact]
public void Cannot_Modify_Items_When_ItemsSource_Set()
{
var target = new ItemsControl
{
Template = GetTemplate(),
ItemTemplate = new FuncDataTemplate<string>((_, __) => new Canvas()),
ItemsSource = Array.Empty<string>(),
};
Assert.Throws<InvalidOperationException>(() => target.Items.Add("foo"));
}
[Fact]
public void Should_Use_ItemTemplate_To_Create_Control()
{

Loading…
Cancel
Save