/// <summary>
    /// fluent setter for <see cref="ISupportSwitchExcludeFilenames"/>.
    /// </summary>
    /// <typeparam name="T">the builder to support the <see cref="ISupportSwitchExcludeFilenames"/>.</typeparam>
    /// <param name="this">The builder-instance.</param>
    /// <param name="type">The <see cref="RecurseType"/>.</param>
    /// <param name="fileNameWildcard">The filename-wildcard.</param>
    /// <param name="additional">Additional filename-wildcards.</param>
    /// <returns>The builder-instance for fluent re-use.</returns>
    public static T WithExcludeFilenames <T>(this T @this, RecurseType type, string fileNameWildcard, params string[] additional)
        where T : ISupportSwitchBuilder <ISupportSwitchExcludeFilenames>
    {
        var first = new SwitchExcludeFilename(fileNameWildcard, type);
        var rest  = additional.Select(x => new SwitchExcludeFilename(x, type));

        return(@this.WithExcludeFilenames(first, rest));
    }
Esempio n. 2
0
    public void Exclude_with_Recurse_Wildcards_outputs_r_zero()
    {
        var          fixture  = new SevenZipSettingsFixture();
        var          sut      = new SwitchExcludeFilename("*.txt", RecurseType.EnableOnlyForWildcardNames);
        const string expected = "-xr0!*.txt";

        var actual = fixture.Parse(b => sut.BuildArguments(ref b));

        actual.ShouldBe(expected);
    }
Esempio n. 3
0
    public void Exclude_without_Recurse_outputs_no_recurse()
    {
        var          fixture  = new SevenZipSettingsFixture();
        var          sut      = new SwitchExcludeFilename("*.txt");
        const string expected = "-x!*.txt";

        var actual = fixture.Parse(b => sut.BuildArguments(ref b));

        actual.ShouldBe(expected);
    }
Esempio n. 4
0
    public void Exclude_with_Recurse_disabled_outputs_r_minus()
    {
        var          fixture  = new SevenZipSettingsFixture();
        var          sut      = new SwitchExcludeFilename("*.txt", RecurseType.Disable);
        const string expected = "-xr-!*.txt";

        var actual = fixture.Parse(b => sut.BuildArguments(ref b));

        actual.ShouldBe(expected);
    }
    private static T WithExcludeFilenames <T>(
        this T @this,
        SwitchExcludeFilename first,
        IEnumerable <SwitchExcludeFilename> rest)
        where T : ISupportSwitchBuilder <ISupportSwitchExcludeFilenames>
    {
        if (@this.Command.ExcludeFilenames == null)
        {
            @this.Command.ExcludeFilenames = new SwitchExcludeFilenameCollection(first);
        }
        else
        {
            @this.Command.ExcludeFilenames.Add(first);
        }

        rest.ToList().ForEach(@this.Command.ExcludeFilenames.Add);

        return(@this);
    }