本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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");
}
示例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");
}
示例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");
}
示例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);
}
示例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());
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}