public void TestListOfSimple() { var expected = new List <ClassSimple> { new ClassSimple { name = "Test value #1", value = 12345 }, new ClassSimple { name = "It should be on a second place", value = 54321 }, new ClassSimple { name = "Last element. Ordering is important", value = 777 } }; var actual = ConfigTestTools.LoadValidConfig <List <ClassSimple> >( Config.SaveToString(Config.ConvertFromClass(expected)) ); Assert.IsTrue(expected.SequenceEqual(actual)); }
public void TestLoadValue() { var config = ConfigTestTools.LoadValidConfig("key value"); Assert.AreEqual(1, config.GetKeys().Length, "1 value should be loaded"); var value = config.Get(config.GetKeys()[0]); Assert.IsNotNull(value, "Should get existing key"); Assert.AreEqual("value", ConfigTestTools.GetData(value), "Should have a data after key"); }
public void TestLoadMultipleValues() { var config = ConfigTestTools.LoadValidConfig("key 1\nkey 2"); Assert.AreEqual(1, config.GetKeys().Length, "1 value should be loaded"); var values = config.GetAll(config.GetKeys()[0]); Assert.IsNotNull(values, "Should get all existing values from key"); Assert.AreEqual(2, values.Count, "Should get exactly 2 values for key"); Assert.AreEqual("1", ConfigTestTools.GetData(values[0]), "Should have a data after key 1"); Assert.AreEqual("2", ConfigTestTools.GetData(values[1]), "Should have a data after key 1"); }
public void TestLoadSimple() { var expected = new ClassSimple { name = "Test method", value = 15210 }; var actual = ConfigTestTools.LoadValidConfig <ClassSimple>( Config.SaveToString(Config.ConvertFromClass(expected)) ); Assert.AreEqual(expected, actual); }
public void TestLoadMultipleKeys() { var config = ConfigTestTools.LoadValidConfig("keyA 1\nkeyB 2"); Assert.AreEqual(2, config.GetKeys().Length, "2 values should be loaded"); var valueA = config.Get(config.GetKeys()[0]); var valueB = config.Get(config.GetKeys()[1]); Assert.IsNotNull(valueA, "Should get a value from key 1"); Assert.IsNotNull(valueB, "Should get a value from key 2"); Assert.AreEqual("1", ConfigTestTools.GetData(valueA), "Should have a data after key 1"); Assert.AreEqual("2", ConfigTestTools.GetData(valueB), "Should have a data after key 2"); }
public void TestLoadEnclosedValue() { var config = ConfigTestTools.LoadValidConfig("key value\n key inner"); Assert.AreEqual(1, config.GetKeys().Length, "1 value should be loaded at top level"); var value = config.Get(config.GetKeys()[0]); Assert.IsNotNull(value, "Should get a value from key"); Assert.AreEqual("value", ConfigTestTools.GetData(value), "Should have a data value"); Assert.AreEqual(1, value.GetKeys().Length, "Should have 1 inner value"); var innerValue = value.Get(value.GetKeys()[0]); Assert.IsNotNull(value, "Should get a value from inner key"); Assert.AreEqual("inner", ConfigTestTools.GetData(innerValue), "Should have a data value"); }
public void TestComplexValues() { var expected = new ClassComplex { time = DateTime.MinValue.AddDays(1234), i = 1125, l = 962377529306543236, s = "This\nis\ta{TEST} \"of\" parser's capabilities", d = 256.125 }; var actual = ConfigTestTools.LoadValidConfig <ClassComplex>( Config.SaveToString(Config.ConvertFromClass(expected)) ); Assert.AreEqual(expected, actual); }
public void TestLoadMultipleData() { var config = ConfigTestTools.LoadValidConfig("key 3 2 1"); Assert.AreEqual(1, config.GetKeys().Length, "1 value should be loaded"); var value = config.Get(config.GetKeys()[0]); Assert.IsNotNull(value, "Should get a value from key"); Assert.AreEqual("3 2 1", ConfigTestTools.GetData(value), "Should have a data after key"); Assert.AreEqual(3, value.AsArray()?.Length, "Should have 3 data values in value"); CollectionAssert.AreEqual( new[] { "3", "2", "1" }, value.AsArray(), "Should have data values in right order" ); }
public void TestLoadSelfContained() { var expected = new ClassSelfContained { value = "Root element", contained = new ClassSelfContained { value = "Inner class", contained = new ClassSelfContained { value = "Deeply placed container.", contained = null } } }; var actual = ConfigTestTools.LoadValidConfig <ClassSelfContained>( Config.SaveToString(Config.ConvertFromClass(expected)) ); Assert.AreEqual(expected, actual); }
public void TestLoadEmpty() { var config = ConfigTestTools.LoadValidConfig(""); Assert.AreEqual(0, config.GetKeys().Length, "Config should have no enclosed values by default"); }