<commit_before>﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using FlubuCore.Tasks.Process;
using Microsoft.DotNet.Cli.Utils;
using Moq;
using Xunit;

namespace FlubuCore.Tests.Tasks
{
    [Collection(nameof(FlubuTestCollection))]
    public class RunProgramTaskTests : FlubuTestBase
    {
        private readonly FlubuTestFixture _fixture;
        private readonly Mock<ICommandFactory> _commandFactory = new Mock<ICommandFactory>();
        private readonly Mock<ICommand> _command = new Mock<ICommand>();

        public RunProgramTaskTests(FlubuTestFixture fixture)
            : base(fixture.LoggerFactory)
        {
            _fixture = fixture;
        }

        [Fact]
        public void QuickTest()
        {
           var a = TestTer<int>();
        }

        public T TestTer<T>()
        {
            int i = 5;
            T a;

            if (typeof(T) == typeof(int))
            {
                a = (T)(object)i;
                return a;
            }

            return default(T);
        }

        [Fact]
        public void ExecuteDotNetCommandWithFullPath()
        {
            var fileName = GetOsPlatform() == OSPlatform.Windows ? "C:\\Program Files\\dotnet\\dotnet.exe" : "/usr/bin/dotnet";
            string currentFolder = Directory.GetCurrentDirectory();
            var path = Path.GetFullPath(fileName);
            _commandFactory.Setup(i => i.Create(path, new List<string> { "--version" }, null, "Debug")).Returns(_command.Object);

            _command.Setup(i => i.CaptureStdErr()).Returns(_command.Object);
            _command.Setup(i => i.CaptureStdOut()).Returns(_command.Object);
            _command.Setup(i => i.WorkingDirectory(currentFolder)).Returns(_command.Object);
            _command.Setup(i => i.OnErrorLine(It.IsAny<Action<string>>())).Returns(_command.Object);
            _command.Setup(i => i.OnOutputLine(It.IsAny<Action<string>>())).Returns(_command.Object);
            _command.Setup(i => i.Execute()).Returns(new CommandResult(new ProcessStartInfo { Arguments = "aa" }, 0, string.Empty, string.Empty));

            RunProgramTask task = new RunProgramTask(_commandFactory.Object, fileName);

            int res = task
                .WithArguments("--version")
                .Execute(Context);<commit_msg>Remove temporary test<commit_after>﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using FlubuCore.Tasks.Process;
using Microsoft.DotNet.Cli.Utils;
using Moq;
using Xunit;

namespace FlubuCore.Tests.Tasks
{
    [Collection(nameof(FlubuTestCollection))]
    public class RunProgramTaskTests : FlubuTestBase
    {
        private readonly FlubuTestFixture _fixture;
        private readonly Mock<ICommandFactory> _commandFactory = new Mock<ICommandFactory>();
        private readonly Mock<ICommand> _command = new Mock<ICommand>();

        public RunProgramTaskTests(FlubuTestFixture fixture)
            : base(fixture.LoggerFactory)
        {
            _fixture = fixture;
        }

        [Fact]
        public void ExecuteDotNetCommandWithFullPath()
        {
            var fileName = GetOsPlatform() == OSPlatform.Windows ? "C:\\Program Files\\dotnet\\dotnet.exe" : "/usr/bin/dotnet";
            string currentFolder = Directory.GetCurrentDirectory();
            var path = Path.GetFullPath(fileName);
            _commandFactory.Setup(i => i.Create(path, new List<string> { "--version" }, null, "Debug")).Returns(_command.Object);

            _command.Setup(i => i.CaptureStdErr()).Returns(_command.Object);
            _command.Setup(i => i.CaptureStdOut()).Returns(_command.Object);
            _command.Setup(i => i.WorkingDirectory(currentFolder)).Returns(_command.Object);
            _command.Setup(i => i.OnErrorLine(It.IsAny<Action<string>>())).Returns(_command.Object);
            _command.Setup(i => i.OnOutputLine(It.IsAny<Action<string>>())).Returns(_command.Object);
            _command.Setup(i => i.Execute()).Returns(new CommandResult(new ProcessStartInfo { Arguments = "aa" }, 0, string.Empty, string.Empty));

            RunProgramTask task = new RunProgramTask(_commandFactory.Object, fileName);

            int res = task
                .WithArguments("--version")
                .Execute(Context);
{'fraction_non_alphanumeric': 0.12220465326406144, 'fraction_numerical': 0.0006776598147729839, 'mean_word_length': 2.7335581787521077, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 37, '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': '5440836', 'n_tokens_mistral': 1239, 'n_tokens_neox': 1223, 'n_words': 229}