private static int Main(string[] args) { int exitcode = 0; // parse the option arguments Parser.Default.ParseArguments <Options>(args) .WithParsed(opt => { if (opt.Final) { MakeFinalRequest(opt.CommitUUID, opt.Token); } else if (string.IsNullOrEmpty(opt.ReportFile)) { throw new FormatException( "Unspecified report file! Use -r or type --help"); } else if (string.IsNullOrEmpty(opt.ReportType)) { throw new FormatException( "Unspecified report type! Use -e or type --help"); } else { CodacyReport report; switch (opt.ReportType) { case "dotcover": var dotCoverProcessor = new DotCoverProcessor(); var dotCoverParsed = dotCoverProcessor.Parse(opt.ReportFile); report = dotCoverProcessor.Transform(dotCoverParsed); break; case "opencover": var openCoverProcessor = new OpenCoverProcessor(); var openCoverParsed = openCoverProcessor.Parse(opt.ReportFile); report = openCoverProcessor.Transform(openCoverParsed); break; default: throw new FormatException( "Unrecognized report format, please choose dotcover or opencover"); } SendReport(report, opt.CommitUUID, opt.Token, opt.Partial); } }) .WithNotParsed(errs => exitcode = 1); return(exitcode); }
public void BadParseTest() { Assert.ThrowsAny <Exception>(() => processor.Parse(@"Resources/Bad.xml")); }