本文整理汇总了C#中Microsoft.VisualStudio.TestTools.UnitTesting.SequenceEqual方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.VisualStudio.TestTools.UnitTesting.SequenceEqual方法的具体用法?C# Microsoft.VisualStudio.TestTools.UnitTesting.SequenceEqual怎么用?C# Microsoft.VisualStudio.TestTools.UnitTesting.SequenceEqual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.VisualStudio.TestTools.UnitTesting
的用法示例。
在下文中一共展示了Microsoft.VisualStudio.TestTools.UnitTesting.SequenceEqual方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadAndStoreElement
public void LoadAndStoreElement()
{
Func<string[], int, string> d1 =
(a, ix) =>
{
ix %= a.Length;
var b = a[ix];
if (b.Length > 0)
{
a[ix] = b.Substring(0, b.Length - 1);
}
else
{
a[ix] = "hello world";
}
return b;
};
var ops = Sigil.Disassembler<Func<string[], int, string>>.Disassemble(d1);
Assert.IsNotNull(ops);
Assert.IsTrue(ops.CanEmit);
var e1 = ops.EmitAll();
string instrs;
var r1 = e1.CreateDelegate(out instrs);
var a1 = new[] { "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten" };
var a2 = new[] { "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten" };
for (var i = 0; i < 100; i++)
{
Assert.AreEqual(d1(a1, i), r1(a2, i));
Assert.IsTrue(a1.SequenceEqual(a2));
}
const string Pre4_6 = "ldarg.1\r\nldarg.0\r\nldlen\r\nconv.i4\r\nrem\r\nstarg.s 1\r\nldarg.0\r\nldarg.1\r\nldelem.ref\r\nstloc.0\r\nldloc.0\r\ncallvirt Int32 get_Length()\r\nldc.i4.0\r\nble.s _label40\r\nldarg.0\r\nldarg.1\r\nldloc.0\r\nldc.i4.0\r\nldloc.0\r\ncallvirt Int32 get_Length()\r\nldc.i4.1\r\nsub\r\ncallvirt System.String Substring(Int32, Int32)\r\nstelem.ref\r\nbr.s _label48\r\n\r\n_label40:\r\nldarg.0\r\nldarg.1\r\nldstr 'hello world'\r\nstelem.ref\r\n\r\n_label48:\r\nldloc.0\r\nret\r\n";
const string Post4_6 = "ldarg.2\r\nldarg.1\r\nldlen\r\nconv.i4\r\nrem\r\nstarg.s 2\r\nldarg.1\r\nldarg.2\r\nldelem.ref\r\nstloc.0\r\nldloc.0\r\ncallvirt Int32 get_Length()\r\nldc.i4.0\r\nble.s _label40\r\nldarg.1\r\nldarg.2\r\nldloc.0\r\nldc.i4.0\r\nldloc.0\r\ncallvirt Int32 get_Length()\r\nldc.i4.1\r\nsub\r\ncallvirt System.String Substring(Int32, Int32)\r\nstelem.ref\r\nbr.s _label48\r\n\r\n_label40:\r\nldarg.1\r\nldarg.2\r\nldstr 'hello world'\r\nstelem.ref\r\n\r\n_label48:\r\nldloc.0\r\nret\r\n";
var isValid = instrs == Pre4_6 || instrs == Post4_6;
Assert.IsTrue(isValid, instrs);
}
示例2: LoadLength
public void LoadLength()
{
Func<int[], int, int> d1 =
(a, ix) =>
{
ix %= a.Length;
var b = a[ix];
a[ix] = b - 1;
return b;
};
var ops = Sigil.Disassembler<Func<int[], int, int>>.Disassemble(d1);
Assert.IsNotNull(ops);
Assert.IsTrue(ops.CanEmit);
var e1 = ops.EmitAll();
string instrs;
var r1 = e1.CreateDelegate(out instrs);
var a1 = new[] { 1, 2, 3, 4, 5, 6 };
var a2 = new[] { 1, 2, 3, 4, 5, 6 };
for (var i = 0; i < 100; i++)
{
Assert.AreEqual(d1(a1, i), r1(a2, i));
Assert.IsTrue(a1.SequenceEqual(a2));
}
const string Pre4_6 = "ldarg.1\r\nldarg.0\r\nldlen\r\nconv.i4\r\nrem\r\nstarg.s 1\r\nldarg.0\r\nldarg.1\r\nldelem.i4\r\nstloc.0\r\nldarg.0\r\nldarg.1\r\nldloc.0\r\nldc.i4.1\r\nsub\r\nstelem.i4\r\nldloc.0\r\nret\r\n";
const string Post4_6 = "ldarg.2\r\nldarg.1\r\nldlen\r\nconv.i4\r\nrem\r\nstarg.s 2\r\nldarg.1\r\nldarg.2\r\nldelem.i4\r\nstloc.0\r\nldarg.1\r\nldarg.2\r\nldloc.0\r\nldc.i4.1\r\nsub\r\nstelem.i4\r\nldloc.0\r\nret\r\n";
var isValid = instrs == Pre4_6 || instrs == Post4_6;
Assert.IsTrue(isValid, instrs);
}