private char[] GetNextLine(Common.Random random, long capacity, ref List <char[]> duplicates)
        {
            char[] chars = null;
            if (duplicates.Count > 0 && random.Next(100) < duplicatesProbabilityPercents)
            {
                //get duplicate line
                chars = duplicates[random.Next(duplicates.Count)];

                var remainingBytes = capacity - chars.Length;
                if (remainingBytes <= MinLineLength)
                {
                    chars = null;
                }
            }

            // need to generate new line
            if (null == chars)
            {
                // generate new line
                var rnd    = random.Next(MinLineLength, maxLineLength);
                var length = Math.Min(rnd, capacity);

                var remainingBytes = capacity - length;
                if (remainingBytes <= MinLineLength)
                {
                    length += remainingBytes;
                }

                chars = GenerateLine(random, (int)length);

                // store duplicates to future use
                if (duplicatePatternsCount > 0)
                {
                    lock (duplicates)
                    {
                        --duplicatePatternsCount;
                        duplicates.Add(chars);
                    }
                }
            }

            return(chars);
        }
        private static char[] GenerateLine(Common.Random random, int length)
        {
            var buffer = new char[length];

            var dotIndex = random.Next(1, Math.Min(length - MinLineLength + 1, MaxDigitsConunt));

            for (var i = 0; i < buffer.Length - 2; i++)
            {
                if (i == dotIndex || i == dotIndex + 1)
                {
                    continue;
                }
                buffer[i] = chars[
                    i < dotIndex
                                        ? random.Next(i == 0 ? 1 : 0, 10)
                                        : random.Next(chars.Length)];
            }

            buffer[dotIndex]          = '.';
            buffer[dotIndex + 1]      = ' ';
            buffer[buffer.Length - 2] = '\r';
            buffer[buffer.Length - 1] = '\n';
            return(buffer);
        }