コード例 #1
0
        public void DefaultFormatEncodeTest1()
        {
            String expected = "0||";
            String actual   = new DefaultFormatConverter().Encode(new string[] { "" });

            Assert.AreEqual(expected, actual);
        }
コード例 #2
0
        public void DefaultFormatDecodeTest3()
        {
            string[] expected  = { "param1", "param2", "param3" };
            string   parameter = "6|param1|6|param2|6|param3|";

            string[] actual = new DefaultFormatConverter().Decode(parameter);
            Assert.AreEqual(expected, actual);
        }
コード例 #3
0
        public void DefaultFormatEncodeTest3()
        {
            string[] parameters = { "param1", "param2", "param3" };
            String   expected   = "6|param1|6|param2|6|param3|";
            String   actual     = new DefaultFormatConverter().Encode(parameters);

            Assert.AreEqual(expected, actual);
        }
コード例 #4
0
        public void DefaultFormatEncodeTest2()
        {
            String expected = "";

            string[] parameters = { };
            String   actual     = new DefaultFormatConverter().Encode(parameters);

            Assert.AreEqual(expected, actual);
        }
コード例 #5
0
 public bool Save(string dirPath, IFormatConverter conv = null)
 {
     Trace.Assert(dirPath != null, "dirPath == null");
     try
     {
         Directory.CreateDirectory(dirPath);
         if (conv == null)
         {
             conv = new DefaultFormatConverter();
         }
         StreamWriter file = new StreamWriter(Path.Combine(dirPath, name));
         file.WriteLine(conv.Encode(columnName.ToArray()));
         for (int i = 0; i < Count; i++)
         {
             file.WriteLine(conv.Encode(this[i].ToArray()));
         }
         file.Close();
     }
     catch (Exception e) { throw new TableException(e.ToString()); }
     return(true);
 }
コード例 #6
0
        public bool Restore(string filePath, IFormatConverter conv = null)
        {
            Trace.Assert(filePath != null, "dirPath == null");
            string line;

            try
            {
                if (conv == null)
                {
                    conv = new DefaultFormatConverter();
                }
                StreamReader file = new StreamReader(filePath);
                Clear();
                columnName = new ColumnNames(conv.Decode(file.ReadLine()));
                while ((line = file.ReadLine()) != null)
                {
                    Contract.Invariant(line != null);
                    AddLine(conv.Decode(line.Trim()));
                }
            }
            catch (Exception e) { Debug.Write("Error restoring:" + name); throw new TableException(e.ToString()); }
            return(true);
        }
コード例 #7
0
 public void DefaultFormatDecodeTest2()
 {
     string[] expected = { };
     string[] actual   = new DefaultFormatConverter().Decode("");
     Assert.AreEqual(expected, actual);
 }