public void UnparseableNumericValueReturnsFalse() { var configuration = new RequestedConfiguration(); var result = new ConfigurationReader().Read(configuration, new [] { "enable", "Uranium:5a" }); Assert.False(result); }
static Dictionary <string, RequestedConfiguration> TranslateObjectList(ReverseConditionTable table, IEnumerable <ObjectEntry> list, Dictionary <string, string> optionalDictionary = null) { Dictionary <string, RequestedConfiguration> result = new Dictionary <string, RequestedConfiguration>(); foreach (var entry in list) { var cfg = new RequestedConfiguration { Framework = table.Frameworks[entry.OneBasedFrameworkIndex - 1] }; if (entry.OneBasedConfigurationFragmentIndex != 0) { cfg.Configuration = table.ConditionTable[entry.OneBasedConfigurationFragmentIndex - 1].RequestedConfiguration; } string key = entry.ObjectName; if (optionalDictionary != null && optionalDictionary.TryGetValue(key, out var val)) { key = val; } result[key] = cfg; } return(result); }
public void CanRoundtrip() { var original = new RequestedConfiguration { BlockRules = { new BlockRule { BlockName = "Ore", Include = false }, }, Displays = { new RequestedDisplayConfiguration { DisplayName = "Components", IncludeCategories ={ "Components" }, }, new RequestedDisplayConfiguration { DisplayName = "Hydrogen", IncludeCategories ={ "Hydrogen" }, }, }, }; var serialised = new ConfigurationWriter().Serialise(original); var roundtripped = new ConfigurationReader().Deserialise(serialised); Assert.Multiple(() => { Assert.That(roundtripped.BlockRules, Is.EquivalentTo(original.BlockRules)); Assert.That(roundtripped.Displays, Is.EquivalentTo(original.Displays).Using(new RequestedDisplayConfigurationEqualityComparer())); }); }
public void ChangingBlockInclusionMovesItToTheEndOfTheRules() { var configuration = new RequestedConfiguration { BlockRules = { new BlockRule { BlockName = "A", Include = true }, new BlockRule { BlockName = "B", Include = false }, new BlockRule { BlockName = "C", Include = true }, } }; new ConfigurationReader().Read(configuration, new [] { "exclude", "B" }); Assert.That(configuration.BlockRules, Is.EqualTo(new [] { new BlockRule { BlockName = "A", Include = true }, new BlockRule(), new BlockRule { BlockName = "C", Include = true }, new BlockRule { BlockName = "B", Include = false }, })); }
public void CanForgetBlockName() { var configuration = new RequestedConfiguration { BlockRules = { new BlockRule { BlockName = "A", Include = true }, new BlockRule { BlockName = "B", Include = false }, new BlockRule { BlockName = "C", Include = true }, } }; new ConfigurationReader().Read(configuration, new [] { "forget", "B" }); Assert.That(configuration.BlockRules, Is.EqualTo(new [] { new BlockRule { BlockName = "A", Include = true }, new BlockRule(), new BlockRule { BlockName = "C", Include = true }, })); }
public void CanSpecifyRefinerySpeed() { var configuration = new RequestedConfiguration(); new ConfigurationReader().Read(configuration, new [] { "refinery-speed", "5" }); Assert.That(configuration.RefinerySpeedFactor, Is.EqualTo(5)); }
public void CanSpecifyAssemblerSpeed() { var configuration = new RequestedConfiguration(); new ConfigurationReader().Read(configuration, new [] { "assembler-speed", "4" }); Assert.That(configuration.AssemblerSpeedFactor, Is.EqualTo(4)); }
public void CanSpecifyOreStatusDisplayName() { var configuration = new RequestedConfiguration(); new ConfigurationReader().Read(configuration, new [] { "show-ore", "Display Name with a : in it" }); Assert.That(configuration.OreStatusDisplayName, Is.EqualTo("Display Name with a : in it")); }
public void CanIncludeBlockName() { var configuration = new RequestedConfiguration(); new ConfigurationReader().Read(configuration, new [] { "include", "Ore" }); Assert.That(configuration.BlockRules, Is.EqualTo(new [] { new BlockRule { BlockName = "Ore", Include = true } })); }
public void CanEnableIngot() { var configuration = new RequestedConfiguration(); new ConfigurationReader().Read(configuration, new [] { "enable", "Uranium" }); RequestedIngotConfiguration ingot; Assert.True(configuration.Ingots.TryGetValue(new ItemType("Ingot/Uranium"), out ingot)); Assert.True(ingot.Enable); }
public void IngotsMayBeIdentifiedByPath() { var configuration = new RequestedConfiguration(); new ConfigurationReader().Read(configuration, new [] { "enable", "Ore/Ice" }); RequestedIngotConfiguration ingot; Assert.True(configuration.Ingots.TryGetValue(new ItemType("Ore/Ice"), out ingot)); Assert.True(ingot.Enable); }
public void CanSpecifyContainersToScan() { var configuration = new RequestedConfiguration(); new ConfigurationReader().Read(configuration, new [] { "scan", "Ore Containers", "scan", "Ingot Containers" }); Assert.That(configuration.InventoryBlockNames, Is.EquivalentTo(new [] { "Ore Containers", "Ingot Containers" })); }
public void CanConfigureStockpileTargetAndLimit() { var configuration = new RequestedConfiguration(); new ConfigurationReader().Read(configuration, new [] { "enable", "Uranium:50:100" }); RequestedIngotConfiguration ingot; Assert.True(configuration.Ingots.TryGetValue(new ItemType("Ingot/Uranium"), out ingot)); Assert.That(ingot.StockpileTarget, Is.EqualTo(50)); Assert.That(ingot.StockpileLimit, Is.EqualTo(100)); }
public void StockpileParametersAreUpdatedForDisabledIngots() { var configuration = new RequestedConfiguration(); new ConfigurationReader().Read(configuration, new [] { "disable", "Platinum:50:100" }); RequestedIngotConfiguration ingot; Assert.True(configuration.Ingots.TryGetValue(new ItemType("Ingot/Platinum"), out ingot)); Assert.False(ingot.Enable); Assert.That(ingot.StockpileTarget, Is.EqualTo(50)); Assert.That(ingot.StockpileLimit, Is.EqualTo(100)); }
public void CanRoundtrip() { var original = new RequestedConfiguration { Ingots = { [new ItemType("Ingot/Iron")] = new RequestedIngotConfiguration { Enable = true, StockpileTarget = 500, StockpileLimit = 1000 }, [new ItemType("Ingot/Platinum")] = new RequestedIngotConfiguration { Enable = false, StockpileLimit = 200 }, [new ItemType("Ore/Test")] = new RequestedIngotConfiguration { Enable = true, StockpileTarget = 700 }, }, InventoryBlockNames = { "Storage", "Buffer", }, OreStatusDisplayName = "Status: \"Ore\"", IngotStatusDisplayName = "IngotStatus", RefinerySpeedFactor = 5, AssemblerSpeedFactor = 4, }; var serialised = new ConfigurationWriter().Serialise(original); var roundtripped = new ConfigurationReader().Deserialise(serialised); Assert.Multiple(() => { Assert.That(roundtripped.Ingots, Is.EquivalentTo(original.Ingots).Using(new RequestedIngotConfigurationEqualityComparer())); Assert.That(roundtripped.InventoryBlockNames, Is.EquivalentTo(original.InventoryBlockNames)); Assert.That(roundtripped.OreStatusDisplayName, Is.EqualTo(original.OreStatusDisplayName)); Assert.That(roundtripped.IngotStatusDisplayName, Is.EqualTo(original.IngotStatusDisplayName)); Assert.That(roundtripped.RefinerySpeedFactor, Is.EqualTo(original.RefinerySpeedFactor)); Assert.That(roundtripped.AssemblerSpeedFactor, Is.EqualTo(original.AssemblerSpeedFactor)); }); }