private static int Main(string[] args) { // Parse command line arguments var commandLineArgumentParser = new CommandLineArgumentParser(); var options = new Options(); var areCommandLineArgumentsValid = commandLineArgumentParser.Parse(args, options); var areOptionsValid = AreOptionsValid(options); // Proceed with application if options are valid if (areCommandLineArgumentsValid && areOptionsValid) { // Output run options options.PrintOptions(); try { // Initialize TestRail controller var testRailApiController = new TestRailApiController( options.TestRailUrl, options.TestRailUserEmail, options.TestRailPassword, options.TestRailProjectId); // Test the TestRail API connection testRailApiController.TestConnection(); // Initialize TestSync controller var nunitController = new NunitFileController(); var testSyncController = new TestSyncController(nunitController, testRailApiController, RootSectionName); // Ensure Root section exists for TestRail project testSyncController.InitializeRootSectionInTestRail(); // Sync Test Cases if (options.ShouldSyncTestCases) { testSyncController.SyncTestCases(options.NunitTestCasesFile); } // Sync Test Results if (options.ShouldSyncTestResults) { testSyncController.SyncTestResults(options.NunitTestResultsFile, options.TestRailRunName); } Console.WriteLine(); Console.WriteLine("TestRail-NUnit-Sync completed successfully."); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine(); Console.WriteLine("TestRail-NUnit-Sync completed unsuccessfully."); return(1); } } return(0); }