public void TestArchiveOldLogFiles(string logDirectory, int yearsToSimulate, int filesPerYear)
        {
            var logDir = new DirectoryInfo(logDirectory);

            if (filesPerYear < 10)
            {
                filesPerYear = 10;
            }
            else if (filesPerYear > 100)
            {
                filesPerYear = 100;
            }

            if (yearsToSimulate > 20)
            {
                yearsToSimulate = 20;
            }

            if (!logDir.Exists)
            {
                try
                {
                    logDir.Create();
                }
                catch (Exception ex)
                {
                    Assert.Fail("Unable to create missing directory " + logDir.FullName + ": " + ex.Message);
                }
            }

            // Create dummy log files for 2018, starting on March 1
            var logFilesCreated = CreateLogFiles(logDir, new DateTime(2018, 3, 1), filesPerYear);

            // If it is more than 30 days after March 1 of this year, the FileLogger will move log files into subdirectory 2018
            // To avoid duplicates (which leads to filename backups), check for and delete any files that might get moved
            // (this also avoids Console messages of the form
            //  "Backing up identically named old log file: C:\Temp\2018\FileLoggingTester_03-08-2018.txt")
            foreach (var logFile in logFilesCreated)
            {
                var candidateFileToDelete = new FileInfo(Path.Combine(logDir.FullName, "2018", logFile.Name));

                if (candidateFileToDelete.Exists)
                {
                    candidateFileToDelete.Delete();
                }
            }

            // Cache the list of old log file directories so we can examine the .zip file for each
            var logFileDirs = new List <DirectoryInfo>();

            // Create dummy log files for previous years, starting on June 1 of each year
            // In addition, delete any old .zip files
            for (var i = 1; i <= yearsToSimulate; i++)
            {
                var oldLogFileYear = 2018 - i;

                var logFileStartDate = new DateTime(oldLogFileYear, 6, 1);

                var oldLogFilesDir   = new DirectoryInfo(Path.Combine(logDir.FullName, oldLogFileYear.ToString()));
                var oldLogDirZipFile = new FileInfo(Path.Combine(logDir.FullName, oldLogFileYear + ".zip"));

                CreateLogFiles(oldLogFilesDir, logFileStartDate, filesPerYear);

                if (oldLogDirZipFile.Exists)
                {
                    oldLogDirZipFile.Delete();
                }

                logFileDirs.Add(oldLogFilesDir);

                System.Threading.Thread.Sleep(1000);
            }

            FileLogger.ChangeLogFileBaseName(Path.Combine(logDirectory, LOGFILE_BASENAME));
            FileLogger.ZipOldLogDirectories = true;

            System.Threading.Thread.Sleep(1000);

            // Instruct the logger to create .zip files for previous years
            FileLogger.ArchiveOldLogFilesNow();

            // Assure that the zip files were created and have data
            foreach (var oldLogFilesDir in logFileDirs)
            {
                var zipFileToCheck = new FileInfo(oldLogFilesDir.FullName + ".zip");

                if (!zipFileToCheck.Exists)
                {
                    Assert.Fail("Expected .zip file not found: " + zipFileToCheck.FullName);
                }

                using (var archive = ZipFile.OpenRead(zipFileToCheck.FullName))
                {
                    var fileCountInZip = archive.Entries.Count;

                    Assert.GreaterOrEqual(fileCountInZip, filesPerYear, "Zip file {0} has fewer than {1} files", zipFileToCheck.FullName, filesPerYear);

                    Console.WriteLine("{0} has {1} entries", zipFileToCheck.FullName, fileCountInZip);
                }
            }

            FileLogger.FlushPendingMessages();
        }