public void TestGetEntriesOnlyString() { 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)); string key3 = "testKey3"; bool toWrite3 = true; NtCore.SetEntryValue(key3, Value.MakeBoolean(toWrite3)); Thread.Sleep(20); var entries = NtCore.GetEntryInfo("", NtType.String); Assert.That(1, Is.EqualTo(entries.Count)); Assert.That(entries[0].Name, Is.EqualTo(key1)); Assert.That(entries[0].Type, Is.EqualTo(NtType.String)); Assert.That(entries[0].Flags, Is.EqualTo(EntryFlags.None)); Assert.That(entries[0].LastChange, Is.GreaterThan(0)); }
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 static void DeleteAllWithPersistent() { foreach (var entryInfo in NtCore.GetEntryInfo("", 0)) { NtCore.DeleteEntry(entryInfo.Name); } }
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); }