public void Run()
        {
            try
            {
                if (!VerifyImportFiles())
                {
                    logger.Error("Required Files do not exist. Exiting the application.");
                    Environment.Exit(0);
                }

                IEnumerable <EverfiUser> userList = GetEverfiUsersFromCSV();

                logger.Information("Loading Template at: {0}", templateFile.FullName);
                using (EverfiExcelTemplate template = new EverfiExcelTemplate(this.templateFile, this.logger))
                {
                    logger.Information("Importing CSV File from: {0}", csvFile.FullName);
                    template.ImportDataFromList(userList.ToList());
                    DateFileTagger fileTagger      = new DateFileTagger();
                    FileInfo       saveDestination = new FileInfo(Environment.ExpandEnvironmentVariables(this.configuration.ReportSavePath));
                    saveDestination = fileTagger.Tag(saveDestination, this.timeStamp);

                    logger.Information("Saving report to: {0}", saveDestination.FullName);
                    bool saveSuccessful = template.SaveTemplateTo(saveDestination);
                    if (saveSuccessful)
                    {
                        logger.Information("Save successful | Path: {0}", saveDestination.FullName);
                        DirectoryInfo archiveDirectory = new DirectoryInfo(Environment.ExpandEnvironmentVariables(configuration.ArchiveDirectory));
                        FileInfo      archivedFile     = this.fileArchiver.Archive(csvFile, archiveDirectory);
                        if (!archivedFile.Exists)
                        {
                            logger.Warning("Could not archive the CSV File: {0}", archivedFile.FullName);
                        }
                        else
                        {
                            logger.Information("Archive successful: {0}", archivedFile.FullName);
                        }
                    }
                    else
                    {
                        logger.Error("Failed to save the exported excel sheet in the specified location: {0}", saveDestination.FullName);
                        Environment.Exit(0);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("Something unexpected happened | Reason: {0}", ex);
                Environment.Exit(0);
            }
        }
        public void EverfiExcelTemplate_SaveTemplateTo_ReturnsFalseIfFileAlreadyExist()
        {
            FileInfo existingTemplate     = new FileInfo("../../../Utilities/TestData/faketemplate.xlsx");
            FileInfo existingFilePathPath = new FileInfo("../../../Utilities/TestData/existingsaveas.xlsx");
            var      mockLogger           = new Mock <ILogger>();
            bool     didFileSave          = true;

            using (EverfiExcelTemplate excelTemplate = new EverfiExcelTemplate(existingTemplate, mockLogger.Object))
            {
                didFileSave = excelTemplate.SaveTemplateTo(existingFilePathPath);
            }

            Assert.False(didFileSave);
        }
        public void EverfiExcelTemplate_SaveTemplateTo_ReturnsTrueIfFileSaveSuccessful()
        {
            FileInfo existingTemplate    = new FileInfo("../../../Utilities/TestData/faketemplate.xlsx");
            FileInfo nonexistingFilePath = new FileInfo("../../../Utilities/TestData/nonexistingsaveas.xlsx");
            var      mockLogger          = new Mock <ILogger>();
            bool     didFileSave         = false;

            using (EverfiExcelTemplate excelTemplate = new EverfiExcelTemplate(existingTemplate, mockLogger.Object))
            {
                didFileSave = excelTemplate.SaveTemplateTo(nonexistingFilePath);
            }

            nonexistingFilePath.Delete();
            Assert.True(didFileSave);
        }
        public void EverfiExcelTemplate_SaveTemplateTo_WillLeaveCreatedFileBehind()
        {
            FileInfo existingTemplate         = new FileInfo("../../../Utilities/TestData/faketemplate.xlsx");
            FileInfo nonexistingFilePath      = new FileInfo("../../../Utilities/TestData/nonexistingsaveas.xlsx");
            var      mockLogger               = new Mock <ILogger>();
            bool     doesFileInitiallyExist   = nonexistingFilePath.Exists;
            bool     doesFileExistAfterSaveAs = false;

            using (EverfiExcelTemplate excelTemplate = new EverfiExcelTemplate(existingTemplate, mockLogger.Object))
            {
                excelTemplate.SaveTemplateTo(nonexistingFilePath);
                nonexistingFilePath.Refresh();
                doesFileExistAfterSaveAs = nonexistingFilePath.Exists;
            }

            nonexistingFilePath.Delete();
            Assert.False(doesFileInitiallyExist);
            Assert.True(doesFileExistAfterSaveAs);
        }