コード例 #1
0
    /// <summary>
    /// Applies the specified context of the command line option to the specified command line options.
    /// </summary>
    /// <param name="options">The command line options to apply the command line option.</param>
    /// <param name="context">The context of the command line option to be applied.</param>
    public void Apply(CarnaRunnerCommandLineOptions options, CarnaRunnerCommandLineOptionContext context)
    {
        if (!CanApply(context))
        {
            return;
        }

        ApplyOption(options, context);
    }
コード例 #2
0
    /// <summary>
    /// Applies the specified context of the command line option to the specified command line options.
    /// </summary>
    /// <param name="options">The command line options to apply the command line option.</param>
    /// <param name="context">The context of the command line option to be applied.</param>
    /// <exception cref="InvalidCommandLineOptionException">
    /// Settings file defined by <paramref name="context"/> does not exist.
    /// </exception>
    protected override void ApplyOption(CarnaRunnerCommandLineOptions options, CarnaRunnerCommandLineOptionContext context)
    {
        if (!File.Exists(context.Value))
        {
            throw new InvalidCommandLineOptionException($@"Settings file does not exist.
File: {context.Value}");
        }

        options.SettingsFilePath = context.Value;
    }
コード例 #3
0
    /// <summary>
    /// Applies the specified context of the command line option to the specified command line options.
    /// </summary>
    /// <param name="options">The command line options to apply the command line option.</param>
    /// <param name="context">The context of the command line option to be applied.</param>
    /// <exception cref="InvalidCommandLineOptionException">
    /// Assembly file defined by <paramref name="context"/> does not exist.
    /// </exception>
    protected override void ApplyOption(CarnaRunnerCommandLineOptions options, CarnaRunnerCommandLineOptionContext context)
    {
        if (!File.Exists(context.Argument))
        {
            throw new InvalidCommandLineOptionException($@"Assembly file does not exist.
File: {context.Argument}");
        }

        options.Assemblies.Add(context.Argument);
    }
コード例 #4
0
    /// <summary>
    /// Parses the specified arguments of the command line.
    /// </summary>
    /// <param name="args">The arguments of the command line.</param>
    /// <returns>The new instance of the <see cref="CarnaRunnerCommandLineOptions"/>.</returns>
    /// <exception cref="InvalidCommandLineOptionException">
    /// The argument of the command line is not specified and
    /// a settings file does not exist.
    /// </exception>
    protected virtual CarnaRunnerCommandLineOptions Parse(string[] args)
    {
        if (args.Any())
        {
            return(ParseArguments(args));
        }

        var options = new CarnaRunnerCommandLineOptions();

        if (File.Exists(options.SettingsFilePath))
        {
            return(options);
        }

        throw new InvalidCommandLineOptionException(@"Specify an assembly or setting file.
The current working directory does not contain a settings file.");
    }
コード例 #5
0
 /// <summary>
 /// Applies the specified context of the command line option to the specified command line options.
 /// </summary>
 /// <param name="options">The command line options to apply the command line option.</param>
 /// <param name="context">The context of the command line option to be applied.</param>
 protected override void ApplyOption(CarnaRunnerCommandLineOptions options, CarnaRunnerCommandLineOptionContext context)
 {
     options.CanPause = true;
 }
コード例 #6
0
 public static bool Start(CarnaRunnerCommandLineOptions options)
 => new FixtureEngine()
 .AddOptions(options)
 .AddSummaryReporter()
 .Start();
コード例 #7
0
 public static FixtureEngine AddOptions(this FixtureEngine @this, CarnaRunnerCommandLineOptions options)
 {
     return(@this.LoadConfiguration(options.SettingsFilePath)
            .AddAssemblies(options.Assemblies)
            .AddDefaultFilter(options.Filter));
 }
コード例 #8
0
ファイル: FilterOption.cs プロジェクト: averrunci/Carna
 /// <summary>
 /// Applies the specified context of the command line option to the specified command line options.
 /// </summary>
 /// <param name="options">The command line options to apply the command line option.</param>
 /// <param name="context">The context of the command line option to be applied.</param>
 protected override void ApplyOption(CarnaRunnerCommandLineOptions options, CarnaRunnerCommandLineOptionContext context)
 {
     options.Filter = context.Value;
 }