Пример #1
0
        public void ExampleReleaser_Does_Nothing_When_PathRoot_Does_Not_Exist()
        {
            ExampleReleaser exampleReleaser = new ExampleReleaser(pathRoot: @"c:\Foo\Bar");

            Assert.DoesNotThrow(() => exampleReleaser.Release());
            Assert.That(exampleReleaser.ExamplesToRelease.Count, Is.EqualTo(0));
        }
Пример #2
0
        public void ExampleReleaser_Does_Nothing_When_Required_Directories_Do_Not_Exist()
        {
            ExampleReleaser exampleReleaserBase = new ExampleReleaser(PROGRAM);
            string          pathSource          = Path.Combine(exampleReleaserBase.PathRoot, ExampleReleaser.DIR_SOURCE);
            string          pathRelease         = Path.Combine(exampleReleaserBase.PathRoot, ExampleReleaser.DIR_RELEASE);

            ExampleReleaser exampleReleaser = new ExampleReleaser(PROGRAM, pathSource, pathRelease);

            RunPath = exampleReleaser.PathRoot;


            if (Directory.Exists(pathSource))
            {
                Directory.Delete(pathSource, recursive: true);
            }

            Assert.DoesNotThrow(() => exampleReleaser.Release());

            if (Directory.Exists(pathRelease))
            {
                Directory.Delete(pathRelease, recursive: true);
            }

            Assert.DoesNotThrow(() => exampleReleaser.Release());
            Assert.IsFalse(Directory.Exists(pathRelease));
            Assert.That(exampleReleaser.ExamplesToRelease.Count, Is.EqualTo(0));
        }
Пример #3
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());
        }
Пример #4
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)));
        }
Пример #5
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)));
        }
Пример #6
0
        public void ExampleReleaser_Initialization_From_Config_File_Defaults()
        {
            ExampleReleaser exampleReleaser = new ExampleReleaser();

            Assert.That(exampleReleaser.Application, Is.EqualTo(PROGRAM));
            Assert.That(exampleReleaser.PathExamplesSource, Is.EqualTo(@"\..\" + ExampleReleaser.DIR_SOURCE));
            Assert.That(exampleReleaser.PathExamplesRelease, Is.EqualTo(Path.Combine(exampleReleaser.PathRoot, ExampleReleaser.DIR_RELEASE)));
        }
Пример #7
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")));
        }
Пример #8
0
        public void ExampleReleaser_Does_Nothing_When_Required_Properties_Are_NullOrEmpty()
        {
            // Set up object
            ExampleReleaser exampleReleaser = new ExampleReleaser(null, @"c:\", @"c:\Program Files");

            // Method under test
            Assert.DoesNotThrow(() => exampleReleaser.Release());
            Assert.That(exampleReleaser.ExamplesToRelease.Count, Is.EqualTo(0));
        }
Пример #9
0
        public void ExampleReleaser_Initialization_Custom_PathRoot()
        {
            string          customRootPath      = @"C:\\Foo\Bar";
            ExampleReleaser exampleReleaserPath = new ExampleReleaser();
            string          pathConfig          = Path.Combine(exampleReleaserPath.PathRoot, ExampleReleaser.CONFIG_FILENAME);
            ExampleReleaser exampleReleaser     = new ExampleReleaser(pathConfig, customRootPath);

            Assert.That(exampleReleaser.PathRoot, Is.EqualTo(customRootPath));
        }
Пример #10
0
        /// <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;

            ExampleReleaser exampleReleaser = new ExampleReleaser(configFilePath, pathRoot);

            exampleReleaser.Release();
        }
Пример #11
0
        public void ExampleReleaser_Initialization_Specified_Invalid_Source_Destination_Directories()
        {
            RunPath         = @"c:\foo";
            DestinationPath = @"c:\bar";

            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(@"\..\" + ExampleReleaser.DIR_SOURCE));
            Assert.That(exampleReleaser.PathExamplesRelease, Is.EqualTo(Path.Combine(exampleReleaser.PathRoot, ExampleReleaser.DIR_RELEASE)));
        }
Пример #12
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));
        }
Пример #13
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)));
        }
Пример #14
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));
        }
Пример #15
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")));
        }