private static void AssertValidState <T, U, V>(ISelectionPageModel <T, U, V> selection) where U : IPageModel where V : ISelectablePageModel <U>, ITextValuedPageModel <T> { if (selection.SelectedItem == null) { AssertNothingSelected(selection); } else { AssertSingleSelection(selection); Assert.IsTrue(selection.SelectedItem.IsSelected); } }
private static void ISelectionPageModel_StandardTests <T, U, V>(ISelectionPageModel <T, U, V> selection) where U : IPageModel where V : ISelectablePageModel <U>, ITextValuedPageModel <T> { if (!selection.Items.Any()) { Assert.Inconclusive(); } AssertValidState(selection); if (selection.SelectedItem != null) { selection.SelectedItem.SetSelected(false); AssertValidState(selection); } foreach (var selectionItem in selection.Items) { selectionItem.SetSelected(true); AssertValidState(selection); } }
private static void AssertSingleSelection <T, U, V>(ISelectionPageModel <T, U, V> selection) where U : IPageModel where V : ISelectablePageModel <U>, ITextValuedPageModel <T> { Assert.IsTrue(selection.Items.SkipWhile(x => !x.IsSelected).Skip(1).All(x => !x.IsSelected)); }
private static void AssertNothingSelected <T, U, V>(ISelectionPageModel <T, U, V> selection) where U : IPageModel where V : ISelectablePageModel <U>, ITextValuedPageModel <T> { Assert.IsTrue(selection.Items.All(x => !x.IsSelected)); }