public void each_BinPath_can_have_multiple_OutputPath()
        {
            var output1 = TestHelper.CleanupFolder(_outputFolder.AppendPart("each_BinPath_can_have_multiple_OutputPath").AppendPart("o1"), false);
            var output2 = TestHelper.CleanupFolder(_outputFolder.AppendPart("each_BinPath_can_have_multiple_OutputPath").AppendPart("o2"), false);

            var config = new StObjEngineConfiguration();

            config.Aspects.Add(new TypeScriptAspectConfiguration());
            var b = new BinPathConfiguration();

            b.AspectConfigurations.Add(new XElement("TypeScript", new XElement("OutputPath", output1), new XElement("OutputPath", output2)));
            config.BinPaths.Add(b);

            var engine = new StObjEngine(TestHelper.Monitor, config);

            engine.Run(new MonoCollectorResolver(typeof(Simple))).Should().BeTrue("StObjEngine.Run worked.");
            Directory.Exists(output1).Should().BeTrue();
            Directory.Exists(output2).Should().BeTrue();

            var f1 = output1.Combine("CK/StObj/TypeScript/Tests/Simple.ts");
            var f2 = output2.Combine("CK/StObj/TypeScript/Tests/Simple.ts");

            File.Exists(f1).Should().BeTrue();
            File.Exists(f2).Should().BeTrue();

            var s = File.ReadAllText(f1);

            s.Should().StartWith("export enum Simple");
            s.Should().Be(File.ReadAllText(f2));
        }
        /// <summary>
        /// Low level helper that initializes a new <see cref="StObjEngineConfiguration"/> and computes the force setup flag
        /// that can be used by other helpers that need to run a setup.
        /// </summary>
        /// <param name="helper">The <see cref="IStObjSetupTestHelper"/> helper.</param>
        /// <returns>The configuration and the flag.</returns>
        static public (StObjEngineConfiguration Configuration, ForceSetupLevel ForceSetup) CreateDefaultConfiguration(IActivityMonitor monitor,
                                                                                                                      IStObjSetupTestHelper helper)
        {
            var stObjConf = new StObjEngineConfiguration
            {
                RevertOrderingNames         = helper.StObjRevertOrderingNames,
                TraceDependencySorterInput  = helper.StObjTraceGraphOrdering,
                TraceDependencySorterOutput = helper.StObjTraceGraphOrdering,
            };
            // BinPath by default is: the first "CKSetup/DefaultBinPaths" if it has been configured
            // otherwise it is the {ClosestSUTProjectFolder}/{PathToBin} (if no ClosestSUTProjectFolder
            // has been found, {ClosestSUTProjectFolder} is the {TestProjectFolder} so {ClosestSUTProjectFolder}/{PathToBin}
            // is... this {BinFolder})
            NormalizedPath binPath;

            if (helper.CKSetup.DefaultBinPaths.Count > 0)
            {
                binPath = helper.CKSetup.DefaultBinPaths[0];
                monitor.Info($"Using first configured 'CKSetup/DefaultBinPaths' = {binPath}");
            }
            else
            {
                binPath = helper.ClosestSUTProjectFolder.Combine(helper.PathToBin);
                monitor.Info($"No 'CKSetup/DefaultBinPaths' configuration. Using ClosestSUTProjectFolder/PathToBin: {binPath}.");
            }

            var b = new BinPathConfiguration
            {
                // The name of the BinPath to use is the current IStObjMapTestHelper.BinPathName.
                Name = helper.BinPathName,
                Path = binPath,
                // Then the OutputPath will copy the generated assembly to this bin folder.
                OutputPath    = helper.BinFolder,
                CompileOption = CompileOption.Compile,
                // ...and the G0.cs to the TestProjectFolder.
                GenerateSourceFiles = helper.StObjGenerateSourceFiles,
                ProjectPath         = helper.TestProjectFolder
            };

            stObjConf.BinPaths.Add(b);

            // Consider by default the CKSetup configuration that be not None,
            // but if it is None, set it to Engine: the engine must run even if
            // all the binaries are unchanged to check the G0.cs and assembly.

            var f = helper.CKSetup.ForceSetup;

            if (f == ForceSetupLevel.None)
            {
                monitor.Trace($"Setting CKSetup ForceSetupLevel to Engine so it can check the required artifacts.");
                f = ForceSetupLevel.Engine;
            }
            return(stObjConf, f);
        }
        static NormalizedPath GenerateTSCode(string testName, params Type[] types)
        {
            var output = TestHelper.CleanupFolder(_outputFolder.AppendPart(testName), false);
            var config = new StObjEngineConfiguration();

            config.Aspects.Add(new TypeScriptAspectConfiguration());
            var b = new BinPathConfiguration();

            b.AspectConfigurations.Add(new XElement("TypeScript", new XElement("OutputPath", output)));

            config.BinPaths.Add(b);

            var engine = new StObjEngine(TestHelper.Monitor, config);

            engine.Run(new MonoCollectorResolver(types)).Should().BeTrue("StObjEngine.Run worked.");
            Directory.Exists(output).Should().BeTrue();
            return(output);
        }
        static (NormalizedPath BinTSPath1, NormalizedPath BinTSPath2) GenerateTSCode(string testName, params Type[] types)
        {
            var output1 = TestHelper.CleanupFolder(_outputFolder.AppendPart(testName).AppendPart("b1"), false);
            var output2 = TestHelper.CleanupFolder(_outputFolder.AppendPart(testName).AppendPart("b2"), false);

            var config = new StObjEngineConfiguration();

            config.Aspects.Add(new TypeScriptAspectConfiguration());

            var b1 = new BinPathConfiguration();

            b1.AspectConfigurations.Add(new XElement("TypeScript", new XElement("OutputPath", output1)));
            var b2 = new BinPathConfiguration();

            b2.AspectConfigurations.Add(new XElement("TypeScript", new XElement("OutputPath", output2)));
            // b3 has no TypeScript aspect or no OutputPath or an empty OutputPath: nothing must be generated and this is just a warning.
            var b3 = new BinPathConfiguration();

            switch (Environment.TickCount % 3)
            {
            case 0: b3.AspectConfigurations.Add(new XElement("TypeScript", new XElement("OutputPath", " "))); break;

            case 1: b3.AspectConfigurations.Add(new XElement("TypeScript")); break;
            }

            config.BinPaths.Add(b1);
            config.BinPaths.Add(b2);
            config.BinPaths.Add(b3);

            var engine = new StObjEngine(TestHelper.Monitor, config);

            engine.Run(new MonoCollectorResolver(types)).Should().BeTrue("StObjEngine.Run worked.");
            Directory.Exists(output1).Should().BeTrue();
            Directory.Exists(output2).Should().BeTrue();

            return(output1, output2);
        }
 public StObjCollectorResult GetSecondaryResult(BinPathConfiguration head, IEnumerable <BinPathConfiguration> all)
 {
     throw new NotImplementedException("There is only one BinPath: only the unified one is required.");
 }
 public StObjCollectorResult GetUnifiedResult(BinPathConfiguration unified)
 {
     return(TestHelper.GetSuccessfulResult(TestHelper.CreateStObjCollector(_types)));
 }