本文整理汇总了C#中Selection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Selection.Add方法的具体用法?C# Selection.Add怎么用?C# Selection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Selection
的用法示例。
在下文中一共展示了Selection.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestContains
public void TestContains()
{
Selection<object> test = new Selection<object>();
Assert.False(test.Contains("a"));
test.Add("a");
Assert.True(test.Contains("a"));
test.Add("b");
Assert.True(test.Contains("b"));
}
示例2: TestCount
public void TestCount()
{
Selection<object> test = new Selection<object>();
Assert.True(test.Count == 0);
test.Add("a");
Assert.True(test.Count == 1);
test.Add("b");
Assert.True(test.Count == 2);
}
示例3: TestIEnumerable
public void TestIEnumerable()
{
Selection<object> test = new Selection<object>();
CollectionAssert.IsEmpty(test);
test.Add("a");
Utilities.TestSequenceEqual(test, "a");
test.Add("b");
Utilities.TestSequenceEqual(test, "a", "b");
}
示例4: TestRemove
public void TestRemove()
{
Selection<object> test = new Selection<object>();
test.Add("a");
test.Add("b");
Assert.False(test.Remove("c"));
Assert.True(test.Remove("a"));
Utilities.TestSequenceEqual(test, "b");
Assert.False(test.Remove("a"));
Assert.True(test.Remove("b"));
CollectionAssert.IsEmpty(test);
}
示例5: TestAdd
public void TestAdd()
{
Selection<object> test = new Selection<object>();
test.Add("a");
Utilities.TestSequenceEqual(test, "a");
test.Add("b");
Utilities.TestSequenceEqual(test, "a", "b");
// On 1/12/2012, contractor Brandon Ehle wanted to use Selection<int>. I agreed that it would be
// useful because GridView was doing a lot of casting to 'object' and boxing ints. By changing
// Selection<T> to work with value types, I removed the requirement that 'null' not be added
// so that value types and reference types are treated equivalently, and to allow for default
// value-types to be added. For example, I think Selection<int> should be able to hold 0.
// --Ron Little
//Assert.Throws<ArgumentNullException>(delegate() { test.Add(null); });
}
示例6: GetSelectionFromComplexArray
public static ISelection GetSelectionFromComplexArray(Complex[] complexArray){
ISelection selection = new Selection();
foreach (Complex c in complexArray) {
double[] v = {c.R};
selection.Add(new Vector(v));
}
return selection;
}
示例7: GetSelectionFromRange
public ISelection GetSelectionFromRange(double min, double max, int count) {
var range = new Range(min, max);
ISelection result = new Selection();
for (double i = range.Min; i < range.Max; i += (range.Length / (double)count))
{
IVector v = new Vector(2);
v[0] = i;
v[1] = GetValueForX(i);
result.Add(v);
}
return result;
}
示例8: TestChangeEvents
public void TestChangeEvents()
{
Selection<object> test = new Selection<object>();
test.Changing += new EventHandler(test_Changing);
test.Changed += new EventHandler(test_Changed);
test.Add("a");
Assert.True(m_changedEvents == 1);
test.Add("a");
Assert.True(m_changedEvents == 1); // no change!
test.Add("b");
Assert.True(m_changedEvents == 2);
test[0] = "b";
Assert.True(m_changedEvents == 3);
}
示例9: TestAsIEnumerable
public void TestAsIEnumerable()
{
Selection<object> test = new Selection<object>();
CollectionAssert.IsEmpty(test.AsIEnumerable<object>());
test.Add("a");
test.Add(this);
Utilities.TestSequenceEqual(test.AsIEnumerable<string>(), "a");
Utilities.TestSequenceEqual(test.AsIEnumerable<object>(), "a", this);
}
示例10: TestGetSnapshotGeneric
public void TestGetSnapshotGeneric()
{
Selection<object> test = new Selection<object>();
CollectionAssert.IsEmpty(test.GetSnapshot());
test.Add("a");
test.Add(this);
Assert.AreEqual(test.GetSnapshot<object>(), new object[] { "a", this });
Assert.AreEqual(test.GetSnapshot<string>(), new string[] { "a" });
}
示例11: TestGetSnapshot
public void TestGetSnapshot()
{
Selection<object> test = new Selection<object>();
CollectionAssert.IsEmpty(test.GetSnapshot());
test.Add("a");
object[] snapshot = test.GetSnapshot();
Assert.AreEqual(snapshot, new object[] { "a" });
test.Add("b");
snapshot = test.GetSnapshot();
Assert.AreEqual(snapshot, new object[] { "a", "b" });
}
示例12: TestGetLastSelected
public void TestGetLastSelected()
{
Selection<object> test = new Selection<object>();
Assert.Null(test.GetLastSelected<string>());
test.Add("a");
Assert.AreSame(test.GetLastSelected<string>(), "a");
test.Add(this); // any non-string
Assert.AreSame(test.GetLastSelected<string>(), "a");
Assert.AreSame(test.GetLastSelected<TestSelection>(), this);
}
示例13: generateSourceSelection
private ISelection generateSourceSelection(int n, generateMethod func)
{
ISelection selection = new Selection();
for (int i = 0; i < n; i++)
{
selection.Add(func(i, n));
}
return selection;
}
示例14: TestIndexer
public void TestIndexer()
{
Selection<object> test = new Selection<object>();
Assert.Throws<ArgumentOutOfRangeException>(delegate() { object temp = test[0]; });
test.Add("a");
test.Add("b");
Assert.AreEqual(test[0], "a");
Assert.AreEqual(test[1], "b");
Assert.Throws<ArgumentOutOfRangeException>(delegate() { object temp = test[2]; });
test[0] = "c";
Assert.AreEqual(test[0], "c");
test[1] = "d";
Assert.AreEqual(test[1], "d");
}
示例15: TestRemoveAt
public void TestRemoveAt()
{
Selection<object> test = new Selection<object>();
test.Add("a");
test.Add("b");
Assert.Throws<ArgumentOutOfRangeException>(delegate() { test.RemoveAt(2); });
test.RemoveAt(1);
Utilities.TestSequenceEqual(test, "a");
Assert.Throws<ArgumentOutOfRangeException>(delegate() { test.RemoveAt(1); });
test.RemoveAt(0);
CollectionAssert.IsEmpty(test);
Assert.Throws<ArgumentOutOfRangeException>(delegate() { test.RemoveAt(0); });
}