Exemple #1
0
        public TestData()
        {
            // Backup config and override on filesystem with new.
            OriginalConfig = IConfig <LoaderConfig> .FromPathOrDefault(Paths.LoaderConfigPath);

            TestConfig = MakeTestConfig();
            IConfig <LoaderConfig> .ToPath(TestConfig, Paths.LoaderConfigPath);

            try
            {
                // Populate configurations.
                ModConfigurations = ModConfig.GetAllMods().Select(x => x.Config).ToArray();
                AppConfigurations = ApplicationConfig.GetAllApplications().Select(x => x.Config).ToArray();

                ThisApplication = new ApplicationConfig(IdOfThisApp,
                                                        "Reloaded Mod Loader Tests",
                                                        Environment.CurrentProcessLocation.Value,
                                                        new[] { TestModConfigA.ModId, TestModConfigB.ModId, TestModConfigD.ModId });

                ConfigurationPathOfThisApp = Path.Combine(TestConfig.ApplicationConfigDirectory, IdOfThisApp, ApplicationConfig.ConfigFileName);
                IConfig <ApplicationConfig> .ToPath(ThisApplication, ConfigurationPathOfThisApp);

                // Populate nonexisting dependencies.
                NonexistingDependencies.Add(TestModB.Program.NonexistingDependencyName);
                NonexistingDependencies.Add(TestModC.Program.NonexistingDependencyName);
            }
            catch (Exception)
            {
                IConfig <LoaderConfig> .ToPath(OriginalConfig, Paths.LoaderConfigPath);

                throw;
            }
        }
Exemple #2
0
        public TestData()
        {
            // Backup config and override on filesystem with new.
            bool configExists = File.Exists(LoaderConfigReader.ConfigurationPath());

            if (configExists)
            {
                OriginalConfig = LoaderConfigReader.ReadConfiguration();
            }

            TestConfig = MakeTestConfig();
            LoaderConfigReader.WriteConfiguration(TestConfig);

            try
            {
                // Populate configurations.
                ModConfigurations = ModConfig.GetAllMods().Select(x => x.Object).ToArray();
                AppConfigurations = ApplicationConfig.GetAllApplications().Select(x => x.Object).ToArray();

                ThisApplication = new ApplicationConfig(IdOfThisApp,
                                                        "Reloaded Mod Loader Tests",
                                                        Process.GetCurrentProcess().GetExecutablePath(),
                                                        new[] { TestModConfigA.ModId, TestModConfigB.ModId, TestModConfigD.ModId });

                ConfigurationPathOfThisApp = Path.Combine(TestConfig.ApplicationConfigDirectory, IdOfThisApp, ApplicationConfig.ConfigFileName);
                ApplicationConfig.WriteConfiguration(ConfigurationPathOfThisApp, ThisApplication);

                // Populate nonexisting dependencies.
                NonexistingDependencies.Add(TestModB.Program.NonexistingDependencyName);
                NonexistingDependencies.Add(TestModC.Program.NonexistingDependencyName);
            }
            catch (Exception)
            {
                if (OriginalConfig != null)
                {
                    LoaderConfigReader.WriteConfiguration(OriginalConfig);
                }
                throw;
            }
        }