Exemplo n.º 1
0
        private void TestFilePartitions(string fileName, string[][] expected, Encoding encoding = null)
        {
            var streams = new Stream[expected.Length];

            for (int i = 0; i < streams.Length; i++)
            {
                streams[i] = System.IO.File.OpenRead(fileName);
            }

            var readers = TextFilePartitioner.PartitionReaders(streams, encoding);

            TestPartitionedReaders(readers, expected);
        }
Exemplo n.º 2
0
        private TextReader[] GetPartitionedReaders(string text, int partitions, Encoding encoding)
        {
            var ms     = new MemoryStream();
            var writer = new StreamWriter(ms, encoding, bufferSize: 1024, leaveOpen: true);

            writer.Write(text);
            writer.Close();

            ms.Position = 0;
            var bytes = ms.ToArray();

            var streams = new Stream[partitions];

            for (int i = 0; i < partitions; i++)
            {
                streams[i] = new MemoryStream(bytes);
            }

            return(TextFilePartitioner.PartitionReaders(streams, encoding));
        }