• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# TestSelector类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



TestSelector类属于命名空间,在下文中一共展示了TestSelector类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: Create

        public static Runner Create()
        {
            var exceptionFilter = new NUnitExceptionFilter(printStacktrace: false);
             var viewTestFixture = new ViewTestFixture(exceptionFilter);
             var inicjalizerView = new InicjalizerView(exceptionFilter);
             var nUnitAssertionAction = new NUnitAssertionAction();
             var runInExclusiveGroupAttributeFilter = new RunInExclusiveGroupAttributeFilter();
             var traditionalTestAttributeFilter = new TraditionalTestAttributeFilter();
             var testMethodSelector = new TestSelector(
            new NUnitTestMethodSelectorFromTestFixture(),
            new ITestMethodFilter[] { runInExclusiveGroupAttributeFilter, traditionalTestAttributeFilter },
            nUnitAssertionAction);
             var nUnitTestMethodSelectorFromCallStack = new NUnitTestMethodSelectorFromCallStack();

             return new Runner(
            exceptionFilter, viewTestFixture, inicjalizerView,
            testMethodSelector, nUnitAssertionAction, nUnitTestMethodSelectorFromCallStack);
        }
开发者ID:quang319,项目名称:Penn-State-Fall,代码行数:18,代码来源:RunnerHelper.cs


示例17: Unbound_SelectedItems_Should_Be_Cleared_When_DataContext_Cleared

        public void Unbound_SelectedItems_Should_Be_Cleared_When_DataContext_Cleared()
        {
            var data = new
            {
                Items = new[] { "foo", "bar", "baz" },
            };

            var target = new TestSelector
            {
                DataContext = data,
                Template = Template(),
            };

            var itemsBinding = new Binding { Path = "Items" };
            itemsBinding.Bind(target, TestSelector.ItemsProperty);

            Assert.Same(data.Items, target.Items);

            target.SelectedItems.Add("bar");
            target.DataContext = null;

            Assert.Empty(target.SelectedItems);
        }
开发者ID:randydotnet,项目名称:Perspex,代码行数:23,代码来源:SelectingItemsControlTests_Multiple.cs


示例18: Should_Not_Write_To_Old_DataContext

        public void Should_Not_Write_To_Old_DataContext()
        {
            var vm = new OldDataContextViewModel();
            var target = new TestSelector();

            var itemsBinding = new Binding
            {
                Path = "Items",
                Mode = BindingMode.OneWay,
            };

            var selectedItemsBinding = new Binding
            {
                Path = "SelectedItems",
                Mode = BindingMode.OneWay,
            };

            // Bind Items and SelectedItems to the VM.
            itemsBinding.Bind(target, TestSelector.ItemsProperty);
            selectedItemsBinding.Bind(target, TestSelector.SelectedItemsProperty);

            // Set DataContext and SelectedIndex
            target.DataContext = vm;
            target.SelectedIndex = 1;

            // Make sure SelectedItems are written back to VM.
            Assert.Equal(new[] { "bar" }, vm.SelectedItems);

            // Clear DataContext and ensure that SelectedItems is still set in the VM.
            target.DataContext = null;
            Assert.Equal(new[] { "bar" }, vm.SelectedItems);

            // Ensure target's SelectedItems is now clear.
            Assert.Empty(target.SelectedItems);
        }
开发者ID:randydotnet,项目名称:Perspex,代码行数:35,代码来源:SelectingItemsControlTests_Multiple.cs


示例19: Suprious_SelectedIndex_Changes_Should_Not_Be_Triggered

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

            target.ApplyTemplate();

            var selectedIndexes = new List<int>();
            target.GetObservable(TestSelector.SelectedIndexProperty).Subscribe(x => selectedIndexes.Add(x));

            target.SelectedItems = new PerspexList<object> { "bar", "baz" };
            target.SelectedItem = "foo";

            Assert.Equal(0, target.SelectedIndex);
            Assert.Equal(new[] { -1, 1, 0 }, selectedIndexes);
        }
开发者ID:randydotnet,项目名称:Perspex,代码行数:19,代码来源:SelectingItemsControlTests_Multiple.cs


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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# TestServer类代码示例发布时间:2022-05-24
下一篇:
C# TestScheduler类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap