private static void Run()

in TestDataCreator/DataCreator.cs [44:120]


        private static void Run(object state)
        {
            var st = state as State;
            if (st.IsLocal)
            {
                using (var ostream = new StreamWriter(new FileStream(st.Path, FileMode.Create, FileAccess.Write), Encoding.UTF8))
                {
                    if (st.FileLength > 0)
                    {
                        long lengthToRead = st.FileLength;
                        using (Stream rndStream = new RandomDataStream(st.FileLength))
                        {
                            byte[] readBytes = new byte[BuffSize];
                            while (lengthToRead > 0)
                            {
                                int bytesRead = rndStream.Read(readBytes, 0, (int)Math.Min(BuffSize, lengthToRead));

                                // Break when the end of the file is reached.
                                if (bytesRead > 0)
                                {
                                    if (st.WriteInNewLines)
                                    {
                                        ostream.WriteLine(Encoding.UTF8.GetString(readBytes, 0, bytesRead));
                                    }
                                    else
                                    {
                                        ostream.Write(Encoding.UTF8.GetString(readBytes, 0, bytesRead));
                                    }
                                }
                                else
                                {
                                    break;
                                }
                                lengthToRead -= bytesRead;
                            }
                        }

                    }
                }
            }
            else
            {
                using (var ostream = st.Client.CreateFile(st.Path, IfExists.Overwrite))
                {
                    if (st.FileLength> 0)
                    {
                        long lengthToRead = st.FileLength;
                        using (Stream rndStream = new RandomDataStream(st.FileLength))
                        {
                            byte[] readBytes = new byte[BuffSize];
                            while (lengthToRead > 0)
                            {
                                int bytesRead = rndStream.Read(readBytes, 0, (int)Math.Min(BuffSize, lengthToRead));

                                // Break when the end of the file is reached.
                                if (bytesRead > 0)
                                {
                                    ostream.Write(readBytes, 0, bytesRead);
                                }
                                else
                                {
                                    break;
                                }

                                lengthToRead -= bytesRead;
                            }
                        }

                    }
                    else if (!string.IsNullOrEmpty(st.NonRandomText))
                    {
                        var readBytes = Encoding.UTF8.GetBytes(st.NonRandomText);
                        ostream.Write(readBytes,0,readBytes.Length);
                    }
                }
            }
        }