<commit_before>﻿using System.Collections.Generic;
using System.IO;
using System.Reflection;
using NUnit.Framework;

namespace Bounce.Framework.Tests.Features {
    [TestFixture]
    public class RemoteBounceFeature {
        [SetUp]
        public void SetUp() {
            Output = new StringWriter();
        }

        [Test]
        public void ShouldGenerateCommandLineForRemoteBounceWithParametersUsedInRemoteTarget() {
            MethodInfo method = typeof (TargetsProvider).GetMethod("GetTargets");
            new BounceRunner().Run(new[] {"build", "One", "/hack:refactor", "/two:three", "/machine:live"}, method);

            string rexecCommands = "rexec -h live bounce.exe /describe-tasks:false /loglevel:warning /command-output:false build RemoteOne /hack:refactor\r\n";

            Assert.That(Output.ToString(), Is.EqualTo(rexecCommands));
        }

        [Test]
        public void ShouldIncludeRemoteTargetsSoTheyCanBeInvokedRemotely() {
            MethodInfo method = typeof (TargetsProvider).GetMethod("GetTargets");
            new BounceRunner().Run(new[] {"build", "RemoteOne", "/hack:refactor"}, method);

            Assert.That(Output.ToString(), Is.EqualTo("refactor\r\n"));
        }

        [Test]
        public void ShouldExecuteMultipleRemoteTasksEachWithDifferentParameters() {
            MethodInfo method = typeof(MultipleRemoteTargetsProvider).GetMethod("GetTargets");
            new BounceRunner().Run(new[] {"build", "One"}, method);

            string rexecCommands =
@"rexec -h machine1 bounce.exe /describe-tasks:false /loglevel:warning /command-output:false build RemoteOne /machineName:machine1
rexec -h machine2 bounce.exe /describe-tasks:false /loglevel:warning /command-output:false build RemoteOne /machineName:machine2
";

            Assert.That(Output.ToString(), Is.EqualTo(rexecCommands));
        }

        private static TextWriter Output;

        class TargetsProvider {
            [Targets]
            public static object GetTargets(IParameters parameters) {
                var remoteOne = new PrintTask(Output) {Description = parameters.Required<string>("hack")};
                var two = new PrintTask(Output) {Description = parameters.Required<string>("two")};
<commit_msg>another test, can never get enough<commit_after>﻿using System.Collections.Generic;
using System.IO;
using System.Reflection;
using NUnit.Framework;

namespace Bounce.Framework.Tests.Features {
    [TestFixture]
    public class RemoteBounceFeature {
        [SetUp]
        public void SetUp() {
            Output = new StringWriter();
        }

        [Test]
        public void ShouldGenerateCommandLineForRemoteBounceWithParametersUsedInRemoteTarget() {
            MethodInfo method = typeof (TargetsProvider).GetMethod("GetTargets");
            new BounceRunner().Run(new[] {"build", "One", "/hack:refactor", "/two:three", "/machine:live"}, method);

            string rexecCommands = "rexec -h live bounce.exe /describe-tasks:false /loglevel:warning /command-output:false build RemoteOne /hack:refactor\r\n";

            Assert.That(Output.ToString(), Is.EqualTo(rexecCommands));
        }

        [Test]
        public void ShouldIncludeRemoteTargetsSoTheyCanBeInvokedRemotely() {
            MethodInfo method = typeof (TargetsProvider).GetMethod("GetTargets");
            new BounceRunner().Run(new[] {"build", "RemoteOne", "/hack:refactor"}, method);

            Assert.That(Output.ToString(), Is.EqualTo("refactor\r\n"));
        }

        [Test]
        public void ShouldExecuteMultipleRemoteTasksEachWithDifferentParameters() {
            MethodInfo method = typeof(MultipleRemoteTargetsProvider).GetMethod("GetTargets");
            new BounceRunner().Run(new[] {"build", "One"}, method);

            string rexecCommands =
@"rexec -h machine1 bounce.exe /describe-tasks:false /loglevel:warning /command-output:false build RemoteOne /machineName:machine1
rexec -h machine2 bounce.exe /describe-tasks:false /loglevel:warning /command-output:false build RemoteOne /machineName:machine2
";

            Assert.That(Output.ToString(), Is.EqualTo(rexecCommands));
        }

        [Test]
        public void ShouldInvokeRemoteTargetWithArguments() {
            MethodInfo method = typeof(MultipleRemoteTargetsProvider).GetMethod("GetTargets");
            new BounceRunner().Run(new[] {"build", "RemoteOne", "/machineName:machine1"}, method);

            string rexecCommands = "machine1\r\n";

            Assert.That(Output.ToString(), Is.EqualTo(rexecCommands));
        }

        private static TextWriter Output;

        class TargetsProvider {
            [Targets]
            public static object GetTargets(IParameters parameters) {
                var remoteOne = new PrintTask(Output) {Description = parameters.Required<string>("hack")};
                var two = new PrintTask(Output) {Description = parameters.Required<string>("two")};

{'fraction_non_alphanumeric': 0.11731276638928353, 'fraction_numerical': 0.0020296326364927946, 'mean_word_length': 3.151642796967144, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5007819', 'n_tokens_mistral': 1330, 'n_tokens_neox': 1291, 'n_words': 277}