public void ModsetConfig_LoadConfig_Success() { _settingsMock.Setup(settings => settings.ModsetConfigDirectoryName).Returns(_modsetConfigDirName); _configMock.Setup(x => x.DirectoryPath).Returns(_workingDirectory); _configMock.Setup(x => x.BasicCfg).Returns(Path.Join(_workingDirectory, "example_basic.cfg")); _configMock.Setup(x => x.ServerCfg).Returns(Path.Join(_workingDirectory, "example_server.cfg")); _configMock.Setup(x => x.ConfigJson).Returns(Path.Join(_workingDirectory, "common.json")); var expectedModsetConfigDirectory = Path.Join(_workingDirectory, _modsetConfigDirName, _modsetName); var expectedModsetConfigFiles = new[] { "server.cfg", "basic.cfg", "config.json" }; var configFileCreator = new ConfigFileCreator(new ConfigReplacer(new NullLogger <ConfigReplacer>())); IModsetConfig modsetConfig = new ModsetConfig( _configMock.Object, _settingsMock.Object, _modsetName, configFileCreator, new NullLogger <ModsetConfig>(), _fileSystemMock); var configLoaded = modsetConfig.CopyConfigFiles(); using (new AssertionScope()) { configLoaded.IsSuccess.Should().BeTrue(); _fileSystemMock.Directory.Exists(expectedModsetConfigDirectory).Should().BeTrue(); _fileSystemMock.Directory.GetFiles(expectedModsetConfigDirectory) .Select(Path.GetFileName).Should().BeEquivalentTo(expectedModsetConfigFiles); } }
/// <summary> /// Generates configuration file with default values. /// </summary> /// <param name="overrideFileIfExists">Old configuration file will be replaced when set to true.</param> /// <returns>True if configuration file was successfully created; false otherwise.</returns> public static bool CreateDefaultConfigurationFile(bool overrideFileIfExists) { var path = $@"{Application.dataPath}\Resources"; var fileName = ConfigurationConstants.CONFIG_FILE_NAME; // Create Resources directory if not exists System.IO.Directory.CreateDirectory(path); return(ConfigFileCreator.Create(path, fileName, overrideFileIfExists)); }
public ModsetConfigurationProvider( ISettings settings, ConfigFileCreator configFileCreator, ILogger <ServerConfig> serverConfigLogger, ILogger <ModsetConfig> modsetConfigLogger) { _settings = settings; _configFileCreator = configFileCreator; _serverConfigLogger = serverConfigLogger; _modsetConfigLogger = modsetConfigLogger; }