本文整理汇总了C#中NUnit.Framework.List.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# List.Insert方法的具体用法?C# List.Insert怎么用?C# List.Insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NUnit.Framework.List
的用法示例。
在下文中一共展示了List.Insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoubleTest
public void DoubleTest()
{
List<int> myList = new List<int>();
myList.Insert(0, 1);
myList.Insert(1, 2);
myList.Insert(2, 3);
List<int> changedList = Map.MapFunction(myList, x => x * 2);
Assert.AreEqual(2, changedList[0]);
Assert.AreEqual(4, changedList[1]);
Assert.AreEqual(6, changedList[2]);
}
示例2: OriginalListDoesntChangeTest
public void OriginalListDoesntChangeTest()
{
List<int> myList = new List<int>();
myList.Insert(0, 5);
Map.MapFunction(myList, x => x * x);
Assert.AreEqual(5, (myList[0]));
}
示例3: SquareTest
public void SquareTest()
{
List<int> myList = new List<int>();
myList.Insert(0, 5);
List<int> changedList = Map.MapFunction(myList, x => x * x);
Assert.AreEqual(25, (changedList[0]));
}
示例4: EvaluateScriptWithJqueryAsync
public static async Task<String> EvaluateScriptWithJqueryAsync(params String[] sources)
{
var list = new List<String>(sources);
list.Insert(0, Sources.Jquery);
var cfg = Configuration.Default.WithDefaultLoader(setup => setup.IsResourceLoadingEnabled = true).WithJavaScript();
var scripts = "<script>" + String.Join("</script><script>", list) + "</script>";
var html = "<!doctype html><div id=result></div>" + scripts;
var document = await BrowsingContext.New(cfg).OpenAsync(m => m.Content(html));
return document.GetElementById("result").InnerHtml;
}
示例5: ReportListGenerator
public IEnumerable<Report> ReportListGenerator()
{
int iCount = 5;
var x = new List<Report>();
while (iCount > 0)
{
x.Insert(0, new Report() { ID = iCount, Name = "Report #" + iCount });
iCount--;
}
return x.AsEnumerable();
}
示例6: UnionQueryReuse
public void UnionQueryReuse()
{
List<int> first = new List<int> { 1, 2 };
List<int> second = new List<int> { 2, 3 };
IEnumerable<int> enumerable = first.Union(second);
enumerable.AssertEqual(1, 2, 3);
first.Insert(0, 0);
second.Add(4);
enumerable.AssertEqual(0, 1, 2, 3, 4);
}
示例7: TestExecute
public void TestExecute()
{
var list = new List<int> ();
Action<int,int> exeAction = (i, v) => list.Insert (i, v);
Action<int,int> undoAction = (i, v) => list.RemoveAt (i);
var command = new Command<int,int>(0,4,exeAction, undoAction);
command.Execute ();
Assert.AreEqual (1, list.Count);
Assert.AreEqual (list[0],4);
command.Undo ();
Assert.AreEqual (0, list.Count);
}
示例8: ListCollectgionInitialization
public void ListCollectgionInitialization()
{
var people = new List<Person>
{
new Person { Name = "Matteo", Age = 12 }, //equivalent to people.Add(new Person { Name = "Matteo", Age = 12 }); add the object to the end of the list
new Person { Name = "Valerio", Age = 13 }
};
people.Insert(1, new Person { Name = "Antonio", Age = 23 });
foreach (var person in people)
{
Console.WriteLine(person.Name);
}
}
示例9: AddReplicaTest
public void AddReplicaTest()
{
Assert.IsTrue(this.repTable.Exists(), "RTable does not exist");
View v = this.configurationWrapper.GetWriteView();
int index = v.Chain.Count - 1;
string accountName = v.GetReplicaInfo(index).StorageAccountName;
List<ReplicaInfo> replicas = new List<ReplicaInfo>();
for (int i = 0; i <= index; i++)
{
replicas.Add(v.Chain[i].Item1);
}
//Just add the last replica again at the head to simulate a new replica addition
ReplicaInfo newReplica = new ReplicaInfo()
{
StorageAccountName = accountName,
};
//Add the new replica at the head
replicas.Insert(0, newReplica);
int readViewHeadIndex = 1;
this.UpdateConfiguration(replicas, readViewHeadIndex);
// validate all state
Assert.IsFalse(this.configurationWrapper.IsViewStable(), "View = {0}", this.configurationWrapper.GetWriteView().IsStable);
View readView = this.configurationWrapper.GetReadView();
View writeView = this.configurationWrapper.GetWriteView();
long viewIdAfterFirstUpdate = writeView.ViewId;
// Actually, both read and write views point to the same view
Assert.IsTrue(readView == writeView);
int headIndex = 0;
long readViewHeadViewId = readView.GetReplicaInfo(readViewHeadIndex).ViewInWhichAddedToChain;
Assert.IsTrue(writeView.GetReplicaInfo(headIndex).ViewInWhichAddedToChain == readViewHeadViewId + 1);
//Now, make the read and write views the same
this.UpdateConfiguration(replicas, 0);
// validate all state
Assert.IsTrue(this.configurationWrapper.IsViewStable());
readView = this.configurationWrapper.GetReadView();
writeView = this.configurationWrapper.GetWriteView();
Assert.IsTrue(readView == writeView);
Assert.IsTrue(readView.ViewId == viewIdAfterFirstUpdate + 1);
}
示例10: Insert
public void Insert()
{
List<string> applied = new List<string> { "foo", "bar", "baz" };
Action reset = () => Assert.Fail ("Reset should not be called");
Action<object, int, bool> insert = (o, i, create) => {
Assert.That (create, Is.True);
applied.Insert (i, (string) o);
};
Action<object, int> removeAt = (o, i) => applied.RemoveAt (i);
var items = new ObservableCollection<string> (applied);
items.CollectionChanged += (s, e) => e.Apply (insert, removeAt, reset);
items.Insert (1, "monkey");
CollectionAssert.AreEqual (items, applied);
}
示例11: TestStack
public void TestStack()
{
Stack<string> stack = new Stack<string>();
stack.Push("1");
stack.Push("2");
stack.Push("3");
stack.Push("4");
List<string> list = new List<string>();
while (stack.Count >0)
{
list.Insert(0,stack.Pop());
}
foreach (string s in list)
{
Console.WriteLine(s);
}
}
示例12: diff_charsToLinesTest
public void diff_charsToLinesTest()
{
diff_match_patchTest dmp = new diff_match_patchTest();
Assert.AreEqual(new Diff(Operation.EQUAL, "a"),
new Diff(Operation.EQUAL, "a"));
// Convert chars up to lines.
List<Diff> diffs = new List<Diff> {
new Diff(Operation.EQUAL, "\u0001\u0002\u0001"),
new Diff(Operation.INSERT, "\u0002\u0001\u0002")};
List<string> tmpVector = new List<string>();
tmpVector.Add("");
tmpVector.Add("alpha\n");
tmpVector.Add("beta\n");
dmp.diff_charsToLines(diffs, tmpVector);
CollectionAssert.AreEqual(new List<Diff> {
new Diff(Operation.EQUAL, "alpha\nbeta\nalpha\n"),
new Diff(Operation.INSERT, "beta\nalpha\nbeta\n")}, diffs);
// More than 256 to reveal any 8-bit limitations.
int n = 300;
tmpVector.Clear();
StringBuilder lineList = new StringBuilder();
StringBuilder charList = new StringBuilder();
for (int x = 1; x < n + 1; x++) {
tmpVector.Add(x + "\n");
lineList.Append(x + "\n");
charList.Append(Convert.ToChar (x));
}
Assert.AreEqual(n, tmpVector.Count);
string lines = lineList.ToString();
string chars = charList.ToString();
Assert.AreEqual(n, chars.Length);
tmpVector.Insert(0, "");
diffs = new List<Diff> {new Diff(Operation.DELETE, chars)};
dmp.diff_charsToLines(diffs, tmpVector);
CollectionAssert.AreEqual(new List<Diff>
{new Diff(Operation.DELETE, lines)}, diffs);
}
示例13: TestAddGetRemove
public void TestAddGetRemove ()
{
var foos = new List<string> (){ "1", "2", "3" };
Assert.AreEqual (3, foos.Count);
foos [2] = "MooFoey!";
Assert.IsTrue (foos.Contains ("MooFoey!"));
Assert.AreEqual ("MooFoey!", foos [2]);
foos.Add ("Hello!");
Assert.AreEqual (4, foos.Count);
foos.Remove ("Hello!");
Assert.AreEqual (3, foos.Count);
foos.Insert (1, "foomoey!");
Assert.AreEqual (4, foos.Count);
foos.InsertRange (1, new List<string>{ "1", "2", "3" });
Assert.AreEqual (7, foos.Count);
foos.Clear ();
Assert.IsEmpty (foos);
}
示例14: diff_linesToCharsTest
public void diff_linesToCharsTest()
{
var dmp = new diff_match_patchTest();
// Convert lines down to characters.
var tmpVector = new List<string>{"", "alpha\n", "beta\n"};
Object[] result = dmp.diff_linesToChars("alpha\nbeta\nalpha\n", "beta\nalpha\nbeta\n");
Assert.AreEqual("\u0001\u0002\u0001", result[0]);
Assert.AreEqual("\u0002\u0001\u0002", result[1]);
CollectionAssert.AreEqual(tmpVector, (List<string>)result[2]);
tmpVector.Clear();
tmpVector.Add("");
tmpVector.Add("alpha\r\n");
tmpVector.Add("beta\r\n");
tmpVector.Add("\r\n");
result = dmp.diff_linesToChars("", "alpha\r\nbeta\r\n\r\n\r\n");
Assert.AreEqual("", result[0]);
Assert.AreEqual("\u0001\u0002\u0003\u0003", result[1]);
CollectionAssert.AreEqual(tmpVector, (List<string>)result[2]);
tmpVector.Clear();
tmpVector.Add("");
tmpVector.Add("a");
tmpVector.Add("b");
result = dmp.diff_linesToChars("a", "b");
Assert.AreEqual("\u0001", result[0]);
Assert.AreEqual("\u0002", result[1]);
CollectionAssert.AreEqual(tmpVector, (List<string>)result[2]);
// More than 256 to reveal any 8-bit limitations.
const int n = 300;
tmpVector.Clear();
var lineList = new StringBuilder();
var charList = new StringBuilder();
for (int x = 1; x < n + 1; x++) {
tmpVector.Add(x + "\n");
lineList.Append(x + "\n");
charList.Append(Convert.ToChar(x));
}
Assert.AreEqual(n, tmpVector.Count);
string lines = lineList.ToString();
string chars = charList.ToString();
Assert.AreEqual(n, chars.Length);
tmpVector.Insert(0, "");
result = dmp.diff_linesToChars(lines, "");
Assert.AreEqual(chars, result[0]);
Assert.AreEqual("", result[1]);
CollectionAssert.AreEqual(tmpVector, (List<string>)result[2]);
}
示例15: MakeContextMenu_CheckedStates_SelCoversMultiSideBySideAnn
public void MakeContextMenu_CheckedStates_SelCoversMultiSideBySideAnn()
{
// Provide hvoTagPoss and SelectedWfics, create a markup tag and examine it.
// Setup the SelectedWfics property to include 2 words
List<int> tempList = new List<int>();
tempList.Add(m_hvoWfics[0]);
tempList.Add(m_hvoWfics[1]);
m_tagChild.SelectedWfics = tempList;
// Make a tag for 1st selection
int itestItem1 = 0; // first tag in list
m_tagChild.CallMakeTextTagAnnotation(m_possTagHvos[itestItem1]);
// Setup the SelectedWfics property to include one more word
tempList.Clear();
tempList.Add(m_hvoWfics[2]);
tempList.Add(m_hvoWfics[3]);
m_tagChild.SelectedWfics = tempList;
// Make a tag for 2nd selection
int itestItem2 = 1; // 2nd tag in list
m_tagChild.CallMakeTextTagAnnotation(m_possTagHvos[itestItem2]);
// Setup selection to cover part of first tag, and all of second
tempList.Insert(0, m_hvoWfics[1]);
m_tagChild.SelectedWfics = tempList;
// SUT; make menu while selected phrase has 2 side-by-side tags
ContextMenuStrip menu = new ContextMenuStrip();
m_tagChild.CallMakeContextMenuForTags(menu, m_textMarkupTags);
// Verification of SUT; Two should be checked and that in a submenu
ToolStripMenuItem subList = AssertHasMenuWithText(menu.Items, kFTO_RRG_Semantics, 3);
Assert.IsNotNull(subList, "No " + kFTO_RRG_Semantics + " menu!?");
ToolStripItemCollection subMenu = subList.DropDownItems;
bool[] expectedStates = new bool[subMenu.Count];
expectedStates[itestItem1] = true;
expectedStates[itestItem2] = true;
AssertMenuCheckState(expectedStates, subMenu);
}