Esempio n. 1
0
 private static void SetBasicChecks(CheckOptions opts)
 {
     opts.CheckSchema       = true;
     opts.CheckUniqueGuid   = true;
     opts.CheckImageSize    = true;
     opts.CheckFileContents = true;
 }
Esempio n. 2
0
        static public int Main(string[] args)
        {
            var t = Parser.Default.ParseArguments <CheckOptions, ErrorCodeOptions>(args)
                    .MapResult(
                (CheckOptions opts) => CheckOptions.Run(opts),
                (ErrorCodeOptions opts) => ErrorCodeOptions.Run(opts),
                errs => Status.CommandLineError);

            return((int)t);
        }
Esempio n. 3
0
        internal static Status Run(CheckOptions opts)
        {
            Console.WriteLine("=== bcf-tool - checking BCF files.");

            if (opts.WriteMismatch)
            {
                opts.CheckZipMatch = true;
            }

            if (opts.ReZip)
            {
                opts.CheckZipMatch = true;
            }

            if (opts.QualityAssurance)
            {
                // enables default tests and then the ones specific for QA of bcf-xml
                SetBasicChecks(opts);
                opts.CheckZipMatch         = true;
                opts.CheckNewLines         = true;
                opts.CheckSchemaDefinition = true;
            }

            // if no check is required than check default
            if (
                !opts.CheckSchema &&
                !opts.CheckUniqueGuid &&
                !opts.CheckZipMatch &&
                !opts.CheckNewLines &&
                !opts.CheckImageSize &&
                !opts.CheckFileContents &&
                !opts.CheckSchemaDefinition
                )
            {
                SetBasicChecks(opts);
                Console.WriteLine("Performing default checks.");
            }
            else
            {
                List <string> checks = new List <string>();
                if (opts.CheckSchema)
                {
                    checks.Add("Schema");
                }
                if (opts.CheckUniqueGuid)
                {
                    checks.Add("UniqueGuid");
                }
                if (opts.CheckZipMatch)
                {
                    checks.Add("ZipMatch");
                }
                if (opts.CheckNewLines)
                {
                    checks.Add("Readable Xml");
                }
                if (opts.CheckImageSize)
                {
                    checks.Add("ImageSize");
                }
                if (opts.CheckFileContents)
                {
                    checks.Add("File contents");
                }
                if (opts.CheckSchemaDefinition)
                {
                    checks.Add("Xsd schemas correctness");
                }
                Console.WriteLine($"Checking: {string.Join(", ", checks.ToArray())}.");
            }
            if (!string.IsNullOrWhiteSpace(opts.UseRepoSchemaVersion))
            {
                if (!opts.UseRepoSchemaVersion.StartsWith("v"))
                {
                    Console.WriteLine($"Invalid parameter 'repoSchema': '{opts.UseRepoSchemaVersion}'. It should be 'v[Major].[Minor]', e.g. 'v3.0'");
                    return(Status.CommandLineError);
                }
                Console.WriteLine($"Attempting to use local schema files for test cases of version '{opts.UseRepoSchemaVersion}'.");
            }

            if (Directory.Exists(opts.InputSource))
            {
                Console.WriteLine("");
                var t = new DirectoryInfo(opts.InputSource);
                opts.ResolvedSource = t;
                var ret = ProcessExamplesFolder(t, new CheckInfo(opts));
                Console.WriteLine($"\r\nCompleted with status: {ret}.");
                return(ret);
            }
            if (File.Exists(opts.InputSource))
            {
                Console.WriteLine("");
                var t = new FileInfo(opts.InputSource);
                opts.ResolvedSource = t;
                var ret = ProcessSingleFile(t, new CheckInfo(opts));
                Console.WriteLine($"\r\nCompleted with status: {ret}.");
                return(ret);
            }
            Console.WriteLine($"Error: Invalid input source '{opts.InputSource}'");
            return(Status.NotFoundError);
        }
Esempio n. 4
0
 public CheckInfo(CheckOptions opts)
 {
     Options = opts;
 }