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

            Assert.IsEmpty(txtDb.ReadLastLine());
            txtDb.DumpFile();
        }
コード例 #2
0
        public void CreateOrWriteToTxt()
        {
            TxtDB  txtDb      = new TxtDB("info");
            string teststring = "Testing" + Guid.NewGuid().ToString("N");

            txtDb.AppendAndSave(teststring);
            string lastline = txtDb.ReadLastLine();

            Assert.AreEqual(lastline, teststring);
        }
コード例 #3
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();
        }
コード例 #4
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());
        }
コード例 #5
0
 public void Setup()
 {
     txtDb = new TxtDB("taskcommandtest");
 }