本文整理汇总了C#中Microsoft.VisualStudio.TestTools.UnitTesting.List.Swap方法的典型用法代码示例。如果您正苦于以下问题:C# List.Swap方法的具体用法?C# List.Swap怎么用?C# List.Swap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.VisualStudio.TestTools.UnitTesting.List
的用法示例。
在下文中一共展示了List.Swap方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: If_I_Try_To_Swap_Only_Two_Letters
public void If_I_Try_To_Swap_Only_Two_Letters()
{
IList<char> letters = new List<char> { 'z', 'h', };
letters.Swap<char>(0, 1);
Assert.IsTrue(letters.IndexOf('z') == 1);
Assert.IsTrue(letters.IndexOf('h') == 0);
}
示例2: SwappingTwoItems
public void SwappingTwoItems()
{
var list = new List<string>();
list.Add("Hans");
list.Add("Sepp");
list.Swap(0, 1);
Assert.AreEqual("Sepp", list[0]);
Assert.AreEqual("Hans", list[1]);
}
示例3: TestSwap
public void TestSwap()
{
var obj1 = new object();
var obj2 = new object();
var list = new List<object>
{
new object(),
new object(),
obj1,
new object(),
new object(),
new object(),
obj2,
new object()
};
list.Swap(2, 6);
Assert.AreSame(obj1, list[6]);
Assert.AreSame(obj2, list[2]);
}
示例4: If_I_Try_To_Swap_Second_Position_Less_Than_Zero
public void If_I_Try_To_Swap_Second_Position_Less_Than_Zero()
{
IList<char> letters = new List<char> { 'z', 'b' };
letters.Swap<char>(1, -3);
}
示例5: If_I_Try_To_Swap_Positions_Nonexistent
public void If_I_Try_To_Swap_Positions_Nonexistent()
{
IList<char> letters = new List<char> { 'z', };
letters.Swap<char>(0, 1);
}
示例6: If_I_Try_To_Swap_One_Element_Nonexistent
public void If_I_Try_To_Swap_One_Element_Nonexistent()
{
IList<char> letters = new List<char> { 'z', 'a', 'b', 'w', 'm', };
letters.Swap<char>('g', 'a');
}
示例7: If_I_Try_To_Swap_First_Position_Less_Than_Zero
public void If_I_Try_To_Swap_First_Position_Less_Than_Zero()
{
IList<char> letters = new List<char> { 'z', };
letters.Swap<char>(-1, 3);
}
示例8: If_I_Try_To_Swap_Two_Items_By_Position_Having_Other_Letters_In_Collection
public void If_I_Try_To_Swap_Two_Items_By_Position_Having_Other_Letters_In_Collection()
{
IList<char> letters = new List<char> { 'a', 'z', 'h', 'd', };
letters.Swap<char>(1, 3);
Assert.IsTrue(letters.IndexOf('z') == 3);
Assert.IsTrue(letters.IndexOf('d') == 1);
}
示例9: If_I_Try_To_Swap_Two_Elements_Having_Other_Letters_In_Collection
public void If_I_Try_To_Swap_Two_Elements_Having_Other_Letters_In_Collection()
{
IList<char> letters = new List<char> { 'z', 'a', 'b', 'w', 'm', };
letters.Swap<char>('a', 'm');
//
Assert.IsTrue(letters.IndexOf('a') == 4);
Assert.IsTrue(letters.IndexOf('m') == 1);
}
示例10: If_I_Try_To_Swap_The_Same_Position
public void If_I_Try_To_Swap_The_Same_Position()
{
IList<char> letters = new List<char> { 'a', 'z', 'h', 'd', };
letters.Swap<char>(1, 1);
Assert.IsTrue(letters.IndexOf('z') == 1);
Assert.IsTrue(letters.IndexOf('d') == 3);
}
示例11: SwapWithYPositionTooLow
public void SwapWithYPositionTooLow()
{
var items = new List<string> { "a", "b", "c", "d", "e" };
items.Swap(2, -4);
}
示例12: SwapWithXPositionTooHigh
public void SwapWithXPositionTooHigh()
{
var items = new List<string> { "a", "b", "c", "d", "e" };
items.Swap(15, 4);
}
示例13: SwapWithEqualPositions
public void SwapWithEqualPositions()
{
var items = new List<string> { "a", "b", "c", "d", "e" };
items.Swap(2, 2);
CollectionAssert.AreEqual(
new List<string> { "a", "b", "c", "d", "e" }, items);
}