Ejemplo n.º 1
0
        public static string GetSolutionDirectory()
        {
            const string solutionName = "FacilityCSharp.sln";

            string solutionFilePath = NCrunchEnvironment.GetOriginalSolutionPath();

            if (solutionFilePath != null && Path.GetFileName(solutionFilePath) == solutionName)
            {
                return(Path.GetDirectoryName(solutionFilePath));
            }

            string solutionDirectoryPath = AssemblyHelper.GetDirectoryName(typeof(TestUtility).Assembly);

            while (solutionDirectoryPath != null)
            {
                if (File.Exists(Path.Combine(solutionDirectoryPath, solutionName)))
                {
                    return(solutionDirectoryPath);
                }
                solutionDirectoryPath = Path.GetDirectoryName(solutionDirectoryPath);
            }

            solutionDirectoryPath = Environment.CurrentDirectory;
            if (File.Exists(Path.Combine(solutionDirectoryPath, solutionName)))
            {
                return(solutionDirectoryPath);
            }

            throw new InvalidOperationException("Failed to locate solution directory.");
        }
Ejemplo n.º 2
0
        public void TestFixtureSetup()
        {
            PathBase = Directory.GetParent(NCrunchEnvironment.GetOriginalSolutionPath()).FullName;
            PathBase = Path.Combine(PathBase, "resources-testing", "_results");

            PathDestination = Path.Combine(PathBase, PROGRAM, DIRECTORY_RESULT);
        }
Ejemplo n.º 3
0
        public void ExampleReleaser_Initialization_From_Config_File_By_FileName_Only()
        {
            // Set up custom config file
            string          configFile          = "ExamplesReleaser_CustomName.Config.xml";
            string          program             = "ETABS";
            ExampleReleaser exampleReleaserPath = new ExampleReleaser();

            string sourceBasePath = Directory.GetParent(Directory.GetParent(NCrunchEnvironment.GetOriginalSolutionPath()).FullName).FullName;

            sourceBasePath = Path.Combine(sourceBasePath, "ExamplesReleaser", "resources-testing");
            string fileDestination = Path.Combine(exampleReleaserPath.PathRoot, configFile);

            if (!File.Exists(fileDestination))
            {
                File.Copy(Path.Combine(sourceBasePath, configFile), fileDestination);
            }
            _filesToClean.Add(fileDestination);

            // Test
            ExampleReleaser exampleReleaser = new ExampleReleaser(configFile);

            // Check results
            Assert.That(exampleReleaser.Application, Is.EqualTo(program));
            Assert.That(exampleReleaser.PathExamplesSource, Is.EqualTo(Path.Combine(exampleReleaser.PathRoot, @"..\" + ExampleReleaser.DIR_SOURCE)));
            Assert.That(exampleReleaser.PathExamplesRelease, Is.EqualTo(Path.Combine(exampleReleaser.PathRoot, program, ExampleReleaser.DIR_RELEASE)));
        }
Ejemplo n.º 4
0
        public void TestFixtureSetup()
        {
            PathBase = Directory.GetParent(NCrunchEnvironment.GetOriginalSolutionPath()).FullName;
            PathBase = Path.Combine(PathBase, "resources-testing", "_modelsDB");

            PathDestination = Path.Combine(PathBase, "release");
        }
Ejemplo n.º 5
0
        public void ExampleReleaser_Initialization_From_Config_File_By_Full_File_Path()
        {
            // Set up custom config file
            string          configFile          = "ExamplesReleaser_CustomName.Config.xml";
            ExampleReleaser exampleReleaserPath = new ExampleReleaser();

            string sourceBasePath = Directory.GetParent(Directory.GetParent(NCrunchEnvironment.GetOriginalSolutionPath()).FullName).FullName;

            sourceBasePath    = Path.Combine(sourceBasePath, "ExamplesReleaser", "resources-testing");
            OtherLocationPath = Path.Combine(exampleReleaserPath.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
            ExampleReleaser exampleReleaser = new ExampleReleaser(fileDestination);

            // Check results
            Assert.That(exampleReleaser.Application, Is.EqualTo("ETABS"));
            Assert.That(exampleReleaser.PathExamplesSource, Is.EqualTo(@"\..\" + ExampleReleaser.DIR_SOURCE));
            Assert.That(exampleReleaser.PathExamplesRelease, Is.EqualTo(Path.Combine(exampleReleaser.PathRoot, ExampleReleaser.DIR_RELEASE)));
        }
        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));
        }
Ejemplo n.º 9
0
        public void ExampleReleaser_Initialization_From_Config_File_Empty_Properties()
        {
            // Set up custom config file
            string          configFile          = "ExamplesReleaser_EmptyProperties.Config.xml";
            ExampleReleaser exampleReleaserPath = new ExampleReleaser();

            string sourceBasePath = Directory.GetParent(Directory.GetParent(NCrunchEnvironment.GetOriginalSolutionPath()).FullName).FullName;

            string fileDestination = Path.Combine(exampleReleaserPath.PathRoot, configFile);

            if (!File.Exists(fileDestination))
            {
                File.Copy(Path.Combine(sourceBasePath, "ExamplesReleaser", "resources-testing", configFile), fileDestination);
            }

            // Test
            ExampleReleaser exampleReleaser = new ExampleReleaser(configFile);

            // Check results
            Assert.That(exampleReleaser.Application, Is.EqualTo(string.Empty));
            Assert.That(exampleReleaser.PathExamplesSource, Is.EqualTo(Path.Combine(exampleReleaser.PathRoot, @"\..\", ExampleReleaser.DIR_SOURCE)));
            Assert.That(exampleReleaser.PathExamplesRelease, Is.EqualTo(Path.Combine(exampleReleaser.PathRoot, ExampleReleaser.DIR_RELEASE)));

            // Archive should do nothing with a malformed object
            Assert.DoesNotThrow(() => exampleReleaser.Release());
        }
Ejemplo n.º 10
0
        public void Main_With_File_Argument_Releases_Examples_From_Specified_Config_File()
        {
            RunPath = Environment.CurrentDirectory;
            string[] paths = NCrunchEnvironment.GetAllAssemblyLocations();
            foreach (string path in paths)
            {
                if (!path.Contains(ConsoleName))
                {
                    continue;
                }
                RunPath = Path.GetDirectoryName(path);
                break;
            }

            string sourceBasePath = Directory.GetParent(NCrunchEnvironment.GetOriginalSolutionPath()).FullName;

            // Set up custom config file
            string configFile         = "ExamplesReleaser_CustomName.Config.xml";
            string sourceBasePathFile = Path.Combine(sourceBasePath, "resources-testing");
            string fileDestination    = Path.Combine(RunPath, configFile);

            if (!File.Exists(fileDestination))
            {
                File.Copy(Path.Combine(sourceBasePathFile, configFile), fileDestination);
            }
            _filesToClean.Add(fileDestination);

            // Set up test directories
            sourceBasePath = Path.Combine(sourceBasePath, "resources-testing");
            string pathSource = Path.Combine(RunPath, @"..\", ExampleReleaser.DIR_SOURCE);

            copyDirectory(sourceBasePath, pathSource);
            _directoriesToClean.Add(pathSource);

            Assert.That(Directory.Exists(pathSource));

            string pathRelease = Path.Combine(RunPath, "ETABS", ExampleReleaser.DIR_RELEASE);

            Assert.That(!Directory.Exists(pathRelease));

            // Method under test
            string[] parameters = { configFile };
            Program.Main(parameters);

            // Check results
            Assert.That(Directory.Exists(pathRelease));

            string[] directoriesPathRelease = Directory.GetDirectories(pathRelease);
            Assert.That(directoriesPathRelease.Length, Is.EqualTo(2));

            Assert.That(File.Exists(Path.Combine(pathRelease, "Analysis", "Example 1-003.edb")));
            Assert.That(File.Exists(Path.Combine(pathRelease, "Analysis", "Example 6-010.edb")));
            Assert.That(File.Exists(Path.Combine(pathRelease, "Analysis", "EQ6-010-trans.txt")));
            Assert.That(File.Exists(Path.Combine(pathRelease, "Design", "Steel Frame", "BS 5950-2000 SFD Ex002.edb")));
            Assert.That(File.Exists(Path.Combine(pathRelease, "Design", "Shear Wall", "ACI 318-14 SWD Ex002.edb")));
            Assert.That(File.Exists(Path.Combine(pathRelease, "Design", "Shear Wall", "CSA A23.3-04 SWD Ex001.edb")));
            Assert.That(File.Exists(Path.Combine(pathRelease, "Design", "Concrete Frame", "ACI 318-14 CFD Ex001.edb")));
            Assert.That(File.Exists(Path.Combine(pathRelease, "Design", "Composite Beam", "BS 5950-1990 CBD Ex001.edb")));
        }
Ejemplo n.º 11
0
        public void ReleaseExample_Releases_CSiBrige_Examples_From_SAP2000_Directory()
        {
            // Set up custom config file
            string          configFile          = "ExamplesReleaser_modelsDB_CSiBridge.Config.xml";
            ExampleReleaser exampleReleaserPath = new ExampleReleaser();

            string sourceBasePath = Directory.GetParent(Directory.GetParent(NCrunchEnvironment.GetOriginalSolutionPath()).FullName).FullName;

            sourceBasePath    = Path.Combine(sourceBasePath, "ExamplesReleaser", "resources-testing");
            OtherLocationPath = Path.Combine(exampleReleaserPath.PathRoot, "otherLocation");
            string fileDestination = Path.Combine(OtherLocationPath, configFile);

            if (!Directory.Exists(OtherLocationPath))
            {
                Directory.CreateDirectory(OtherLocationPath);
                _directoriesToClean.Add(OtherLocationPath);
            }
            if (!File.Exists(fileDestination))
            {
                File.Copy(Path.Combine(sourceBasePath, configFile), fileDestination);
                _filesToClean.Add(fileDestination);
            }

            // Copy models
            string modelsDatabasePath            = Path.Combine(sourceBasePath, "_modelsDB");
            string modelsDatabaseDestinationPath = Path.Combine(OtherLocationPath, "_modelsDB");

            if (!Directory.Exists(modelsDatabaseDestinationPath))
            {
                copyDirectory(modelsDatabasePath, modelsDatabaseDestinationPath);
                _directoriesToClean.Add(modelsDatabaseDestinationPath);
            }

            // Set up object
            ExampleReleaser exampleReleaser = new ExampleReleaser(fileDestination);

            RunPath = exampleReleaser.PathRoot;
            string pathRelease = Path.Combine(RunPath, "CSiBridge", ExampleReleaser.DIR_RELEASE);

            _directoriesToClean.Add(pathRelease);
            Assert.That(!Directory.Exists(pathRelease));

            // Method under test
            exampleReleaser.Release();

            // Check results
            Assert.That(exampleReleaser.ExamplesToRelease.Count, Is.EqualTo(3));

            Assert.That(Directory.Exists(pathRelease));

            string[] directoriesPathRelease = Directory.GetDirectories(pathRelease);
            Assert.That(directoriesPathRelease.Length, Is.EqualTo(1));

            Assert.That(!File.Exists(Path.Combine(pathRelease, "Design", "Steel Frame", "AISC 360-05 SFD Ex001.bdb")));
            Assert.That(File.Exists(Path.Combine(pathRelease, "Analysis", "Example 1-001.bdb")));
            Assert.That(File.Exists(Path.Combine(pathRelease, "Analysis", "Example 1-004.bdb")));
            Assert.That(File.Exists(Path.Combine(pathRelease, "Analysis", "Example 7-002.bdb")));
        }
        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));
        }
Ejemplo n.º 13
0
        public void Main_EXE_NoArguments_Creates_Archive_From_Default_Config_File()
        {
            RunPath = Environment.CurrentDirectory;
            string[] paths = NCrunchEnvironment.GetAllAssemblyLocations();
            foreach (string path in paths)
            {
                if (!path.Contains(ConsoleName))
                {
                    continue;
                }
                RunPath = Path.GetDirectoryName(path);
                break;
            }
            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
            startConsoleApplication(Path.Combine(RunPath, ConsoleName), workingDirectory: RunPath);

            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));

            // Design Results
            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_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));
        }
        public static string?TryFindVcsRootPath(Action <string>?logger = null)
        {
            if (NCrunchEnvironment.NCrunchIsResident())
            {
                var originalSolutionFileInfo = new FileInfo(NCrunchEnvironment.GetOriginalSolutionPath());
                return(VcsPathHelper.TryFindVcsRootPath(originalSolutionFileInfo.Directory?.FullName, logger));
            }

            return(VcsPathHelper.TryFindVcsRootPath(logger: logger));
        }
Ejemplo n.º 16
0
        public static string FindVcsRootPath(string baseDir = null)
        {
            if (NCrunchEnvironment.NCrunchIsResident())
            {
                var fileInfo = new FileInfo(NCrunchEnvironment.GetOriginalSolutionPath());

                return(VcsPathHelper.FindVcsRootPath(fileInfo.Directory?.FullName));
            }

            return(VcsPathHelper.FindVcsRootPath(baseDir));
        }
Ejemplo n.º 17
0
        public static string FindVcsRootPath()
        {
            if (NCrunchEnvironment.NCrunchIsResident())
            {
                var directory = new FileInfo(NCrunchEnvironment.GetOriginalSolutionPath()).Directory;

                return(VcsPathHelper.FindVcsRootPath(directory?.FullName));
            }

            return(VcsPathHelper.FindVcsRootPath());
        }
Ejemplo n.º 18
0
        public void Main_NoArguments_Releases_Examples_From_Default_Config_File()
        {
            RunPath = Environment.CurrentDirectory;
            string[] paths = NCrunchEnvironment.GetAllAssemblyLocations();
            foreach (string path in paths)
            {
                if (!path.Contains(ConsoleName))
                {
                    continue;
                }
                RunPath = Path.GetDirectoryName(path);
                break;
            }
            string sourceBasePath = Directory.GetParent(NCrunchEnvironment.GetOriginalSolutionPath()).FullName;

            sourceBasePath = Path.Combine(sourceBasePath, "resources-testing");
            copyDirectory(sourceBasePath, RunPath);

            string pathSource = Path.Combine(RunPath, ExampleReleaser.DIR_SOURCE);

            Assert.That(Directory.Exists(pathSource));

            string pathRelease = Path.Combine(RunPath, ExampleReleaser.DIR_RELEASE);

            Assert.That(Directory.Exists(pathRelease));

            // Method under test
            Program.Main(null);

            // Check results
            // TODO:
            Assert.That(false);
            //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));

            //// Design Results
            //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));
        }
Ejemplo n.º 19
0
        public static string GetRootDirectory(string?basePath = null)
        {
            string originalSolutionPath = NCrunchEnvironment.GetOriginalSolutionPath();

            if (!string.IsNullOrWhiteSpace(originalSolutionPath))
            {
                var fileInfo = new FileInfo(originalSolutionPath);
                return(VcsPathHelper.FindVcsRootPath(fileInfo.Directory?.FullName ?? Directory.GetCurrentDirectory()));
            }

            return(VcsPathHelper.FindVcsRootPath(basePath ?? new FileInfo(typeof(VcsTestPathHelper).Assembly.Location).DirectoryName ?? Directory.GetCurrentDirectory()));
        }
Ejemplo n.º 20
0
        private static DacPackage GetDacPackage(string packageName)
        {
            string basePath      = AppDomain.CurrentDomain.BaseDirectory;
            int    removeAtIndex = basePath.IndexOf($"\\{System.Reflection.Assembly.GetExecutingAssembly().GetName().Name}");

            basePath = $"{basePath.Remove(removeAtIndex)}\\dacpac";

            if (NCrunchEnvironment.NCrunchIsResident())
            {
                basePath = Path.GetDirectoryName(NCrunchEnvironment.GetOriginalSolutionPath()) + $"\\dacpac";
            }

            return(DacPackage.Load($"{basePath}\\{packageName}.dacpac"));
        }
Ejemplo n.º 21
0
        public void ExampleReleaser_Initialization_Specified()
        {
            RunPath         = Environment.CurrentDirectory;
            DestinationPath = Directory.GetParent(Directory.GetParent(NCrunchEnvironment.GetOriginalSolutionPath()).FullName).FullName;

            Assert.That(ExampleReleaser.MODEL_CONTROL_XML_FILE_PATTERN, Is.EqualTo("*_MC.xml"));
            Assert.That(ExampleReleaser.CONFIG_FILENAME, Is.EqualTo("ExamplesReleaser.Config.xml"));
            Assert.That(ExampleReleaser.DIR_RELEASE, Is.EqualTo("Verification"));
            Assert.That(ExampleReleaser.DIR_SOURCE, Is.EqualTo("Verification"));
            Assert.That(ExampleReleaser.StandardSuites[0], Is.EqualTo("Analysis"));
            Assert.That(ExampleReleaser.StandardSuites[1], Is.EqualTo("Design"));

            ExampleReleaser exampleReleaser = new ExampleReleaser(PROGRAM, RunPath, DestinationPath);

            //Assert.That(exampleReleaser.PathRoot, Is.EqualTo(PATH_SOURCE)); // Source is at location of program. Not useful for testing.
            Assert.That(exampleReleaser.Application, Is.EqualTo(PROGRAM));
            Assert.That(exampleReleaser.PathExamplesSource, Is.EqualTo(RunPath));
            Assert.That(exampleReleaser.PathExamplesRelease, Is.EqualTo(DestinationPath));
        }
Ejemplo n.º 22
0
        public void ExampleReleaser_Correctly_Reads_Custom_Config_File()
        {
            // Set up custom config file
            string          configFile          = "ExamplesReleaser_modelsDB.Config.xml";
            ExampleReleaser exampleReleaserPath = new ExampleReleaser();

            string sourceBasePath = Directory.GetParent(Directory.GetParent(NCrunchEnvironment.GetOriginalSolutionPath()).FullName).FullName;

            sourceBasePath    = Path.Combine(sourceBasePath, "ExamplesReleaser", "resources-testing");
            OtherLocationPath = Path.Combine(exampleReleaserPath.PathRoot, "otherLocation");
            string fileDestination = Path.Combine(OtherLocationPath, configFile);

            if (!Directory.Exists(OtherLocationPath))
            {
                Directory.CreateDirectory(OtherLocationPath);
            }
            _directoriesToClean.Add(OtherLocationPath);
            if (!File.Exists(fileDestination))
            {
                File.Copy(Path.Combine(sourceBasePath, configFile), fileDestination);
            }
            _filesToClean.Add(fileDestination);

            // Copy models
            string modelsDatabasePath            = Path.Combine(sourceBasePath, "_modelsDB");
            string modelsDatabaseDestinationPath = Path.Combine(OtherLocationPath, "_modelsDB");

            if (!Directory.Exists(modelsDatabaseDestinationPath))
            {
                copyDirectory(modelsDatabasePath, modelsDatabaseDestinationPath);
            }
            _directoriesToClean.Add(modelsDatabaseDestinationPath);

            // Set up object
            ExampleReleaser exampleReleaser = new ExampleReleaser(fileDestination);

            // Method under test
            Assert.That(exampleReleaser.Application, Is.EqualTo(PROGRAM));
            Assert.That(exampleReleaser.PathExamplesSource, Is.EqualTo(modelsDatabaseDestinationPath));
            Assert.That(exampleReleaser.PathExamplesRelease, Is.EqualTo(Path.Combine(exampleReleaser.PathRoot, PROGRAM, ExampleReleaser.DIR_RELEASE)));
        }
Ejemplo n.º 23
0
        public void Main_EXE_NoArguments_Releases_Examples_From_Default_Config_File()
        {
            RunPath = Environment.CurrentDirectory;
            string[] paths = NCrunchEnvironment.GetAllAssemblyLocations();
            foreach (string path in paths)
            {
                if (!path.Contains(ConsoleName))
                {
                    continue;
                }
                RunPath = Path.GetDirectoryName(path);
                break;
            }
            string sourceBasePath = Directory.GetParent(NCrunchEnvironment.GetOriginalSolutionPath()).FullName;

            sourceBasePath = Path.Combine(sourceBasePath, "resources-testing");
            string pathSource = Path.Combine(RunPath, @"..\", ExampleReleaser.DIR_SOURCE);

            copyDirectory(sourceBasePath, pathSource);
            _directoriesToClean.Add(pathSource);

            Assert.That(Directory.Exists(pathSource));

            string pathRelease = Path.Combine(RunPath, PROGRAM, ExampleReleaser.DIR_RELEASE);

            Assert.That(!Directory.Exists(pathRelease));

            // Method under test
            startConsoleApplication(Path.Combine(RunPath, ConsoleName), workingDirectory: RunPath);

            // Check results
            Assert.That(Directory.Exists(pathRelease));

            string[] directoriesPathRelease = Directory.GetDirectories(pathRelease);
            Assert.That(directoriesPathRelease.Length, Is.EqualTo(2));

            Assert.That(File.Exists(Path.Combine(pathRelease, "Design", "Steel Frame", "AISC 360-05 SFD Ex001.sdb")));
            Assert.That(File.Exists(Path.Combine(pathRelease, "Analysis", "Example 1-001.sdb")));
            Assert.That(File.Exists(Path.Combine(pathRelease, "Analysis", "Example 1-004.sdb")));
            Assert.That(File.Exists(Path.Combine(pathRelease, "Analysis", "Example 7-002.sdb")));
        }
Ejemplo n.º 24
0
        public void ExampleReleaser_Releases_Examples_Of_Program_Set_For_Release_And_None_Others()
        {
            // Set up custom config file
            string          configFile          = "ExamplesReleaser_modelsDB.Config.xml";
            ExampleReleaser exampleReleaserPath = new ExampleReleaser();

            string sourceBasePath = Directory.GetParent(Directory.GetParent(NCrunchEnvironment.GetOriginalSolutionPath()).FullName).FullName;

            sourceBasePath    = Path.Combine(sourceBasePath, "ExamplesReleaser", "resources-testing");
            OtherLocationPath = Path.Combine(exampleReleaserPath.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);
            }
            string modelsDatabasePath            = Path.Combine(sourceBasePath, "_modelsDB");
            string modelsDatabaseDestinationPath = Path.Combine(OtherLocationPath, "_modelsDB");

            if (!Directory.Exists(modelsDatabaseDestinationPath))
            {
                copyDirectory(modelsDatabasePath, modelsDatabaseDestinationPath);
            }

            // Set up object
            ExampleReleaser exampleReleaser = new ExampleReleaser(fileDestination);

            // Method under test
            exampleReleaser.Release();

            Assert.That(exampleReleaser.ExamplesToRelease.Count, Is.EqualTo(4));
        }
Ejemplo n.º 25
0
        public void ReleaseExample_Copy_File_Overwrite_of_ReadOnly_Does_Not_Throw_Exception()
        {
            // Set up custom config file
            string          configFile          = "ExamplesReleaser_modelsDB_ETABS_RedundantReadOnly.Config.xml";
            ExampleReleaser exampleReleaserPath = new ExampleReleaser();

            string sourceBasePath = Directory.GetParent(Directory.GetParent(NCrunchEnvironment.GetOriginalSolutionPath()).FullName).FullName;

            sourceBasePath    = Path.Combine(sourceBasePath, "ExamplesReleaser", "resources-testing");
            OtherLocationPath = Path.Combine(exampleReleaserPath.PathRoot, "otherLocation");
            string fileDestination = Path.Combine(OtherLocationPath, configFile);

            if (!Directory.Exists(OtherLocationPath))
            {
                Directory.CreateDirectory(OtherLocationPath);
            }
            _directoriesToClean.Add(OtherLocationPath);
            if (!File.Exists(fileDestination))
            {
                File.Copy(Path.Combine(sourceBasePath, configFile), fileDestination);
            }
            _filesToClean.Add(fileDestination);

            // Copy models
            string modelsDatabasePath            = Path.Combine(sourceBasePath, "_modelsDB");
            string modelsDatabaseDestinationPath = Path.Combine(OtherLocationPath, "_modelsDB");

            if (!Directory.Exists(modelsDatabaseDestinationPath))
            {
                copyDirectory(modelsDatabasePath, modelsDatabaseDestinationPath);
            }
            _directoriesToClean.Add(modelsDatabaseDestinationPath);

            // Set up object
            ExampleReleaser exampleReleaser = new ExampleReleaser(fileDestination);

            RunPath = exampleReleaser.PathRoot;
            string pathRelease = Path.Combine(RunPath, "ETABS", ExampleReleaser.DIR_RELEASE);

            _directoriesToClean.Add(pathRelease);
            Assert.That(!Directory.Exists(pathRelease));

            // Method under test
            Assert.DoesNotThrow(() => exampleReleaser.Release());

            // Check results
            Assert.That(exampleReleaser.ExamplesToRelease.Count, Is.EqualTo(8));

            Assert.That(Directory.Exists(pathRelease));

            string[] directoriesPathRelease = Directory.GetDirectories(pathRelease);
            Assert.That(directoriesPathRelease.Length, Is.EqualTo(2));

            Assert.That(File.Exists(Path.Combine(pathRelease, "Analysis", "Example 1-003.edb")));
            Assert.That(File.Exists(Path.Combine(pathRelease, "Analysis", "Example 6-011a.edb")));
            Assert.That(File.Exists(Path.Combine(pathRelease, "Analysis", "Example 6-011b.edb")));
            Assert.That(File.Exists(Path.Combine(pathRelease, "Analysis", "EQ6-011.txt")));
            Assert.That(File.Exists(Path.Combine(pathRelease, "Design", "Steel Frame", "BS 5950-2000 SFD Ex002.edb")));
            Assert.That(File.Exists(Path.Combine(pathRelease, "Design", "Shear Wall", "ACI 318-14 SWD Ex002.edb")));
            Assert.That(File.Exists(Path.Combine(pathRelease, "Design", "Shear Wall", "CSA A23.3-04 SWD Ex001.edb")));
            Assert.That(File.Exists(Path.Combine(pathRelease, "Design", "Concrete Frame", "ACI 318-14 CFD Ex001.edb")));
            Assert.That(File.Exists(Path.Combine(pathRelease, "Design", "Composite Beam", "BS 5950-1990 CBD Ex001.edb")));
        }
        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_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));
        }
Ejemplo n.º 28
0
        public void Main_With_File_Path_Argument_Creates_Archive_From_Specified_Config_File_at_Specified_Location()
        {
            RunPath = Environment.CurrentDirectory;
            string[] paths = NCrunchEnvironment.GetAllAssemblyLocations();
            foreach (string path in paths)
            {
                if (!path.Contains(ConsoleName))
                {
                    continue;
                }
                RunPath = Path.GetDirectoryName(path);
                break;
            }

            string sourceBasePath = Directory.GetParent(Directory.GetParent(NCrunchEnvironment.GetOriginalSolutionPath()).FullName).FullName;

            // Set up custom config file
            string configFile         = "ResultsArchiver_CustomName.Config.xml";
            string sourceBasePathFile = Path.Combine(sourceBasePath, "ResultsArchiver", "resources-testing");
            string otherLocationPath  = Path.Combine(RunPath, "otherLocation");

            if (!Directory.Exists(otherLocationPath))
            {
                Directory.CreateDirectory(otherLocationPath);
            }
            string fileDestination = Path.Combine(otherLocationPath, configFile);

            if (!File.Exists(fileDestination))
            {
                File.Copy(Path.Combine(sourceBasePathFile, configFile), fileDestination);
            }


            // Set up test directories
            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
            string[] parameters = { fileDestination };
            Program.Main(parameters);

            // Test 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));

            // Design Results
            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));
        }