当前位置: 首页>>代码示例>>C#>>正文


C# Microsoft.VisualStudio.TestTools.UnitTesting.SequenceEqual方法代码示例

本文整理汇总了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);
        }
开发者ID:zhuozhuowang,项目名称:Sigil,代码行数:46,代码来源:Disassembler.cs

示例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);
        }
开发者ID:zhuozhuowang,项目名称:Sigil,代码行数:39,代码来源:Disassembler.cs


注:本文中的Microsoft.VisualStudio.TestTools.UnitTesting.SequenceEqual方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。