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


C# TestSelector类代码示例

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


TestSelector类属于命名空间,在下文中一共展示了TestSelector类的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: Setting_SelectedIndex_Should_Set_SelectedValue

        public void Setting_SelectedIndex_Should_Set_SelectedValue()
        {
            TestSelector target = new TestSelector();

            target.SelectedIndex = 1;

            Assert.AreEqual(target.TestItems[1], target.SelectedValue);
        }
开发者ID:modulexcite,项目名称:Avalonia,代码行数:8,代码来源:SelectorTests.cs

示例4: Setting_SelectedIndex_With_Invalid_SelectedValuePath_Should_

        public void Setting_SelectedIndex_With_Invalid_SelectedValuePath_Should_()
        {
            TestSelector target = new TestSelector();

            target.SelectedValuePath = "Invalid";
            target.SelectedIndex = 1;

            Assert.IsNull(target.SelectedValue);
        }
开发者ID:modulexcite,项目名称:Avalonia,代码行数:9,代码来源:SelectorTests.cs

示例5: Setting_SelectedIndex_With_SelectedValuePath_Should_Set_SelectedValue

        public void Setting_SelectedIndex_With_SelectedValuePath_Should_Set_SelectedValue()
        {
            TestSelector target = new TestSelector();

            target.SelectedValuePath = "Caption";
            target.SelectedIndex = 1;

            Assert.AreEqual("Bar", target.SelectedValue);
        }
开发者ID:modulexcite,项目名称:Avalonia,代码行数:9,代码来源:SelectorTests.cs

示例6: SelectedIndexSetsSelectedItem

		public void SelectedIndexSetsSelectedItem ()
		{
			TestSelector s = new TestSelector ();
			object o = new object ();
			s.Items.Add (o);
			Assert.IsNull (s.SelectedItem, "1");
			s.SelectedIndex = 0;
			Assert.AreEqual (s.SelectedItem, o, "2");
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:9,代码来源:SelectorTest.cs

示例7: SelectedItemSetsSelectedIndex

		public void SelectedItemSetsSelectedIndex ()
		{
			TestSelector s = new TestSelector ();
			object o = new object ();
			s.Items.Add (o);
			Assert.AreEqual (s.SelectedIndex, -1, "1");
			s.SelectedItem = o;
			Assert.AreEqual (s.SelectedIndex, 0, "2");
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:9,代码来源:SelectorTest.cs

示例8: AddingToAVisibleWindowSetsSelection

		public void AddingToAVisibleWindowSetsSelection ()
		{
			TestSelector s = new TestSelector ();
			s.Items.Add (new object ());
			Window w = new Window ();
			w.Content = s;
			w.Show ();
			Assert.AreEqual (s.SelectedIndex, -1, "1");
			Assert.IsNull (s.SelectedItem, "2");
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:10,代码来源:SelectorTest.cs

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例15: 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


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