public void Test_FilterItems_Sets_FilteredItems_To_Items_Matching_SearchText() { var dummies = GetDummies(); var searchVM = new SearchBoxVM <Dummy>(dummies, converter); searchVM.SearchText = "key"; searchVM.FilterItems(); var result = searchVM.Filtered; Assert.Equal(3, result.Count); Assert.True(GetDummiesWithKey().TrueForAll(dummy => result.Contains(converter(dummy)))); }
public void Test_FilterItems_Sets_AutoCompleteItem_To_Default_When_Not_Only_Result() { var dummies = GetDummiesWithoutKey(); var dummyWithKey = new Dummy { stringItem = "with key", otherValue = 0 }; dummies.Add(dummyWithKey); var searchVM = new SearchBoxVM <Dummy>(dummies, converter); searchVM.SearchText = "key"; searchVM.FilterItems(); Assert.NotNull(searchVM.AutoCompleteItem); dummies.AddRange(GetDummiesWithKey()); searchVM.FilterItems(); var result = searchVM.Filtered; Assert.Equal(4, result.Count); Assert.Null(searchVM.AutoCompleteItem); }
public void Test_FilterItems_Sets_AutoCompleteItem_To_Entry_When_Only_Result() { var dummies = GetDummiesWithoutKey(); var dummyWithKey = new Dummy { stringItem = "with key", otherValue = 0 }; dummies.Add(dummyWithKey); var searchVM = new SearchBoxVM <Dummy>(dummies, converter); searchVM.SearchText = "key"; searchVM.FilterItems(); var result = searchVM.Filtered; Assert.Single(result); Assert.Equal(dummyWithKey, searchVM.AutoCompleteItem); }