当前位置: 首页>>代码示例>>C#>>正文


C# TestSelector.ApplyTemplate方法代码示例

本文整理汇总了C#中TestSelector.ApplyTemplate方法的典型用法代码示例。如果您正苦于以下问题:C# TestSelector.ApplyTemplate方法的具体用法?C# TestSelector.ApplyTemplate怎么用?C# TestSelector.ApplyTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestSelector的用法示例。


在下文中一共展示了TestSelector.ApplyTemplate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Adding_First_SelectedItem_Should_Raise_SelectedIndex_SelectedItem_Changed

        public void Adding_First_SelectedItem_Should_Raise_SelectedIndex_SelectedItem_Changed()
        {
            var target = new TestSelector
            {
                Items = new[] { "foo", "bar" },
                Template = Template(),
            };

            bool indexRaised = false;
            bool itemRaised = false;
            target.PropertyChanged += (s, e) =>
            {
                indexRaised |= e.Property.Name == "SelectedIndex" &&
                    (int)e.OldValue == -1 &&
                    (int)e.NewValue == 1;
                itemRaised |= e.Property.Name == "SelectedItem" &&
                    (string)e.OldValue == null &&
                    (string)e.NewValue == "bar";
            };

            target.ApplyTemplate();
            target.SelectedItems.Add("bar");

            Assert.True(indexRaised);
            Assert.True(itemRaised);
        }
开发者ID:randydotnet,项目名称:Perspex,代码行数:26,代码来源:SelectingItemsControlTests_Multiple.cs

示例2: Adding_SelectedItems_Should_Set_Item_IsSelected

        public void Adding_SelectedItems_Should_Set_Item_IsSelected()
        {
            var items = new[]
            {
                new ListBoxItem(),
                new ListBoxItem(),
                new ListBoxItem(),
            };

            var target = new TestSelector
            {
                Items = items,
                Template = Template(),
            };

            target.ApplyTemplate();
            target.Presenter.ApplyTemplate();
            target.SelectedItems.Add(items[0]);
            target.SelectedItems.Add(items[1]);

            var foo = target.Presenter.Panel.Children[0];

            Assert.True(items[0].IsSelected);
            Assert.True(items[1].IsSelected);
            Assert.False(items[2].IsSelected);
        }
开发者ID:randydotnet,项目名称:Perspex,代码行数:26,代码来源:SelectingItemsControlTests_Multiple.cs

示例3: Assigning_SelectedItems_Should_Set_SelectedIndex

        public void Assigning_SelectedItems_Should_Set_SelectedIndex()
        {
            var target = new TestSelector
            {
                Items = new[] { "foo", "bar" },
                Template = Template(),
            };

            target.ApplyTemplate();
            target.SelectedItems = new[] { "bar" };

            Assert.Equal(1, target.SelectedIndex);
        }
开发者ID:furesoft,项目名称:Perspex,代码行数:13,代码来源:SelectingItemsControlTests_Multiple.cs

示例4: Setting_SelectedIndex_Should_Add_To_SelectedItems

        public void Setting_SelectedIndex_Should_Add_To_SelectedItems()
        {
            var target = new TestSelector
            {
                Items = new[] { "foo", "bar" },
                Template = Template(),
            };

            target.ApplyTemplate();
            target.SelectedIndex = 1;

            Assert.Equal(new[] { "bar" }, target.SelectedItems.Cast<object>().ToList());
        }
开发者ID:furesoft,项目名称:Perspex,代码行数:13,代码来源:SelectingItemsControlTests_Multiple.cs

示例5: First_Item_Should_Be_Selected

        public void First_Item_Should_Be_Selected()
        {
            var target = new TestSelector
            {
                Items = new[] { "foo", "bar" },
                Template = Template(),
            };

            target.ApplyTemplate();

            Assert.Equal(0, target.SelectedIndex);
            Assert.Equal("foo", target.SelectedItem);
        }
开发者ID:rdterner,项目名称:Perspex,代码行数:13,代码来源:SelectingItemsControlTests_AutoSelect.cs

示例6: First_Item_Should_Be_Selected_When_Added

        public void First_Item_Should_Be_Selected_When_Added()
        {
            var items = new PerspexList<string>();
            var target = new TestSelector
            {
                Items = items,
                Template = Template(),
            };

            target.ApplyTemplate();
            items.Add("foo");

            Assert.Equal(0, target.SelectedIndex);
            Assert.Equal("foo", target.SelectedItem);
        }
开发者ID:rdterner,项目名称:Perspex,代码行数:15,代码来源:SelectingItemsControlTests_AutoSelect.cs

示例7: Reassigning_SelectedItems_Should_Clear_Selection

        public void Reassigning_SelectedItems_Should_Clear_Selection()
        {
            var target = new TestSelector
            {
                Items = new[] { "foo", "bar" },
                Template = Template(),
            };

            target.ApplyTemplate();
            target.SelectedItems.Add("bar");
            target.SelectedItems = new PerspexList<object>();

            Assert.Equal(-1, target.SelectedIndex);
            Assert.Equal(null, target.SelectedItem);
        }
开发者ID:furesoft,项目名称:Perspex,代码行数:15,代码来源:SelectingItemsControlTests_Multiple.cs

示例8: Item_Should_Be_Selected_When_Selection_Removed

        public void Item_Should_Be_Selected_When_Selection_Removed()
        {
            var items = new PerspexList<string>(new[] { "foo", "bar", "baz", "qux" });

            var target = new TestSelector
            {
                Items = items,
                Template = Template(),
            };

            target.ApplyTemplate();
            target.SelectedIndex = 2;
            items.RemoveAt(2);

            Assert.Equal(2, target.SelectedIndex);
            Assert.Equal("qux", target.SelectedItem);
        }
开发者ID:rdterner,项目名称:Perspex,代码行数:17,代码来源:SelectingItemsControlTests_AutoSelect.cs

示例9: Selection_Should_Be_Cleared_When_No_Items_Left

        public void Selection_Should_Be_Cleared_When_No_Items_Left()
        {
            var items = new PerspexList<string>(new[] { "foo", "bar" });

            var target = new TestSelector
            {
                Items = items,
                Template = Template(),
            };

            target.ApplyTemplate();
            target.SelectedIndex = 1;
            items.RemoveAt(1);
            items.RemoveAt(0);

            Assert.Equal(-1, target.SelectedIndex);
            Assert.Null(target.SelectedItem);
        }
开发者ID:rdterner,项目名称:Perspex,代码行数:18,代码来源:SelectingItemsControlTests_AutoSelect.cs

示例10: Replacing_First_SelectedItem_Should_Update_SelectedItem_SelectedIndex

        public void Replacing_First_SelectedItem_Should_Update_SelectedItem_SelectedIndex()
        {
            var items = new[]
            {
                new ListBoxItem(),
                new ListBoxItem(),
                new ListBoxItem(),
            };

            var target = new TestSelector
            {
                Items = items,
                Template = Template(),
            };

            target.ApplyTemplate();
            target.Presenter.ApplyTemplate();
            target.SelectedIndex = 1;
            target.SelectedItems[0] = items[2];

            Assert.Equal(2, target.SelectedIndex);
            Assert.Equal(items[2], target.SelectedItem);
            Assert.False(items[0].IsSelected);
            Assert.False(items[1].IsSelected);
            Assert.True(items[2].IsSelected);
        }
开发者ID:randydotnet,项目名称:Perspex,代码行数:26,代码来源:SelectingItemsControlTests_Multiple.cs

示例11: Removing_SelectedItems_Should_Clear_Item_IsSelected

        public void Removing_SelectedItems_Should_Clear_Item_IsSelected()
        {
            var items = new[]
            {
                new ListBoxItem(),
                new ListBoxItem(),
                new ListBoxItem(),
            };

            var target = new TestSelector
            {
                Items = items,
                Template = Template(),
            };

            target.ApplyTemplate();
            target.Presenter.ApplyTemplate();
            target.SelectedItems.Add(items[0]);
            target.SelectedItems.Add(items[1]);
            target.SelectedItems.Remove(items[1]);

            Assert.True(items[0].IsSelected);
            Assert.False(items[1].IsSelected);
        }
开发者ID:randydotnet,项目名称:Perspex,代码行数:24,代码来源:SelectingItemsControlTests_Multiple.cs

示例12: Removing_Last_SelectedItem_Should_Raise_SelectedIndex_Changed

        public void Removing_Last_SelectedItem_Should_Raise_SelectedIndex_Changed()
        {
            var target = new TestSelector
            {
                Items = new[] { "foo", "bar" },
                Template = Template(),
            };

            target.ApplyTemplate();
            target.SelectedItems.Add("foo");

            bool raised = false;
            target.PropertyChanged += (s, e) =>
                raised |= e.Property.Name == "SelectedIndex" &&
                          (int)e.OldValue == 0 &&
                          (int)e.NewValue == -1;

            target.SelectedItems.RemoveAt(0);

            Assert.True(raised);
        }
开发者ID:randydotnet,项目名称:Perspex,代码行数:21,代码来源:SelectingItemsControlTests_Multiple.cs

示例13: Reassigning_SelectedItems_Should_Clear_Item_IsSelected

        public void Reassigning_SelectedItems_Should_Clear_Item_IsSelected()
        {
            var items = new[]
            {
                new ListBoxItem(),
                new ListBoxItem(),
                new ListBoxItem(),
            };

            var target = new TestSelector
            {
                Items = items,
                Template = Template(),
            };

            target.ApplyTemplate();
            target.SelectedItems.Add(items[0]);
            target.SelectedItems.Add(items[1]);

            target.SelectedItems = new PerspexList<object> { items[0], items[1] };

            Assert.False(items[0].IsSelected);
            Assert.False(items[1].IsSelected);
        }
开发者ID:randydotnet,项目名称:Perspex,代码行数:24,代码来源:SelectingItemsControlTests_Multiple.cs

示例14: Assigning_SelectedItems_Should_Raise_SelectionChanged

        public void Assigning_SelectedItems_Should_Raise_SelectionChanged()
        {
            var items = new[] { "foo", "bar", "baz" };

            var target = new TestSelector
            {
                Items = items,
                Template = Template(),
                SelectedItem = "bar",
            };

            var called = false;

            target.SelectionChanged += (s, e) =>
            {
                Assert.Equal(new[] { "foo", "baz" }, e.AddedItems.Cast<object>());
                Assert.Equal(new[] { "bar" }, e.RemovedItems.Cast<object>());
                called = true;
            };

            target.ApplyTemplate();
            target.Presenter.ApplyTemplate();
            target.SelectedItems = new[] { "foo", "baz" };

            Assert.True(called);
        }
开发者ID:randydotnet,项目名称:Perspex,代码行数:26,代码来源:SelectingItemsControlTests_Multiple.cs

示例15: Second_Range_Select_Backwards_Should_Select_From_Original_Selection

        public void Second_Range_Select_Backwards_Should_Select_From_Original_Selection()
        {
            var target = new TestSelector
            {
                Items = new[]
                {
                    "foo",
                    "bar",
                    "baz",
                    "qux",
                    "qiz",
                    "lol",
                },
                SelectionMode = SelectionMode.Multiple,
                Template = Template(),
            };

            target.ApplyTemplate();
            target.SelectedIndex = 2;
            target.SelectRange(5);
            target.SelectRange(4);

            Assert.Equal(new[] { "baz", "qux", "qiz" }, target.SelectedItems.Cast<object>().ToList());
        }
开发者ID:randydotnet,项目名称:Perspex,代码行数:24,代码来源:SelectingItemsControlTests_Multiple.cs


注:本文中的TestSelector.ApplyTemplate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。