public void DoAppendManyLinesThrowsTimeoutException()
        {
            LogShipperWorker worker = new LogShipperWorker();
            var tempFile = Path.Combine(Directory.GetCurrentDirectory(), String.Concat(Path.GetRandomFileName(), ".log"));
            var scriptFile = System.Configuration.ConfigurationManager.AppSettings["ScriptFile"];
            var fReturn = worker.Start(tempFile, scriptFile);
            System.Threading.Thread.Sleep(1000);
            try
            {
                using (StreamWriter streamWriter = File.AppendText(tempFile))
                {
                    streamWriter.WriteLine("{0} - This is a line of text.", -1);
                    streamWriter.Flush();
                    //streamWriter.Close();
                    if (!File.Exists(tempFile))
                    {
                        throw new FileNotFoundException(String.Format("tempFile: File not found. Create operation FAILED."), tempFile);
                    }
                }
                System.Threading.Thread.Sleep(1000);
                using (StreamWriter streamWriter = File.AppendText(tempFile))
                {

                    for (var c = 1000; c < 15000; c++)
                    {
                        streamWriter.WriteLine("{0} - This is a line of text.", c);
                        streamWriter.Flush();
                    }
                }
                System.Diagnostics.Trace.WriteLine("WriteLine completed.");
                System.Threading.Thread.Sleep(1000);
                worker.Stop();
            }
            finally
            {
                if (null != tempFile) File.Delete(tempFile);
                if (File.Exists(tempFile))
                {
                    throw new FileNotFoundException(String.Format("tempFile: File exists. Delete operation FAILED."), tempFile);
                }
            }
        }
        public void DoRenameFile()
        {
            LogShipperWorker worker = new LogShipperWorker();
            var path = Path.Combine(Directory.GetCurrentDirectory(), "some-file.log");
            var tempFile = Path.Combine(Directory.GetCurrentDirectory(), String.Concat(Path.GetRandomFileName(), ".log"));
            var newFile = Path.Combine(Directory.GetCurrentDirectory(), String.Concat(Path.GetRandomFileName(), ".log"));
            var scriptFile = System.Configuration.ConfigurationManager.AppSettings["ScriptFile"];
            var fReturn = worker.Start(tempFile, scriptFile);
            try
            {
                using (StreamWriter streamWriter = File.AppendText(tempFile))
                {
                    streamWriter.WriteLine("This is a line of text on the original file name.");
                    streamWriter.Flush();

                    if (!File.Exists(tempFile))
                    {
                        throw new FileNotFoundException(String.Format("tempFile: File not found. Create operation FAILED."), tempFile);
                    }
                }

                File.Move(tempFile, newFile);

                if (!File.Exists(newFile))
                {
                    throw new FileNotFoundException(String.Format("newFile: File not found. Rename operation FAILED."), newFile);
                }

                using (StreamWriter streamWriter = File.AppendText(newFile))
                {
                    streamWriter.WriteLine("This is a line of text on the new file name.");
                    streamWriter.Flush();
                }
            }
            finally
            {
                worker.Stop();
                if (null != tempFile) File.Delete(tempFile);
                if (File.Exists(tempFile))
                {
                    throw new FileNotFoundException(String.Format("tempFile: File exists. Delete operation FAILED."), tempFile);
                }

                if (null != newFile) File.Delete(newFile);
                if (File.Exists(newFile))
                {
                    throw new FileNotFoundException(String.Format("newFile: File exists. Delete operation FAILED."), newFile);
                }
            }
        }
 public void DoStartStopStartReturnsTrue()
 {
     LogShipperWorker worker = new LogShipperWorker();
     var logFile = Path.Combine(Directory.GetCurrentDirectory(), "some-file.log");
     var scriptFile = System.Configuration.ConfigurationManager.AppSettings["ScriptFile"];
     var fReturn = worker.Start(logFile, scriptFile);
     worker.Stop();
     fReturn = worker.Start();
     Assert.AreEqual(true, fReturn);
 }
 public void DoAppendText2()
 {
     LogShipperWorker worker = new LogShipperWorker();
     var tempFile = Path.Combine(Directory.GetCurrentDirectory(), String.Concat(Path.GetRandomFileName(), ".log"));
     var scriptFile = System.Configuration.ConfigurationManager.AppSettings["ScriptFile"];
     var fReturn = worker.Start(tempFile, scriptFile);
     try
     {
         using (StreamWriter streamWriter = File.AppendText(tempFile))
         {
             streamWriter.WriteLine("This is the first line of text.");
             streamWriter.Flush();
             if (!File.Exists(tempFile))
             {
                 throw new FileNotFoundException(String.Format("tempFile: File not found. Create operation FAILED."), tempFile);
             }
             System.Threading.Thread.Sleep(1000);
             streamWriter.WriteLine("This is the second line of text.");
             streamWriter.WriteLine("This is the third line of text.");
             streamWriter.Flush();
         }
         System.Threading.Thread.Sleep(5000);
         worker.Stop();
     }
     finally
     {
         if (null != tempFile) File.Delete(tempFile);
         if (File.Exists(tempFile))
         {
             throw new FileNotFoundException(String.Format("tempFile: File exists. Delete operation FAILED."), tempFile);
         }
     }
 }
 public void DoStopThrowsInvalidOperationException()
 {
     LogShipperWorker worker = new LogShipperWorker();
     worker.Stop();
 }