public void TestLoadPersistent() { const string key1 = "key1"; const string key2 = "key2"; const string val1 = "val1"; string[] toWrite = new[] { "[NetworkTables Storage 3.0]", $"string \"{key1}\"=\"{val1}\"", $"boolean \"{key2}\"=true", "" }; string fileName = "testfile.txt"; if (File.Exists(fileName)) { File.Delete(fileName); } File.WriteAllLines(fileName, toWrite); IList <string> errors = NtCore.LoadPersistent(fileName); Assert.That(errors.Count, Is.EqualTo(0)); var entries = NtCore.GetEntryInfo("", 0); Assert.That(entries.Count, Is.EqualTo(2)); Assert.That(NtCore.GetEntryValue(key1).GetString(), Is.EqualTo(val1)); Assert.That(NtCore.GetEntryValue(key2).GetBoolean(), Is.EqualTo(true)); }
public void TestDeleteEntry() { string key1 = "testKey"; string toWrite1 = "written"; NtCore.SetEntryValue(key1, Value.MakeString(toWrite1)); string key2 = "testKey2"; double toWrite2 = 3.58; NtCore.SetEntryValue(key2, Value.MakeDouble(toWrite2)); Assert.That(NtCore.GetEntryInfo("", 0).Count, Is.EqualTo(2)); NtCore.DeleteEntry(key1); Assert.That(NtCore.GetEntryInfo("", 0).Count, Is.EqualTo(1)); Assert.That(NtCore.GetEntryValue(key1), Is.Null); }