public static void VerifyAndSetDefaultsIfNeeded(DokimiConfig config) { if (config.Print == null) config.Print = new PrintInfo { Format = DEFAULT_PRINT_FORMAT, Level = DEFAULT_PRINT_LEVEL }; VerifyAndCreateSourceDestination(config); VerifyAndCreatePrintDestination(config); VerifyAndCreateFormattersDestination(config); }
private static void VerifyAndCreatePrintDestination(DokimiConfig config) { if (String.IsNullOrEmpty(config.Print.Destination)) { config.Print.Destination = Path.Combine(GetAppCurrentDirectory(), DEFAULT_PRINT_DEST_PATH); if (!Directory.Exists(config.Print.Destination)) Directory.CreateDirectory(config.Print.Destination); } }
private static bool ParseCommandParams(IEnumerable<string> args, DokimiConfig config, out OptionSet parser) { var success = true; parser = new OptionSet { {"sp=|sourcePath=", "Source path for the test libraries. Default is /src.", value => config.Source.IncludePath = value}, { "pl=|printLevel=", "Print level (Minimal|Verbose). Default is Minimal.", pl => { PrintLevelInfo printLevel; if (Enum.TryParse(pl, true, out printLevel)) config.Print.Level = printLevel; } }, { "pf=|printFormat=", "Print format (Console|Word). Default is Console.", pf => { PrintFormatInfo printFormat; if (Enum.TryParse(pf, true, out printFormat)) config.Print.Format = printFormat; } }, {"pd=|printDestination", @"Print destination file path in (Word). Default is \out.", pd => config.Print.Destination = pd }, { "fp=|formattersPath=", @"Source path for the test message formatters. (if not provided, config is used. If not present in config, \formatters is used.", path => config.Formatters.IncludePath = path }, { "a=|action=", "Action (Describe|Execute). Default is Describe.", pf => { ActionInfo actionInfo; if (Enum.TryParse(pf, true, out actionInfo)) config.Action = actionInfo; } }, {"h|?|help", v => success = v == null}, }; try { parser.Parse(args); } catch (OptionException optionException) { Console.Write("dokimi: "); Console.WriteLine(optionException.Message); Console.WriteLine("Try `dokimi --help' for more information."); success = false; } return success; }
private static void VerifyAndCreateSourceDestination(DokimiConfig config) { if (config.Source == null) config.Source = new SourceInfo(); if (String.IsNullOrEmpty(config.Source.IncludePath)) { config.Source.IncludePath = Path.Combine(GetAppCurrentDirectory(), DEFAULT_SRC_PATH); if (!Directory.Exists(config.Source.IncludePath)) Directory.CreateDirectory(config.Source.IncludePath); } }
private static void VerifyAndCreateFormattersDestination(DokimiConfig config) { if (config.Formatters == null) { config.Formatters = new FormattersInfo() { Formatters = new FormatterInfo[0] }; } if (String.IsNullOrEmpty(config.Formatters.IncludePath)) { config.Formatters.IncludePath = Path.Combine(GetAppCurrentDirectory(), DEFAULT_FORMATTERS_PATH); if (!Directory.Exists(config.Formatters.IncludePath)) Directory.CreateDirectory(config.Formatters.IncludePath); } }
public void DescribeAssembly(DokimiConfig config) { var files = RunnerHelper.GetFileList(config.Source.IncludePath); foreach (var file in files) { var appDomain = AppDomain.CreateDomain(file, AppDomain.CurrentDomain.Evidence); var runner = (AppDomainRunner)appDomain.CreateInstanceAndUnwrap(Assembly.GetExecutingAssembly().FullName, (typeof (AppDomainRunner)).FullName); var command = new RunSpecCommand(file, config.Formatters.IncludePath, config.Formatters.Formatters, config.Print, config.Action); runner.DescribeSpec(command); } }