public void Archive_Does_Nothing_When_Required_Directories_Do_Not_Exist() { ResultArchiver resultArchiver = new ResultArchiver(PROGRAM, VERSION, RUNTYPE_SINGLE, null, new List <string>(ResultArchiver.PsbTestDescriptions)); RunPath = resultArchiver.PathRoot; string pathSource = Path.Combine(resultArchiver.PathRoot, ResultArchiver.DIR_TESTING); deleteDirectory(pathSource); Assert.DoesNotThrow(() => resultArchiver.Archive()); string pathResults = Path.Combine(resultArchiver.PathRoot, ResultArchiver.DIR_RESULTS); deleteDirectory(pathResults); Assert.DoesNotThrow(() => resultArchiver.Archive()); string pathArchive = Path.Combine(resultArchiver.PathRoot, ResultArchiver.DIR_ARCHIVE); deleteDirectory(pathArchive); Assert.DoesNotThrow(() => resultArchiver.Archive()); Assert.IsFalse(Directory.Exists(pathArchive)); }
public void Archive_Does_Nothing_When_Required_Properties_Are_NullOrEmpty(string application, string version, string runType) { // Set up object ResultArchiver resultArchiver = new ResultArchiver(application, version, runType); RunPath = resultArchiver.PathRoot; // Set up directories string sourceBasePath = Directory.GetParent(Directory.GetParent(NCrunchEnvironment.GetOriginalSolutionPath()).FullName).FullName; sourceBasePath = Path.Combine(sourceBasePath, "resources", "_Tests"); copyDirectory(sourceBasePath, RunPath); string pathSource = Path.Combine(RunPath, ResultArchiver.DIR_TESTING); Assert.That(Directory.Exists(pathSource)); string pathResults = Path.Combine(RunPath, ResultArchiver.DIR_RESULTS); Assert.That(Directory.Exists(pathResults)); string pathArchive = Path.Combine(RunPath, ResultArchiver.DIR_ARCHIVE); Assert.That(Directory.Exists(pathArchive)); // Method under test Assert.DoesNotThrow(() => resultArchiver.Archive()); // Check results string[] directoriesProgramVersion = Directory.GetDirectories(pathArchive); Assert.That(directoriesProgramVersion.Length, Is.EqualTo(0)); }
public void ResultArchiver_Initialization_From_Config_File_Empty_Properties() { // Set up custom config file string configFile = "ResultsArchiver_EmptyProperties.Config.xml"; ResultArchiver resultArchiverPath = new ResultArchiver(); string sourceBasePath = Directory.GetParent(Directory.GetParent(NCrunchEnvironment.GetOriginalSolutionPath()).FullName).FullName; string fileDestination = Path.Combine(resultArchiverPath.PathRoot, configFile); if (!File.Exists(fileDestination)) { File.Copy(Path.Combine(sourceBasePath, "ResultsArchiver", "resources-testing", configFile), fileDestination); } // Test ResultArchiver resultArchiver = new ResultArchiver(configFile); // Check results Assert.That(resultArchiver.Application, Is.EqualTo(string.Empty)); Assert.That(resultArchiver.Version, Is.EqualTo(string.Empty)); Assert.That(resultArchiver.RunType, Is.EqualTo(string.Empty)); Assert.IsFalse(resultArchiver.OverWriteExisting); Assert.That(resultArchiver.SuiteNames[0], Is.EqualTo(string.Empty)); Assert.That(resultArchiver.TestDescriptions[0], Is.EqualTo(string.Empty)); // Archive should do nothing with a malformed object Assert.DoesNotThrow(() => resultArchiver.Archive()); }
public void ResultArchiver_Initialization_From_Config_File_By_Full_File_Path() { // Set up custom config file string configFile = "ResultsArchiver_CustomName.Config.xml"; ResultArchiver resultArchiverPath = new ResultArchiver(); string sourceBasePath = Directory.GetParent(Directory.GetParent(NCrunchEnvironment.GetOriginalSolutionPath()).FullName).FullName; sourceBasePath = Path.Combine(sourceBasePath, "ResultsArchiver", "resources-testing"); string otherLocationPath = Path.Combine(resultArchiverPath.PathRoot, "otherLocation"); if (!Directory.Exists(otherLocationPath)) { Directory.CreateDirectory(otherLocationPath); } string fileDestination = Path.Combine(otherLocationPath, configFile); if (!File.Exists(fileDestination)) { File.Copy(Path.Combine(sourceBasePath, configFile), fileDestination); } // Test ResultArchiver resultArchiver = new ResultArchiver(fileDestination); // Check results Assert.That(resultArchiver.Application, Is.EqualTo(PROGRAM)); Assert.That(resultArchiver.Version, Is.EqualTo(VERSION)); Assert.That(resultArchiver.RunType, Is.EqualTo(RUNTYPE_SINGLE)); Assert.IsTrue(resultArchiver.OverWriteExisting); Assert.That(resultArchiver.SuiteNames[0], Is.EqualTo(SUITE_NAME_FILE)); Assert.That(resultArchiver.TestDescriptions[0], Is.EqualTo(DESCRIPTION_FILE)); }
public void Archive_Single_Filtered_By_Suite() { // Set up object ResultArchiver resultArchiver = new ResultArchiver("SAP2000", "19.2.0.1350", RUNTYPE_SINGLE, suiteNames: new List <string> { "Design" }, testDescriptions: new List <string> { "Run as is" }); RunPath = resultArchiver.PathRoot; // Set up directories string sourceBasePath = Directory.GetParent(Directory.GetParent(NCrunchEnvironment.GetOriginalSolutionPath()).FullName).FullName; sourceBasePath = Path.Combine(sourceBasePath, "resources", "_Tests"); copyDirectory(sourceBasePath, RunPath); string pathSource = Path.Combine(RunPath, ResultArchiver.DIR_TESTING); Assert.That(Directory.Exists(pathSource)); string pathResults = Path.Combine(RunPath, ResultArchiver.DIR_RESULTS); Assert.That(Directory.Exists(pathResults)); string pathArchive = Path.Combine(RunPath, ResultArchiver.DIR_ARCHIVE); Assert.That(Directory.Exists(pathArchive)); // Method under test resultArchiver.Archive(); // Check results string[] directoriesProgramVersion = Directory.GetDirectories(pathArchive); Assert.That(directoriesProgramVersion.Length, Is.EqualTo(1)); string[] directoriesBits = Directory.GetDirectories(directoriesProgramVersion[0]); Assert.That(directoriesBits.Length, Is.EqualTo(1)); // Design Results string[] directoriesSuite = Directory.GetDirectories(directoriesBits[0]); Assert.That(directoriesSuite.Length, Is.EqualTo(1)); string[] directoriesRuns = Directory.GetDirectories(directoriesSuite[0]); Assert.That(directoriesRuns.Length, Is.EqualTo(1)); string archiveDestinationPath = Path.Combine(pathArchive, "SAP2000 v19.2.0 Build 1350", "32-bit", "Design", "Run as is"); string resultsSummaryFilePath = Path.Combine(archiveDestinationPath, "test_results_2017-08-15(225720) SAP2000_19.2.0 Build_1350 run_as_is.html"); Assert.That(File.Exists(resultsSummaryFilePath)); string logDestinationPath = Path.Combine(archiveDestinationPath, "logs"); string logFilePath = Path.Combine(logDestinationPath, "AISC 360-05 SFD Ex002.LOG"); Assert.That(File.Exists(logFilePath)); }
public void ResultArchiver_Initialization_Custom_PathRoot() { string customRootPath = @"C:\\Foo\Bar"; ResultArchiver resultArchiverPath = new ResultArchiver(); string pathConfig = Path.Combine(resultArchiverPath.PathRoot, ResultArchiver.CONFIG_FILENAME); ResultArchiver resultArchiver = new ResultArchiver(pathConfig, customRootPath); Assert.That(resultArchiver.PathRoot, Is.EqualTo(customRootPath)); }
public void Archive_Examples_Development() { // Set up object ResultArchiver resultArchiver = new ResultArchiver("SAP2000", "20.0.0.1381", "development", testDescriptions: new List <string> { "Run as is" }); RunPath = resultArchiver.PathRoot; // Set up directories string sourceBasePath = Directory.GetParent(Directory.GetParent(NCrunchEnvironment.GetOriginalSolutionPath()).FullName).FullName; sourceBasePath = Path.Combine(sourceBasePath, "resources", "_Tests"); copyDirectory(sourceBasePath, RunPath); string pathSource = Path.Combine(RunPath, ResultArchiver.DIR_TESTING); Assert.That(Directory.Exists(pathSource)); string pathResults = Path.Combine(RunPath, ResultArchiver.DIR_RESULTS); Assert.That(Directory.Exists(pathResults)); string pathArchive = Path.Combine(RunPath, ResultArchiver.DIR_ARCHIVE); Assert.That(Directory.Exists(pathArchive)); // Method under test resultArchiver.Archive(); // Check results string[] directoriesProgramVersion = Directory.GetDirectories(pathArchive); Assert.That(directoriesProgramVersion.Length, Is.EqualTo(1)); string[] directoriesBits = Directory.GetDirectories(directoriesProgramVersion[0]); Assert.That(directoriesBits.Length, Is.EqualTo(1)); string[] directoriesSuite = Directory.GetDirectories(directoriesBits[0]); Assert.That(directoriesSuite.Length, Is.EqualTo(1)); string[] directoriesRuns = Directory.GetDirectories(directoriesSuite[0]); Assert.That(directoriesRuns.Length, Is.EqualTo(1)); string archiveDestinationPath = Path.Combine(pathArchive, "SAP2000 v20.0.0 Build 1381", "32-bit", "Development", "Run as is"); string resultsSummaryFilePath = Path.Combine(archiveDestinationPath, "test_results_2017-12-08(024756) SAP2000_20.0.0 Build_1381 run_as_is.html"); Assert.That(File.Exists(resultsSummaryFilePath)); string logDestinationPath = Path.Combine(archiveDestinationPath, "logs"); string logFilePath = Path.Combine(logDestinationPath, "AISC 360-16 SFD Ex001.LOG"); Assert.That(File.Exists(logFilePath)); logFilePath = Path.Combine(logDestinationPath, "AISC 360-16 SFD Ex002.LOG"); Assert.That(File.Exists(logFilePath)); }
/// <summary> /// Defines the entry point of the application. /// </summary> /// <param name="args">The arguments for a custom path and/or filename to the config XML file. /// If only the file name is given, it is assumed that the file is at the same location as the running application.</param> public static void Main(string[] args) { string assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string configFilePath = (args != null && args.Length > 0) ? args[0] : assemblyPath; string pathRoot = (args != null && args.Length > 1) ? args[1] : assemblyPath; ResultArchiver resultArchiver = new ResultArchiver(configFilePath, pathRoot); resultArchiver.Archive(); }
public void ResultArchiver_Initialization_Empty_Test_Descriptions() { ResultArchiver resultArchiver = new ResultArchiver(PROGRAM, VERSION, RUNTYPE_SINGLE, null, testDescriptions: new List <string>()); Assert.That(resultArchiver.Application, Is.EqualTo(PROGRAM)); Assert.That(resultArchiver.Version, Is.EqualTo(VERSION)); Assert.That(resultArchiver.RunType, Is.EqualTo(RUNTYPE_SINGLE)); Assert.That(resultArchiver.SuiteNames.Count, Is.EqualTo(0)); Assert.That(resultArchiver.TestDescriptions.Count, Is.EqualTo(1)); Assert.That(resultArchiver.TestDescriptions[0], Is.EqualTo(DESCRIPTION_STANDARD)); }
public void ResultArchiver_Initialization_From_Config_File_Defaults() { ResultArchiver resultArchiver = new ResultArchiver(); Assert.That(resultArchiver.Application, Is.EqualTo(PROGRAM)); Assert.That(resultArchiver.Version, Is.EqualTo(VERSION)); Assert.That(resultArchiver.RunType, Is.EqualTo(RUNTYPE_SINGLE)); Assert.IsTrue(resultArchiver.OverWriteExisting); Assert.That(resultArchiver.SuiteNames[0], Is.EqualTo(SUITE_NAME_FILE)); Assert.That(resultArchiver.TestDescriptions[0], Is.EqualTo(DESCRIPTION_FILE)); }
public void ResultArchiver_Initialization_Specified_And_Defaults() { Assert.That(ResultArchiver.BitsRun[0], Is.EqualTo(BIT_RUN)); Assert.That(ResultArchiver.PsbTestDescriptions[0], Is.EqualTo(DESCRIPTION)); Assert.That(ResultArchiver.StandardSuites[0], Is.EqualTo("Analysis")); ResultArchiver resultArchiver = new ResultArchiver(PROGRAM, VERSION, RUNTYPE_PSB); //Assert.That(resultArchiver.PathRoot, Is.EqualTo(pathSource)); // Source is at location of program. Not useful for testing. Assert.That(resultArchiver.Application, Is.EqualTo(PROGRAM)); Assert.That(resultArchiver.Version, Is.EqualTo(VERSION)); Assert.That(resultArchiver.RunType, Is.EqualTo(RUNTYPE_PSB)); Assert.IsFalse(resultArchiver.OverWriteExisting); Assert.That(resultArchiver.SuiteNames.Count, Is.EqualTo(0)); Assert.That(resultArchiver.TestDescriptions.Count, Is.EqualTo(9)); Assert.That(resultArchiver.TestDescriptions[3], Is.EqualTo(ResultArchiver.PsbTestDescriptions[3])); }
public void ResultArchiver_Initialization_Specified_No_Defaults() { List <string> suiteNames = new List <string> { "Foo", "Bar" }; List <string> testDescriptions = new List <string> { "Moo", "Nar" }; ResultArchiver resultArchiver = new ResultArchiver(PROGRAM, VERSION, RUNTYPE_SINGLE, suiteNames, testDescriptions, overWriteExisting: true); Assert.That(resultArchiver.Application, Is.EqualTo(PROGRAM)); Assert.That(resultArchiver.Version, Is.EqualTo(VERSION)); Assert.That(resultArchiver.RunType, Is.EqualTo(RUNTYPE_SINGLE)); Assert.IsTrue(resultArchiver.OverWriteExisting); Assert.That(resultArchiver.SuiteNames.Count, Is.EqualTo(2)); Assert.That(resultArchiver.SuiteNames[1], Is.EqualTo(suiteNames[1])); Assert.That(resultArchiver.TestDescriptions.Count, Is.EqualTo(2)); Assert.That(resultArchiver.TestDescriptions[1], Is.EqualTo(testDescriptions[1])); }
public void Archive_Single_Not_OverwriteExisting_Does_Not_Overwrite_Existing_File() { // Set up object ResultArchiver resultArchiverPath = new ResultArchiver(); RunPath = resultArchiverPath.PathRoot; // Set up directories string sourceBasePath = Directory.GetParent(Directory.GetParent(NCrunchEnvironment.GetOriginalSolutionPath()).FullName).FullName; sourceBasePath = Path.Combine(sourceBasePath, "resources", "_Tests"); copyDirectory(sourceBasePath, RunPath); string pathSource = Path.Combine(RunPath, ResultArchiver.DIR_TESTING); Assert.That(Directory.Exists(pathSource)); string pathResults = Path.Combine(RunPath, ResultArchiver.DIR_RESULTS); Assert.That(Directory.Exists(pathResults)); string pathArchive = Path.Combine(RunPath, ResultArchiver.DIR_ARCHIVE); Assert.That(Directory.Exists(pathArchive)); // Create duplicate directory string pathDuplicateSource = Path.Combine(pathResults, "SAP2000", "Design", "Single", "Success - 2017-08-15(225720) SAP2000_19.2.0 Build_1350 run_as_is"); copyDirectory(Path.Combine(pathDuplicateSource, "Steel Frame"), Path.Combine(pathDuplicateSource, "Steel Frame - Copy")); // Set up custom config file string configFile = "ResultsArchiver_NoOverwriteExisting.Config.xml"; sourceBasePath = Directory.GetParent(Directory.GetParent(NCrunchEnvironment.GetOriginalSolutionPath()).FullName).FullName; sourceBasePath = Path.Combine(sourceBasePath, "ResultsArchiver", "resources-testing"); string fileDestination = Path.Combine(resultArchiverPath.PathRoot, configFile); if (!File.Exists(fileDestination)) { File.Copy(Path.Combine(sourceBasePath, configFile), fileDestination); } // Test ResultArchiver resultArchiver = new ResultArchiver(configFile); Assert.IsFalse(resultArchiver.OverWriteExisting); resultArchiver.Archive(); // Check results string[] directoriesProgramVersion = Directory.GetDirectories(pathArchive); Assert.That(directoriesProgramVersion.Length, Is.EqualTo(1)); string[] directoriesBits = Directory.GetDirectories(directoriesProgramVersion[0]); Assert.That(directoriesBits.Length, Is.EqualTo(1)); // Design Results string[] directoriesSuite = Directory.GetDirectories(directoriesBits[0]); Assert.That(directoriesSuite.Length, Is.EqualTo(1)); string[] directoriesRuns = Directory.GetDirectories(directoriesSuite[0]); Assert.That(directoriesRuns.Length, Is.EqualTo(1)); string archiveDestinationPath = Path.Combine(pathArchive, "SAP2000 v19.2.0 Build 1350", "32-bit", "Design", "Run as is"); string resultsSummaryFilePath = Path.Combine(archiveDestinationPath, "test_results_2017-08-15(225720) SAP2000_19.2.0 Build_1350 run_as_is.html"); Assert.That(File.Exists(resultsSummaryFilePath)); string logDestinationPath = Path.Combine(archiveDestinationPath, "logs"); string logFilePath = Path.Combine(logDestinationPath, "AISC 360-05 SFD Ex002.LOG"); Assert.That(File.Exists(logFilePath)); }
public void Archive_PSB() { // Set up object ResultArchiver resultArchiver = new ResultArchiver("SAP2000", "20.0.0.1384", RUNTYPE_PSB); RunPath = resultArchiver.PathRoot; string solutionPath = NCrunchEnvironment.GetOriginalSolutionPath(); string sourceBasePath = Directory.GetParent(Directory.GetParent(solutionPath).FullName).FullName; sourceBasePath = Path.Combine(sourceBasePath, "resources", "_Tests"); copyDirectory(sourceBasePath, RunPath); string pathSource = Path.Combine(RunPath, ResultArchiver.DIR_TESTING); Assert.That(Directory.Exists(pathSource)); string pathResults = Path.Combine(RunPath, ResultArchiver.DIR_RESULTS); Assert.That(Directory.Exists(pathResults)); string pathArchive = Path.Combine(RunPath, ResultArchiver.DIR_ARCHIVE); Assert.That(Directory.Exists(pathArchive)); // Method under test resultArchiver.Archive(); // Check results string[] directoriesProgramVersion = Directory.GetDirectories(pathArchive); Assert.That(directoriesProgramVersion.Length, Is.EqualTo(1)); string[] directoriesBits = Directory.GetDirectories(directoriesProgramVersion[0]); Assert.That(directoriesBits.Length, Is.EqualTo(2)); // Analysis Results string[] directoriesSuite = Directory.GetDirectories(directoriesBits[1]); Assert.That(directoriesSuite.Length, Is.EqualTo(1)); string[] directoriesRuns = Directory.GetDirectories(directoriesSuite[0]); Assert.That(directoriesRuns.Length, Is.EqualTo(9)); // Check first PSB string archiveDestinationPath = Path.Combine(pathArchive, "SAP2000 v20.0.0 Build 1384", "64-bit", "Analysis", "P1 S1 B1"); string resultsSummaryFilePath = Path.Combine(archiveDestinationPath, "test_results_2017-12-15(180937) SAP2000_20.0.0 Build_1384 run_as_is.html"); Assert.That(File.Exists(resultsSummaryFilePath)); string logDestinationPath = Path.Combine(archiveDestinationPath, "logs"); string logFilePath = Path.Combine(logDestinationPath, "Example 1-001.LOG"); Assert.That(File.Exists(logFilePath)); // Check Standard PSB archiveDestinationPath = Path.Combine(pathArchive, "SAP2000 v20.0.0 Build 1384", "64-bit", "Analysis", "P2 S2 B1 - Standard"); resultsSummaryFilePath = Path.Combine(archiveDestinationPath, "test_results_2017-12-15(180952) SAP2000_20.0.0 Build_1384 run_as_is.html"); Assert.That(File.Exists(resultsSummaryFilePath)); logDestinationPath = Path.Combine(archiveDestinationPath, "logs"); logFilePath = Path.Combine(logDestinationPath, "Example 1-001.LOG"); Assert.That(File.Exists(logFilePath)); }
public void Archive_Does_Nothing_When_PathRoot_Does_Not_Exist() { ResultArchiver resultArchiver = new ResultArchiver(pathRoot: @"c:\Foo\Bar"); Assert.DoesNotThrow(() => resultArchiver.Archive()); }
public string ResultArchiver_Initialization_RunTypes(string runType) { ResultArchiver resultArchiverSingle = new ResultArchiver(PROGRAM, VERSION, runType); return(resultArchiverSingle.RunType); }