예제 #1
0
        public void TestVerify()
        {
            //using (var verify = MyCSVWriter._initCSV("DDT-verify.csv", "name", "verb", "input_file", "checksum", "fail", "verbose"))
            var  folder        = Column(0);
            var  verb          = Column(1);
            var  input_file    = Column(2);
            var  checksum      = Column(3);
            var  fail          = Boolean.Parse(Column(4));
            var  verbose       = Boolean.Parse(Column(5));
            bool have_checksum = !String.IsNullOrWhiteSpace(checksum);

            var cmdline = $"verify {input_file}";

            if (have_checksum)
            {
                cmdline += $" -c {checksum}";
            }
            if (verbose)
            {
                cmdline += $" -v";
            }

            var proc = FVTestUtil.RunProcess(cmdline, folder);

            // Check against explicit numbers because it is important to ensure that
            // these are correct when batch scripts use the exe in production.
            if (fail)
            {
                Assert.AreEqual(1, proc.ExitCode, folder);
            }
            else
            {
                Assert.AreEqual(0, proc.ExitCode, folder);
            }
        }
예제 #2
0
        public void TestCreate()
        {
            //using (var create = MyCSVWriter._initCSV("DDT-create.csv", "name", "verb", "batchmode", "input_file", "target_file", "expected", "append", "verbose"))
            var folder   = Column(0);
            var verb     = Column(1); // "create", unused
            var isbatch  = Boolean.Parse(Column(2));
            var input    = Column(3);
            var target   = Column(4); // unused
            var expected = Column(5);
            var output   = Column(6);
            var append   = Boolean.Parse(Column(7));
            var verbose  = Boolean.Parse(Column(8));

            using (var cleaner = FileCleaner.New())
            {
                // this is the sloppiest code ever
                if (append)
                {
                    // copy to out-append.json for the test to avoid overwriting generated artifacts
                    var out_append      = "out-append.json";
                    var full_out_append = Path.Combine(folder, out_append);
                    File.Copy(Path.Combine(folder, output), full_out_append, true);
                    output = out_append;
                    cleaner.Add(full_out_append);
                }
                else
                {
                    cleaner.Add(Path.Combine(folder, output));
                }
                if (!String.IsNullOrWhiteSpace(target))
                {
                    cleaner.Add(target);
                }

                string cmdline;
                if (isbatch)
                {
                    cmdline = $"create -b -i \"{input}\" -o \"{output}\"";
                }
                else
                {
                    cmdline = $"create -i \"{input}\" -t \"target.txt\" -o \"{output}\"";
                }
                if (append)
                {
                    cmdline += " -a";
                }

                var proc = FVTestUtil.RunProcess(cmdline, folder);
                Assert.AreEqual(0, proc.ExitCode);
                var exp_text = LoadOutput(Path.Combine(folder, expected));
                var got_text = LoadOutput(Path.Combine(folder, output));
                DictCompare(exp_text, got_text);
            }
        }
예제 #3
0
        public static void Initialize(TestContext ctx)
        {
            Directory.SetCurrentDirectory(GlobalData.DataDirFull);
            FVTestUtil.InitConsoleHookDefault();

            var create_cases = Directory.GetDirectories(@".\case\create", @"test_*");
            var verify_cases = Directory.GetDirectories(@".\case\verify", @"test_*");
            var calc_cases   = Directory.GetDirectories(@".\case\calc", @"test_*");

            _loadCreateCases(create_cases);
            _loadVerifyCases(verify_cases);
            _loadCalcCases(calc_cases);
        }
예제 #4
0
        public void TestCalc()
        {
            //using (var calc = MyCSVWriter._initCSV("DDT-calc.csv", "name", "verb", "input_file", "checksum", "verbose"))

            var folder   = Column(0);
            var verb     = Column(1); // unused, "calc"
            var input    = Column(2);
            var checksum = Column(3);
            var ftp      = Column(4);
            var verbose  = Boolean.Parse(Column(5));

            Process ftp_proc = null;

            if (!String.IsNullOrWhiteSpace(ftp))
            {
                ftp_proc = FVTestUtil.launchFTP(folder);
                input    = $"{ftp}{input}";
            }

            string cmdline = $"calc \"{input}\"";

            if (verbose)
            {
                cmdline += " --verbose";
            }

            var proc = FVTestUtil.RunProcess(cmdline, folder);

            if (ftp_proc != null)
            {
                ftp_proc.Kill();
                ftp_proc.WaitForExit();
            }

            Assert.AreEqual(0, proc.ExitCode, folder);
            string line = proc.StandardOutput.ReadLine();

            Assert.AreEqual(checksum, line, folder);
        }
예제 #5
0
 public static void Cleanup()
 {
     Debug.WriteLine("Cleaning up! :)");
     FVTestUtil.ShutdownConsoleHook();
 }