Ejemplo n.º 1
0
        public void TestSavePersistent()
        {
            string key1     = "key1";
            string toWrite1 = "val1";

            NtCore.SetEntryValue(key1, Value.MakeString(toWrite1));
            NtCore.SetEntryFlags(key1, EntryFlags.Persistent);

            string key2 = "key2";

            NtCore.SetEntryValue(key2, Value.MakeBoolean(true));
            NtCore.SetEntryFlags(key2, EntryFlags.Persistent);

            string fileName = "testfile.txt";

            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }

            NtCore.SavePersistent(fileName);

            string[] lines = File.ReadAllLines(fileName);

            Assert.That(lines.Length, Is.GreaterThanOrEqualTo(3));
            Assert.That(lines[0], Contains.Substring("[NetworkTables Storage 3.0]"));
            Assert.That(lines[1], Contains.Substring($"string \"{key1}\"=\"{toWrite1}\""));
            Assert.That(lines[2], Contains.Substring($"boolean \"{key2}\"=true"));
        }