generated from unoplatform/template
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ItemsRepeaterExtensions fixes (#538)
- Loading branch information
Showing
4 changed files
with
56 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/Uno.Toolkit.RuntimeTests/Tests/ItemsRepeaterExtensionTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Windows.UI.Xaml; | ||
using Uno.Toolkit.RuntimeTests.Helpers; | ||
using Uno.Toolkit.UI; | ||
using Uno.UI.RuntimeTests; | ||
using ItemsRepeater = Microsoft.UI.Xaml.Controls.ItemsRepeater; | ||
using static Uno.Toolkit.RuntimeTests.Tests.ItemsRepeaterChipTests; // to borrow helper methods | ||
|
||
namespace Uno.Toolkit.RuntimeTests.Tests; | ||
|
||
[TestClass] | ||
[RunsOnUIThread] | ||
internal class ItemsRepeaterExtensionTests | ||
{ | ||
[TestMethod] | ||
[DataRow(nameof(ItemsRepeaterExtensions.SelectedItemProperty))] | ||
[DataRow(nameof(ItemsRepeaterExtensions.SelectedItemsProperty))] | ||
[DataRow(nameof(ItemsRepeaterExtensions.SelectedIndexProperty))] | ||
[DataRow(nameof(ItemsRepeaterExtensions.SelectedIndexesProperty))] | ||
public async Task When_Selection_Property_Changed(string property) | ||
{ | ||
var source = Enumerable.Range(0, 3).ToList(); | ||
var SUT = SetupItemsRepeater(source, ItemsSelectionMode.SingleOrNone); | ||
await UnitTestUIContentHelperEx.SetContentAndWait(SUT); | ||
|
||
(property switch | ||
{ | ||
nameof(ItemsRepeaterExtensions.SelectedItemProperty) => () => ItemsRepeaterExtensions.SetSelectedItem(SUT, source.ElementAt(1)), | ||
nameof(ItemsRepeaterExtensions.SelectedItemsProperty) => () => ItemsRepeaterExtensions.SetSelectedItems(SUT, new object[] { 1 }), | ||
nameof(ItemsRepeaterExtensions.SelectedIndexProperty) => () => ItemsRepeaterExtensions.SetSelectedIndex(SUT, 1), | ||
nameof(ItemsRepeaterExtensions.SelectedIndexesProperty) => () => ItemsRepeaterExtensions.SetSelectedIndexes(SUT, new int[] { 1 }), | ||
|
||
_ => default(Action) ?? throw new ArgumentOutOfRangeException(property), | ||
})(); | ||
Assert.AreEqual(true, IsChipSelectedAt(SUT, 1)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters