Exemplo n.º 1
0
    public static void AssertTestRowSort(
      string title,
      ISortStrategy<TestLine> strategy,
      int blockSize
    )
    {
      var input = GenerateTestRows(blockSize);
      var expected = input.OrderBy(x => x.String).ThenBy(x => x.Number).Select(x => _parser.Unparse(x)).ToArray();

      var watch = new Stopwatch();
      watch.Start();

      var actual = strategy.Sort(input).Select(x => _parser.Unparse(x)).ToArray();
      watch.Stop();

      Assert.Equal(expected, actual);
    }
Exemplo n.º 2
0
        private void WriteUngrouped(
            IFileWriter fileWriter,
            GroupedItem <T>[] block
            )
        {
            _Status = SortStatus.Writing;

            var unparsed = block
                           .Select(x => new GroupedItem <string> {
                Count = x.Count, Item = _lineParser.Unparse(x.Item)
            });

            foreach (var item in unparsed)
            {
                for (var i = 0; i < item.Count; i++)
                {
                    fileWriter.WriteLine(item.Item);
                }
            }
        }