Beispiel #1
0
        public void CSVEncodeTest1()
        {
            String expected = "";
            String actual   = new CSVformatConverter().Encode(new string[] { "" });

            Assert.AreEqual(expected, actual);
        }
Beispiel #2
0
        public void CSVDecodeTest3()
        {
            string[] expected  = { "param1", "param2", "param3" };
            string   parameter = "param1;param2;param3";

            string[] actual = new CSVformatConverter().Decode(parameter);
            Assert.AreEqual(expected, actual);
        }
Beispiel #3
0
        public void CSVEncodeTest3()
        {
            string[] parameters = { "param1", "param2", "param3" };
            String   expected   = "param1;param2;param3";
            String   actual     = new CSVformatConverter().Encode(parameters);

            Assert.AreEqual(expected, actual);
        }
Beispiel #4
0
        public void CSVEncodeTest2()
        {
            String expected = "str1;str2";

            string[] parameters = { "str1", "str2" };
            String   actual     = new CSVformatConverter().Encode(parameters);

            Assert.AreEqual(expected, actual);
        }
Beispiel #5
0
        public static string RESTORE_Command(string param)
        {
            Trace.Assert(param != null, "param == null");
            if (param == "-h")
            {
                return("Restore [path [CSV]]          |-> Restore the database from a provided or default path " +
                       "\nRestore tbName [path [CSV]]   |-> Restore a table from current DB from a provided or default path");
            }
            check(currentDb != noDb, "Not allowed");
            if (param == "")
            {
                currentDb.Restore(); return("Database " + currentDb.name + " restored.");
            }
            IFormatConverter conv = null;

            if (param.EndsWith(" CSV"))
            {
                conv  = new CSVformatConverter();
                param = param.Substring(0, param.Length - 4);
            }
            if (param[1] == ':')
            {
                Contract.Ensures(conv != null);
                currentDb.Restore(param, conv);
                Contract.Requires(currentDb.name != null);
                return("Database " + currentDb.name + " restored.");
            }
            int fSpacePos = param.IndexOf(' ');

            if (fSpacePos == -1)
            {
                fSpacePos = param.Length;
            }
            string tbName  = param.Substring(0, fSpacePos).Trim();
            string dstPath = param.Substring(fSpacePos).Trim();

            if (dstPath.Length > 0)
            {
                currentDb[tbName].Restore(dstPath, conv);
            }
            else
            {
                currentDb[tbName].Restore(Path.Combine(currentDb.GetDirName(), tbName));
            }
            Contract.Requires(tbName != null);
            return("Table " + tbName + " restored.");
        }
Beispiel #6
0
 public void CSVDecodeTest2()
 {
     string[] expected = { "" };
     string[] actual   = new CSVformatConverter().Decode("");
     Assert.AreEqual(expected, actual);
 }