Beispiel #1
0
        public void ExitsWithErrorWithUnknownArgument()
        {
            // Execute with unknown parameter and collect output
            int    result = Z80Bench.Main(new string[] { "--unknown-arg", "unknownValue" });
            string output = _stdOut.ToString();

            // Expect -1 for an error
            Assert.AreEqual(-1, result);

            // Expect an errors section and for it to contain a message about the unknown parameter
            Assert.IsTrue(output.Contains("Errors:"));
            Assert.IsTrue(output.Contains("Option 'unknown-arg' is unknown."));
        }
Beispiel #2
0
        public void ExitsWithErrorWithoutArguments()
        {
            // Execute with no parameters and collect the output
            int           result;
            List <string> output;

            result = Z80Bench.Main(new string[] { });
            output = _stdOut.ToString()
                     .Split("\n")
                     .Select(x => x.Trim())
                     .ToList();

            // Expect -1 for an error
            Assert.AreEqual(result, -1);

            // Expect the first line to be usage info
            Assert.AreEqual(output[0], "Usage: z80bench <filename[@address]> [additional files] [options]");

            // Expect the various parameters to be in the usage info
            foreach (var line in _parameters)
            {
                Assert.IsTrue(output.Any(x => x.Contains(line)));
            }
        }