コード例 #1
0
        public void WriteAndReadJsonData()
        {
            TxtDB txtDb = new TxtDB("jsonTest");

            txtDb.OverWrite(JsonConvert.SerializeObject(TestObj.GetTestObj(), Formatting.Indented));

            string jsontxt = txtDb.ReadAll();

            Assert.AreEqual(JsonConvert.DeserializeObject <TestObj>(jsontxt), TestObj.GetTestObj());

            txtDb.DumpFile();
        }
コード例 #2
0
        public void ReadAllAndWriteAll()
        {
            TxtDB  txtDb      = new TxtDB("info");
            string alltext    = txtDb.ReadAll();
            string testString = "Addtest" + Guid.NewGuid().ToString("N");

            if (!alltext.EndsWith(Environment.NewLine))
            {
                alltext += Environment.NewLine;
            }
            alltext += testString;
            txtDb.OverWrite(alltext);
            Assert.AreEqual(testString, txtDb.ReadLastLine());
        }