예제 #1
0
        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))));
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }