Esempio n. 1
0
        public void AutoCompleteBox_TextChanged_ShouldFilterDropDown()
        {
            IList <string> items = new List <string>
            {
                "AnItem",
                "OtherItem"
            };

            AutoCompleteBox autoCompleteBox = new AutoCompleteBox();

            autoCompleteBox.ItemsSource = items;

            TestSetup.AttachVisualChild(autoCompleteBox);
            (autoCompleteBox.GetTemplateChild("Text") as TextBox).Text = "an";

            TestSetup.SleepWhile(() => !autoCompleteBox.IsDropDownOpen,
                                 "DropDown is not open after text change");
            autoCompleteBox.ItemContainerGenerator.ContainerFromItem("AnItem")
            .As <SelectorItem>()
            .Visibility
            .Should()
            .Be(Visibility.Visible);
            autoCompleteBox.ItemContainerGenerator.ContainerFromItem("OtherItem")
            .As <SelectorItem>()
            .Visibility
            .Should()
            .Be(Visibility.Collapsed);
        }