public void Empty_DOSBoxSettingOverride_List_Is_Passed_And_Should_Use_Default_Value() { var gg = new DOSBoxManagerTest(); var settings = new DOSBoxConfigSettings { Sections = new List <DOSBoxConfigSection> { new DOSBoxConfigSection { Name = "[sdl]", Settings = new List <DOSBoxSetting> { new DOSBoxSetting { Name = "Setting_1", DefaultValue = "One", Description = "One 1", Section = "[sdl]", Values = new List <string>() } } } } }; var overrideSettings = new List <DOSBoxSettingOverride>(); var configString = gg.BuildDOSBoxConfigFile(settings, overrideSettings); Assert.Equal($"[sdl]{Environment.NewLine}Setting_1=One{Environment.NewLine}", configString); }
public static void LoadDefaultSettings() { try { DefaultSettings = JsonFileHelper.ReadAsObject <DOSBoxConfigSettings>(DefaultDOSBoxConfigJson); } catch (FileNotFoundException e) { throw e; } }
public string BuildDOSBoxConfigFile(DOSBoxConfigSettings defaultSettings, List <DOSBoxSettingOverride> overrideSettings) { var configFileString = from s in defaultSettings.Sections let settings = from setting in s.Settings join ljos in (overrideSettings ?? new List <DOSBoxSettingOverride>()) on setting.Name equals ljos.Name into temp from joined in temp.DefaultIfEmpty() select $"{setting.Name}={(joined != null ? joined.SelectedValue : setting.DefaultValue)}" select $@"{s.Name}{Environment.NewLine}{string.Join(Environment.NewLine, settings.ToList())}{Environment.NewLine}"; return(string.Join(Environment.NewLine, configFileString)); }
public static List <DOSBoxSettingForConfig> GetSettingsForGame(Game game, DOSBoxConfigSettings defaultSettings) { var overrideSettings = game.DOSBoxOverrides ?? new List <DOSBoxSettingOverride>(); var merged = from ds in defaultSettings.Sections.SelectMany(section => section.Settings) join os in overrideSettings on ds.Name equals os.Name into temp from joined in temp.DefaultIfEmpty() select new DOSBoxSettingForConfig { DefaultValue = ds.DefaultValue, Description = ds.Description, Name = ds.Name, Section = ds.Section, SelectedValue = joined != null ? joined.SelectedValue : ds.DefaultValue, Values = ds.Values }; return(merged.ToList()); }
public void Default_Setting_Is_Overridden() { var gg = new DOSBoxManagerTest(); var settings = new DOSBoxConfigSettings { Sections = new List <DOSBoxConfigSection> { new DOSBoxConfigSection { Name = "[sdl]", Settings = new List <DOSBoxSetting> { new DOSBoxSetting { Name = "Setting_1", DefaultValue = "One", Description = "One 1", Section = "[sdl]", Values = new List <string>() } } } } }; var overrideSettings = new List <DOSBoxSettingOverride> { new DOSBoxSettingOverride { Name = "Setting_1", Section = "[sdl]", SelectedValue = "2" } }; var configString = gg.BuildDOSBoxConfigFile(settings, overrideSettings); Assert.Equal($"[sdl]{Environment.NewLine}Setting_1=2{Environment.NewLine}", configString); }