public void TestWriteCategorizedKey() { var config = HJsonConfig.From("TestFile.hjson"); config.Write("Categoria:Clave6", "Valor6"); config.Write("Categoria:Clave7", "Valor7", "Comentario de la clave 7"); }
public void TestIndexAccess() { var config = HJsonConfig.From(@"TestFile.hjson"); config["SettingIndex"] = "100"; config["SettingIndex"].Should().Be("100"); }
public void TestReadType() { var config = HJsonConfig.From("TestFile.hjson"); // Números enteros Action act = () => config.Read <int>("Tipos:Entero"); act.Should().NotThrow(); config.Read <int>("Tipos:Entero").Should().Be(1); // Números largos act = () => config.Read <long>("Tipos:Largo"); act.Should().NotThrow(); config.Read <long>("Tipos:Largo").Should().Be(1); // Números dobles act = () => config.Read <double>("Tipos:Doble"); act.Should().NotThrow(); config.Read <double>("Tipos:Doble").Should().Be(1.5d); // Números flotantes act = () => config.Read <float>("Tipos:Flotante"); act.Should().NotThrow(); config.Read <float>("Tipos:Flotante").Should().Be(1.5f); // Caracteres act = () => config.Read <char>("Tipos:Caracter"); act.Should().NotThrow(); config.Read <char>("Tipos:Caracter").Should().Be('h'); // Booleanos act = () => config.Read <bool>("Tipos:Booleano"); act.Should().NotThrow(); config.Read <bool>("Tipos:Booleano").Should().Be(false); }
public void TestDeleteKey() { var config = HJsonConfig.From(@"TestFile.hjson"); // Global key config.Write("GlobalKeyToDelete", "ValueToDelete"); config.Read("GlobalKeyToDelete").Should().Be("ValueToDelete"); Action act = () => config.DeleteKey("GlobalKeyToDelete"); act.Should().NotThrow(); config.Read("GlobalKeyToDelete").Should().Be(null); // Local key config.Write("Local:KeyToDelete", "ValueToDelete"); config.Write("Local:KeyToKeep", "ValueToKeep"); config.Read("Local:KeyToDelete").Should().Be("ValueToDelete"); config.Read("Local:KeyToKeep").Should().Be("ValueToKeep"); act = () => config.DeleteKey("Local:KeyToDelete"); act.Should().NotThrow(); config.Read("Local:KeyToDelete").Should().Be(null); config.Read("Local:KeyToKeep").Should().Be("ValueToKeep"); }
public void TestWriteType() { var config = HJsonConfig.From("TestFile.hjson"); // Número entero Action act = () => config.Write("Escrito:Entero", 2); act.Should().NotThrow(); config.Read <int>("Escrito:Entero").Should().Be(2); // Número largo act = () => config.Write("Escrito:Largo", 2L); act.Should().NotThrow(); config.Read <long>("Escrito:Largo").Should().Be(2); // Número doble act = () => config.Write("Escrito:Doble", 2.5d); act.Should().NotThrow(); config.Read <double>("Escrito:Doble").Should().Be(2.5d); // Número flotante act = () => config.Write("Escrito:Flotante", 2.5f); act.Should().NotThrow(); config.Read <float>("Escrito:Flotante").Should().Be(2.5f); // Caracteres act = () => config.Write("Escrito:Caracter", 'x'); act.Should().NotThrow(); config.Read <char>("Escrito:Caracter").Should().Be('x'); // Booleano act = () => config.Write("Escrito:Booleano", true); act.Should().NotThrow(); config.Read <bool>("Escrito:Booleano").Should().Be(true); }
public void TestReadInvalidType() { var config = HJsonConfig.From(@"TestFile.hjson"); Action act = () => config.Read <int>("Clave1"); act.Should().Throw <ConversionImpossibleException>(); }
public void TestWriteInvalidKey() { var config = HJsonConfig.From(@"TestFile.hjson"); Action act = () => config.Write("Invalid:Key:Name", "Value"); act.Should().Throw <InvalidKeyFormatException>(); }
public void TestWriteOrphanKey() { var config = HJsonConfig.From("TestFile.hjson"); config.Write("Clave4", "Valor4"); config.Write("Clave5", "Valor5", "Comentario de la clave 5"); }
public void TestInvalidKey() { var config = HJsonConfig.From("TestFile.hjson"); Action act = () => config.Read("Esta:Clave:Es:Invalida"); act.Should().Throw <InvalidKeyFormatException>(); }
public void TestReadKeys() { var config = HJsonConfig.From("TestFile.hjson"); config.Read("Clave1").Should().Be("Valor1"); config.Read("Clave2").Should().Be("Valor2"); config.Read("Categoria:Clave3").Should().Be("Valor3"); }
public void TestNewJsonFile() { Action act = () => HJsonConfig.From(@"NewFile.hjson"); act.Should().NotThrow(); System.IO.File.Delete("NewFile.hjson"); }
public void TestModifyKey() { var config = HJsonConfig.From(@"TestFile.hjson"); config.Write("Escritura", 100, "Primera escritura"); config.Write("Multi:Escritura", 200, "Segunda escritura"); config.Read <int>("Multi:Escritura").Should().Be(200); }
public void TestSettingsInGlobal() { var config = HJsonConfig.From(@"TestFile.hjson"); var elems = config.SettingsIn(""); elems.Should().HaveCountGreaterOrEqualTo(2); elems.Should().ContainKeys("Clave1", "Clave2"); elems.Should().ContainValues("Valor1", "Valor2"); elems.Should().NotContainKeys("Clave3", "Largo", "Flotante"); }
public void TestSettingsInSection() { var config = HJsonConfig.From(@"TestFile.hjson"); var elems = config.SettingsIn("Tipos"); elems.Should().HaveCountGreaterOrEqualTo(6); elems.Should().ContainKeys("Entero", "Doble", "Booleano"); elems.Should().ContainValues("1", "1.5", "False"); elems.Should().NotContainKeys("Clave1", "Clave3"); }
public void InvalidFileTransfer() { var iniCio = IniConfig.From("TestFile.ini"); Action act = () => iniCio.TransferTo(HJsonConfig.From("Incorrecto.json")); //act.Should().Throw<InvalidFileFormatException>(); New version allows any file format act.Should().NotThrow(); act = () => iniCio.TransferTo(XmlConfig.From("Incorrecto.txt")); //act.Should().Throw<InvalidFileFormatException>(); New version allows any file format act.Should().NotThrow(); }
public void TestDeleteSection() { var config = HJsonConfig.From(@"TestFile.hjson"); config.Write("SectionToDelete:Key1", "Foo"); config.Write("SectionToDelete:Key2", "Bar"); Action act = () => config.DeleteSection("SectionToDelete"); act.Should().NotThrow(); config.Read("SectionToDelete:Key1").Should().Be(null); config.Read("SectionToDelete:Key2").Should().Be(null); }
public void JsonToJsonTranfer() { var iniCio = HJsonConfig.From("TestFileOld.hjson"); var iniFin = iniCio.TransferTo(HJsonConfig.From("TestFileNew.hjson")); }
public void TestNonexistantKey() { var config = HJsonConfig.From("TestFile.hjson"); config.Read("NoExiste:EstaClave").Should().BeNull(); }