private static void AssertValidState <T, U, V>(INamedSelectionPageModel <T, U, V> selection) where U : IPageModel where V : INamedSelectionItemPageModel <T, U> { if (selection.SelectedItem == null) { AssertNothingSelected(selection); } else { AssertSingleSelection(selection); Assert.IsTrue(selection.SelectedItem.IsSelected); } }
private static void INamedSelectionPageModel_StandardTests <T, U, V>(INamedSelectionPageModel <T, U, V> selection) where U : IPageModel where V : INamedSelectionItemPageModel <T, U> { if (!selection.Items.Any()) { Assert.Inconclusive(); } if (selection.SelectedItem != null) { selection.SelectedItem.SetSelected(false); AssertValidState(selection); } foreach (var name in selection.Items.Select(x => x.Name)) { selection.SetValueText(name); AssertValidState(selection); Assert.IsTrue(StringComparer.Ordinal.Equals(selection.SelectedItem.Name, name)); } }
private static void AssertSingleSelection <T, U, V>(INamedSelectionPageModel <T, U, V> selection) where U : IPageModel where V : INamedSelectionItemPageModel <T, U> { Assert.IsTrue(selection.Items.SkipWhile(x => !x.IsSelected).Skip(1).All(x => !x.IsSelected)); }
private static void AssertNothingSelected <T, U, V>(INamedSelectionPageModel <T, U, V> selection) where U : IPageModel where V : INamedSelectionItemPageModel <T, U> { Assert.IsTrue(selection.Items.All(x => !x.IsSelected)); }