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


C# Labeled.ToString方法代码示例

本文整理汇总了C#中Labeled.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Labeled.ToString方法的具体用法?C# Labeled.ToString怎么用?C# Labeled.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Labeled的用法示例。


在下文中一共展示了Labeled.ToString方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetEnumerator_Unordered

        public static void GetEnumerator_Unordered(Labeled<ParallelQuery<int>> labeled, int count)
        {
            IntegerRangeSet seen = new IntegerRangeSet(0, count);
            IEnumerator<int> enumerator = labeled.Item.GetEnumerator();
            if (count == 0 && labeled.ToString().Contains("Array"))
            {
                Assert.Same(enumerator, labeled.Item.GetEnumerator());
            }
            else
            {
                Assert.NotSame(enumerator, labeled.Item.GetEnumerator());
            }
            while (enumerator.MoveNext())
            {
                int current = enumerator.Current;
                seen.Add(current);
                Assert.Equal(current, enumerator.Current);
            }
            seen.AssertComplete();

            if (labeled.ToString().StartsWith("Enumerable.Range") || labeled.ToString().StartsWith("Partitioner"))
            {
                Assert.Throws<NotSupportedException>(() => enumerator.Reset());
            }
            else
            {
                enumerator.Reset();
                seen = new IntegerRangeSet(0, count);
                while (enumerator.MoveNext())
                {
                    Assert.True(seen.Add(enumerator.Current));
                }
                seen.AssertComplete();
            }
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:35,代码来源:GetEnumeratorTests.cs

示例2: GetEnumerator

        public static void GetEnumerator(Labeled<ParallelQuery<int>> labeled, int count)
        {
            int seen = 0;
            IEnumerator<int> enumerator = labeled.Item.GetEnumerator();
            if (count == 0 && labeled.ToString().Contains("Array"))
            {
                Assert.Same(enumerator, labeled.Item.GetEnumerator());
            }
            else
            {
                Assert.NotSame(enumerator, labeled.Item.GetEnumerator());
            }
            while (enumerator.MoveNext())
            {
                int current = enumerator.Current;
                Assert.Equal(seen++, current);
                Assert.Equal(current, enumerator.Current);
            }
            Assert.Equal(count, seen);

            if (labeled.ToString().StartsWith("Enumerable.Range") || labeled.ToString().StartsWith("Partitioner"))
            {
                Assert.Throws<NotSupportedException>(() => enumerator.Reset());
            }
            else
            {
                enumerator.Reset();
                seen = 0;
                while (enumerator.MoveNext())
                {
                    Assert.Equal(seen++, enumerator.Current);
                }
                Assert.Equal(count, seen);
            }
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:35,代码来源:GetEnumeratorTests.cs

示例3: GetEnumerator

 public static void GetEnumerator(Labeled<ParallelQuery<int>> labeled, int count)
 {
     int seen = 0;
     IEnumerator<int> enumerator = labeled.Item.GetEnumerator();
     if (count == 0 && labeled.ToString().Contains("Array"))
     {
         Assert.Same(enumerator, labeled.Item.GetEnumerator());
     }
     else
     {
         Assert.NotSame(enumerator, labeled.Item.GetEnumerator());
     }
     while (enumerator.MoveNext())
     {
         Assert.Equal(seen++, enumerator.Current);
     }
     Assert.Equal(count, seen);
 }
开发者ID:jmhardison,项目名称:corefx,代码行数:18,代码来源:GetEnumeratorTests.cs

示例4: GetEnumerator_Unordered

 public static void GetEnumerator_Unordered(Labeled<ParallelQuery<int>> labeled, int count)
 {
     IntegerRangeSet seen = new IntegerRangeSet(0, count);
     IEnumerator<int> enumerator = labeled.Item.GetEnumerator();
     if (count == 0 && labeled.ToString().Contains("Array"))
     {
         Assert.Same(enumerator, labeled.Item.GetEnumerator());
     }
     else
     {
         Assert.NotSame(enumerator, labeled.Item.GetEnumerator());
     }
     while (enumerator.MoveNext())
     {
         seen.Add(enumerator.Current);
     }
     seen.AssertComplete();
 }
开发者ID:jmhardison,项目名称:corefx,代码行数:18,代码来源:GetEnumeratorTests.cs

示例5: SingleOrDefault

        public static void SingleOrDefault(Labeled<Operation> operation)
        {
            Assert.Equal(DefaultStart, operation.Item(DefaultStart, 1, DefaultSource).SingleOrDefault());
            Assert.Equal(DefaultStart + DefaultSize / 2, operation.Item(DefaultStart, DefaultSize, DefaultSource).SingleOrDefault(x => x == DefaultStart + DefaultSize / 2));

            if (!operation.ToString().StartsWith("DefaultIfEmpty"))
            {
                Assert.Equal(default(int), operation.Item(DefaultStart, 0, DefaultSource).SingleOrDefault());
                Assert.Equal(default(int), operation.Item(DefaultStart, 0, DefaultSource).SingleOrDefault(x => x == DefaultStart + DefaultSize / 2));
            }
        }
开发者ID:ESgarbi,项目名称:corefx,代码行数:11,代码来源:ParallelQueryCombinationTests.cs

示例6: GetEnumerator_CurrentBeforeMoveNext

 public static void GetEnumerator_CurrentBeforeMoveNext(Labeled<ParallelQuery<int>> labeled, int count)
 {
     IEnumerator<int> enumerator = labeled.Item.GetEnumerator();
     if (labeled.ToString().StartsWith("Partitioner")
         || labeled.ToString().StartsWith("Array"))
     {
         Assert.Throws<InvalidOperationException>(() => enumerator.Current);
     }
     else
     {
         Assert.InRange(enumerator.Current, 0, count);
     }
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:13,代码来源:GetEnumeratorTests.cs

示例7: First_AggregateException

        public static void First_AggregateException(Labeled<Operation> source, Labeled<Operation> operation)
        {
            // Concat seems able to return the first element when the left query does not fail ("first" query).
            // This test might be flaky in the case that it decides to run the right query too...
            if (operation.ToString().Contains("Concat-Left"))
            {
                Assert.InRange(operation.Item(DefaultStart, DefaultSize, source.Item).First(), DefaultStart, DefaultStart + DefaultSize);
            }
            else
            {
                AssertThrows.Wrapped<DeliberateTestException>(() => operation.Item(DefaultStart, DefaultSize, source.Item).First());
            }

            AssertThrows.Wrapped<DeliberateTestException>(() => operation.Item(DefaultStart, DefaultSize, source.Item).First(x => false));
        }
开发者ID:ESgarbi,项目名称:corefx,代码行数:15,代码来源:FailingParallelQueryCombinationTests.cs

示例8: GetEnumerator_AggregateException

        public static void GetEnumerator_AggregateException(Labeled<Operation> source, Labeled<Operation> operation)
        {
            IEnumerator<int> enumerator = operation.Item(DefaultStart, DefaultSize, source.Item).GetEnumerator();
            // Spin until concat hits
            // Union-Left needs to spin more than once rarely.
            if (operation.ToString().StartsWith("Concat") || operation.ToString().StartsWith("Union-Left"))
            {
                AssertThrows.Wrapped<DeliberateTestException>(() => { while (enumerator.MoveNext()) ; });
            }
            else
            {
                AssertThrows.Wrapped<DeliberateTestException>(() => enumerator.MoveNext());
            }

            if (operation.ToString().StartsWith("OrderBy") || operation.ToString().StartsWith("ThenBy"))
            {
                Assert.Throws<InvalidOperationException>(() => enumerator.MoveNext());
            }
            else
            {
                Assert.False(enumerator.MoveNext());
            }
        }
开发者ID:ESgarbi,项目名称:corefx,代码行数:23,代码来源:FailingParallelQueryCombinationTests.cs

示例9: Append

 public static Labeled<Operation> Append(this Labeled<Operation> item, Labeled<Operation> next)
 {
     Operation op = item.Item;
     Operation nxt = next.Item;
     return Label(item.ToString() + "|" + next.ToString(), (start, count, source) => nxt(start, count, (s, c, ignore) => op(s, c, source)));
 }
开发者ID:ChuangYang,项目名称:corefx,代码行数:6,代码来源:SourcesAndOperators.cs

示例10: BinaryOperations

        private static IEnumerable<Labeled<Operation>> BinaryOperations(Labeled<Operation> otherSource)
        {
            string label = otherSource.ToString();
            Operation other = otherSource.Item;

            yield return Label("Concat-Right:" + label, (start, count, source) => source(start, count / 2).Concat(other(start + count / 2, count / 2 + count % 2)));
            yield return Label("Concat-Left:" + label, (start, count, source) => other(start, count / 2).Concat(source(start + count / 2, count / 2 + count % 2)));

            // Comparator needs to cover _source_ size, as which of two "equal" items is returned is undefined for unordered collections.
            yield return Label("Except-Right:" + label, (start, count, source) => source(start, count + count / 2).Except(other(start + count, count), new ModularCongruenceComparer(count * 2)));
            yield return Label("Except-Left:" + label, (start, count, source) => other(start, count + count / 2).Except(source(start + count, count), new ModularCongruenceComparer(count * 2)));

            yield return Label("GroupJoin-Right:" + label, (start, count, source) => source(start, count).GroupJoin(other(start, count * CountFactor), x => x, y => y % count, (x, g) => g.Min(), new ModularCongruenceComparer(count)));
            yield return Label("GroupJoin-Left:" + label, (start, count, source) => other(start, count).GroupJoin(source(start, count * CountFactor), x => x, y => y % count, (x, g) => g.Min(), new ModularCongruenceComparer(count)));

            // Comparator needs to cover _source_ size, as which of two "equal" items is returned is undefined.
            yield return Label("Intersect-Right:" + label, (start, count, source) => source(start, count + count / 2).Intersect(other(start - count / 2, count + count / 2), new ModularCongruenceComparer(count * 2)));
            yield return Label("Intersect-Left:" + label, (start, count, source) => other(start, count + count / 2).Intersect(source(start - count / 2, count + count / 2), new ModularCongruenceComparer(count * 2)));

            yield return Label("Join-Right:" + label, (start, count, source) => source(0, count).Join(other(start, count), x => x, y => y - start, (x, y) => x + start, new ModularCongruenceComparer(count)));
            yield return Label("Join-Left:" + label, (start, count, source) => other(0, count).Join(source(start, count), x => x, y => y - start, (x, y) => x + start, new ModularCongruenceComparer(count)));

            yield return Label("Union-Right:" + label, (start, count, source) => source(start, count * 3 / 4).Union(other(start + count / 2, count / 2 + count % 2), new ModularCongruenceComparer(count)));
            yield return Label("Union-Left:" + label, (start, count, source) => other(start, count * 3 / 4).Union(source(start + count / 2, count / 2 + count % 2), new ModularCongruenceComparer(count)));

            // When both sources are unordered any element can be matched to any other, so a different check is required.
            yield return Label("Zip-Unordered-Right:" + label, (start, count, source) => source(0, count).Zip(other(start * 2, count), (x, y) => x + start));
            yield return Label("Zip-Unordered-Left:" + label, (start, count, source) => other(start * 2, count).Zip(source(0, count), (x, y) => y + start));
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:29,代码来源:SourcesAndOperators.cs


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