Merged branch feature/msbuild into piotrpMSFT/branchmerge
This commit is contained in:
commit
3cdd15a145
93 changed files with 1421 additions and 472 deletions
|
@ -17,7 +17,7 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
|||
|
||||
var resolvers = defaultCommandResolver.OrderedCommandResolvers;
|
||||
|
||||
resolvers.Should().HaveCount(6);
|
||||
resolvers.Should().HaveCount(7);
|
||||
|
||||
resolvers.Select(r => r.GetType())
|
||||
.Should()
|
||||
|
@ -28,7 +28,8 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
|||
typeof(ProjectToolsCommandResolver),
|
||||
typeof(AppBaseDllCommandResolver),
|
||||
typeof(AppBaseCommandResolver),
|
||||
typeof(PathCommandResolver)
|
||||
typeof(PathCommandResolver),
|
||||
typeof(PublishedPathCommandResolver)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,6 +118,16 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
return _temporaryDirectory;
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetFiles(string path, string searchPattern)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public string GetDirectoryFullName(string path)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool Exists(string path)
|
||||
{
|
||||
return _files.Keys.Any(k => k.StartsWith(path));
|
||||
|
|
|
@ -97,6 +97,20 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
|
|||
result.Should().Pass();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void It_runs_tests_for_an_assembly_passed_as_param()
|
||||
{
|
||||
var publishCommand = new PublishCommand(_projectFilePath);
|
||||
var result = publishCommand.Execute();
|
||||
result.Should().Pass();
|
||||
|
||||
var assemblyUnderTestPath = Path.Combine(publishCommand.GetOutputDirectory(true).FullName, publishCommand.GetPortableOutputName());
|
||||
|
||||
var testCommand = new DotnetTestCommand();
|
||||
result = testCommand.Execute($"{assemblyUnderTestPath}");
|
||||
result.Should().Pass();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData("ArgumentNames")]
|
||||
public void It_fails_correctly_with_unspecified_arguments_with_long_form(string argument)
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
"Microsoft.DotNet.ProjectModel": {
|
||||
"target": "project"
|
||||
},
|
||||
"Microsoft.DotNet.InternalAbstractions": {
|
||||
"target": "project"
|
||||
},
|
||||
"System.Net.NameResolution": "4.0.0",
|
||||
"System.Net.Sockets": "4.1.0",
|
||||
"System.Runtime.Serialization.Primitives": "4.1.1",
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using FluentAssertions;
|
||||
using Microsoft.DotNet.Tools.Test;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.Dotnet.Tools.Test.Tests
|
||||
{
|
||||
public class GivenAParameterTestRunnerNameResolver
|
||||
{
|
||||
private const string SomeTestRunner = "Some test runner";
|
||||
|
||||
[Fact]
|
||||
public void It_returns_the_runner_based_on_the_parameter()
|
||||
{
|
||||
var parameterTestRunnerResolver = new ParameterTestRunnerNameResolver(SomeTestRunner);
|
||||
|
||||
var testRunner = parameterTestRunnerResolver.ResolveTestRunner();
|
||||
|
||||
testRunner.Should().Be($"dotnet-test-{SomeTestRunner}");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using FluentAssertions;
|
||||
using Microsoft.DotNet.ProjectModel;
|
||||
using Microsoft.DotNet.Tools.Test;
|
||||
using Microsoft.Extensions.Testing.Abstractions;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.Dotnet.Tools.Test.Tests
|
||||
{
|
||||
public class GivenAProjectJsonTestRunnerNameResolver
|
||||
{
|
||||
private const string SomeTestRunner = "runner";
|
||||
|
||||
[Fact]
|
||||
public void It_resolves_the_TestRunner_using_the_testRunner_property_in_the_projectJson()
|
||||
{
|
||||
var project = new Project
|
||||
{
|
||||
TestRunner = SomeTestRunner
|
||||
};
|
||||
|
||||
var projectJsonTestRunnerResolver = new ProjectJsonTestRunnerNameResolver(project);
|
||||
|
||||
var testRunner = projectJsonTestRunnerResolver.ResolveTestRunner();
|
||||
|
||||
testRunner.Should().Be($"dotnet-test-{SomeTestRunner}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void It_returns_null_when_there_is_no_testRunner_set_in_the_projectJson()
|
||||
{
|
||||
var project = new Project();
|
||||
|
||||
var projectJsonTestRunnerResolver = new ProjectJsonTestRunnerNameResolver(project);
|
||||
|
||||
var testRunner = projectJsonTestRunnerResolver.ResolveTestRunner();
|
||||
|
||||
testRunner.Should().BeNull();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,19 +21,21 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
|
|||
"NetCoreAppOnlyProject",
|
||||
"project.json");
|
||||
|
||||
private TestCommand _testCommand;
|
||||
private Mock<IDotnetTestRunnerFactory> _dotnetTestRunnerFactoryMock;
|
||||
private Mock<IDotnetTestRunner> _dotnetTestRunnerMock;
|
||||
private readonly TestCommand _testCommand;
|
||||
private readonly Mock<IDotnetTestRunnerFactory> _dotnetTestRunnerFactoryMock;
|
||||
private readonly Mock<IDotnetTestRunner> _dotnetTestRunnerMock;
|
||||
|
||||
public GivenATestCommand()
|
||||
{
|
||||
_dotnetTestRunnerMock = new Mock<IDotnetTestRunner>();
|
||||
_dotnetTestRunnerMock
|
||||
.Setup(d => d.RunTests(It.IsAny<ProjectContext>(), It.IsAny<DotnetTestParams>(), It.IsAny<BuildWorkspace>()))
|
||||
.Setup(d => d.RunTests(It.IsAny<DotnetTestParams>()))
|
||||
.Returns(0);
|
||||
|
||||
_dotnetTestRunnerFactoryMock = new Mock<IDotnetTestRunnerFactory>();
|
||||
_dotnetTestRunnerFactoryMock.Setup(d => d.Create(null)).Returns(_dotnetTestRunnerMock.Object);
|
||||
_dotnetTestRunnerFactoryMock
|
||||
.Setup(d => d.Create(It.IsAny<DotnetTestParams>()))
|
||||
.Returns(_dotnetTestRunnerMock.Object);
|
||||
|
||||
_testCommand = new TestCommand(_dotnetTestRunnerFactoryMock.Object);
|
||||
}
|
||||
|
@ -44,7 +46,8 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
|
|||
var result = _testCommand.DoRun(new[] {"--help"});
|
||||
|
||||
result.Should().Be(0);
|
||||
_dotnetTestRunnerFactoryMock.Verify(d => d.Create(It.IsAny<int?>()), Times.Never);
|
||||
_dotnetTestRunnerFactoryMock
|
||||
.Verify(d => d.Create(It.IsAny<DotnetTestParams>()), Times.Never);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -53,7 +56,8 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
|
|||
var result = _testCommand.DoRun(new[] { ProjectJsonPath, "-f", "netcoreapp1.0" });
|
||||
|
||||
result.Should().Be(0);
|
||||
_dotnetTestRunnerFactoryMock.Verify(d => d.Create(It.IsAny<int?>()), Times.Once);
|
||||
_dotnetTestRunnerFactoryMock
|
||||
.Verify(d => d.Create(It.IsAny<DotnetTestParams>()), Times.Once);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -62,7 +66,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
|
|||
var result = _testCommand.DoRun(new[] { ProjectJsonPath, "-f", "netcoreapp1.0" });
|
||||
|
||||
_dotnetTestRunnerMock.Verify(
|
||||
d => d.RunTests(It.IsAny<ProjectContext>(), It.IsAny<DotnetTestParams>(), It.IsAny<BuildWorkspace>()),
|
||||
d => d.RunTests(It.IsAny<DotnetTestParams>()),
|
||||
Times.Once);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
|
|||
private Mock<ICommand> _commandMock;
|
||||
private Mock<ICommandFactory> _commandFactoryMock;
|
||||
private Mock<ITestRunnerArgumentsBuilder> _argumentsBuilderMock;
|
||||
private string _runner = "runner";
|
||||
private string _runner = "dotnet-test-runner";
|
||||
private string[] _testRunnerArguments;
|
||||
|
||||
public GivenATestRunner()
|
||||
|
@ -38,7 +38,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
|
|||
|
||||
_commandFactoryMock = new Mock<ICommandFactory>();
|
||||
_commandFactoryMock.Setup(c => c.Create(
|
||||
$"dotnet-{_runner}",
|
||||
$"{_runner}",
|
||||
_testRunnerArguments,
|
||||
null,
|
||||
null)).Returns(_commandMock.Object).Verifiable();
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System.IO;
|
||||
using FluentAssertions;
|
||||
using Microsoft.DotNet.ProjectModel;
|
||||
using Microsoft.DotNet.Tools.Test;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.Dotnet.Tools.Test.Tests
|
||||
{
|
||||
public class GivenATestRunnerNameResolverFactoryAndADotnetTestParams
|
||||
{
|
||||
private const string PathToAFolder = "c:/some/path";
|
||||
private const string PathToAnAssembly = "c:/some/path/to/assembly.dll";
|
||||
private const string SomeTestRunner = "some test runner";
|
||||
|
||||
private readonly string _pathToAProjectJson = Path.Combine(PathToAFolder, "project.json");
|
||||
|
||||
[Fact]
|
||||
public void It_returns_a_ProjectJsonTestRunnerResolver_when_the_path_parameter_points_to_a_project_json()
|
||||
{
|
||||
var dotnetTestParams = new DotnetTestParams
|
||||
{
|
||||
ProjectOrAssemblyPath = _pathToAProjectJson
|
||||
};
|
||||
|
||||
var projectReaderMock = new Mock<IProjectReader>();
|
||||
projectReaderMock
|
||||
.Setup(p => p.ReadProject(dotnetTestParams.ProjectOrAssemblyPath, null))
|
||||
.Returns(new Project());
|
||||
|
||||
var dotnetTestRunnerResolverFactory = new DotnetTestRunnerResolverFactory(projectReaderMock.Object);
|
||||
|
||||
var testRunnerResolver = dotnetTestRunnerResolverFactory.Create(dotnetTestParams);
|
||||
|
||||
testRunnerResolver.Should().BeOfType<ProjectJsonTestRunnerNameResolver>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void It_returns_a_ProjectJsonTestRunnerResolver_when_the_path_parameter_points_to_a_folder()
|
||||
{
|
||||
var dotnetTestParams = new DotnetTestParams
|
||||
{
|
||||
ProjectOrAssemblyPath = PathToAFolder
|
||||
};
|
||||
|
||||
var projectReaderMock = new Mock<IProjectReader>();
|
||||
projectReaderMock
|
||||
.Setup(p => p.ReadProject(dotnetTestParams.ProjectOrAssemblyPath, null))
|
||||
.Returns(new Project());
|
||||
|
||||
var dotnetTestRunnerResolverFactory = new DotnetTestRunnerResolverFactory(projectReaderMock.Object);
|
||||
|
||||
var testRunnerResolver = dotnetTestRunnerResolverFactory.Create(dotnetTestParams);
|
||||
|
||||
testRunnerResolver.Should().BeOfType<ProjectJsonTestRunnerNameResolver>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void It_returns_a_ParameterTestRunnerResolver_when_an_assembly_and_a_test_runner_are_passed()
|
||||
{
|
||||
var dotnetTestParams = new DotnetTestParams
|
||||
{
|
||||
ProjectOrAssemblyPath = PathToAnAssembly,
|
||||
TestRunner = SomeTestRunner
|
||||
};
|
||||
|
||||
var projectReaderMock = new Mock<IProjectReader>();
|
||||
|
||||
var dotnetTestRunnerResolverFactory = new DotnetTestRunnerResolverFactory(projectReaderMock.Object);
|
||||
|
||||
var testRunnerResolver = dotnetTestRunnerResolverFactory.Create(dotnetTestParams);
|
||||
|
||||
testRunnerResolver.Should().BeOfType<ParameterTestRunnerNameResolver>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using FluentAssertions;
|
||||
using Microsoft.DotNet.Tools.Test;
|
||||
using Microsoft.Extensions.EnvironmentAbstractions;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.Dotnet.Tools.Test.Tests
|
||||
{
|
||||
public class GivenAnAssemblyTestRunnerNameResolver
|
||||
{
|
||||
private readonly string _directoryOfAssemblyUnderTest = Path.Combine("c:", "some", "path");
|
||||
|
||||
private const string TestRunnerName = "dotnet-test-someRunner";
|
||||
|
||||
private static readonly string TestRunnerFileName = $"{TestRunnerName}.dll";
|
||||
|
||||
[Fact]
|
||||
public void It_finds_the_runner_in_the_same_folder_as_the_assembly_when_the_path_passed_is_to_the_assembly()
|
||||
{
|
||||
var directoryMock = new DirectoryMock();
|
||||
|
||||
directoryMock.AddFile(_directoryOfAssemblyUnderTest, TestRunnerFileName);
|
||||
|
||||
var pathToAssemblyUnderTest = Path.Combine(_directoryOfAssemblyUnderTest, TestRunnerFileName);
|
||||
var assemblyTestRunnerResolver =
|
||||
new AssemblyTestRunnerNameResolver(pathToAssemblyUnderTest, directoryMock);
|
||||
|
||||
var testRunner = assemblyTestRunnerResolver.ResolveTestRunner();
|
||||
|
||||
testRunner.Should().Be(TestRunnerName);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void It_returns_a_test_runner_even_when_multiple_test_runners_are_present()
|
||||
{
|
||||
var directoryMock = new DirectoryMock();
|
||||
|
||||
directoryMock.AddFile(_directoryOfAssemblyUnderTest, TestRunnerFileName);
|
||||
directoryMock.AddFile(_directoryOfAssemblyUnderTest, "dotnet-test-someOtherTestRunner.dll");
|
||||
directoryMock.AddFile(_directoryOfAssemblyUnderTest, "dotnet-test-AndYetAnotherTestRunner.dll");
|
||||
|
||||
var assemblyTestRunnerResolver =
|
||||
new AssemblyTestRunnerNameResolver(_directoryOfAssemblyUnderTest, directoryMock);
|
||||
|
||||
var bestEffortTestRunner = assemblyTestRunnerResolver.ResolveTestRunner();
|
||||
|
||||
bestEffortTestRunner.Should().NotBeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void It_returns_null_when_no_test_runner_is_found()
|
||||
{
|
||||
var directoryMock = new DirectoryMock();
|
||||
|
||||
var assemblyTestRunnerResolver =
|
||||
new AssemblyTestRunnerNameResolver(_directoryOfAssemblyUnderTest, directoryMock);
|
||||
|
||||
var testRunner = assemblyTestRunnerResolver.ResolveTestRunner();
|
||||
|
||||
testRunner.Should().BeNull();
|
||||
}
|
||||
|
||||
private class DirectoryMock : IDirectory
|
||||
{
|
||||
private readonly IList<string> _files = new List<string>();
|
||||
|
||||
public bool Exists(string path)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public ITemporaryDirectory CreateTemporaryDirectory()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetFiles(string path, string searchPattern)
|
||||
{
|
||||
var searchPatternRegex = new Regex(searchPattern);
|
||||
return _files.Where(f => f.StartsWith(path) && searchPatternRegex.IsMatch(f));
|
||||
}
|
||||
|
||||
public string GetDirectoryFullName(string path)
|
||||
{
|
||||
return Path.GetDirectoryName(path);
|
||||
}
|
||||
|
||||
public void AddFile(string path, string fileName)
|
||||
{
|
||||
_files.Add(Path.Combine(path, fileName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,16 +19,20 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
|
|||
private const string Runtime = "some runtime";
|
||||
private const int ParentProcessId = 1010;
|
||||
private const int Port = 2314;
|
||||
private const string TestRunner = "someTestRunner";
|
||||
private const string PathToAssemblyUnderTest = "c:/some/path/assemblyUnderTest.dll";
|
||||
|
||||
private DotnetTestParams _dotnetTestFullParams;
|
||||
private DotnetTestParams _emptyDotnetTestParams;
|
||||
private readonly DotnetTestParams _dotnetTestFullParamsWithProjectJson;
|
||||
private readonly DotnetTestParams _emptyDotnetTestParams;
|
||||
private readonly DotnetTestParams _dotnetTestParamsWithAssembly;
|
||||
|
||||
public GivenThatWeWantToParseArgumentsForDotnetTest()
|
||||
{
|
||||
_dotnetTestFullParams = new DotnetTestParams();
|
||||
_dotnetTestFullParamsWithProjectJson = new DotnetTestParams();
|
||||
_dotnetTestParamsWithAssembly = new DotnetTestParams();
|
||||
_emptyDotnetTestParams = new DotnetTestParams();
|
||||
|
||||
_dotnetTestFullParams.Parse(new[]
|
||||
_dotnetTestFullParamsWithProjectJson.Parse(new[]
|
||||
{
|
||||
ProjectJson,
|
||||
"--parentProcessId", ParentProcessId.ToString(),
|
||||
|
@ -42,19 +46,25 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
|
|||
"--additional-parameters", "additional-parameter-value"
|
||||
});
|
||||
|
||||
_dotnetTestParamsWithAssembly.Parse(new[]
|
||||
{
|
||||
PathToAssemblyUnderTest,
|
||||
"--test-runner", TestRunner
|
||||
});
|
||||
|
||||
_emptyDotnetTestParams.Parse(new string[] { });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void It_sets_the_project_path_current_folder_if_one_is_not_passed_in()
|
||||
{
|
||||
_emptyDotnetTestParams.ProjectPath.Should().Be(Directory.GetCurrentDirectory());
|
||||
_emptyDotnetTestParams.ProjectOrAssemblyPath.Should().Be(Directory.GetCurrentDirectory());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void It_sets_the_project_path_to_the_passed_value()
|
||||
{
|
||||
_dotnetTestFullParams.ProjectPath.Should().Be(ProjectJson);
|
||||
_dotnetTestFullParamsWithProjectJson.ProjectOrAssemblyPath.Should().Be(ProjectJson);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -72,7 +82,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
|
|||
[Fact]
|
||||
public void It_converts_the_parent_process_id_to_int_when_a_valid_one_is_passed()
|
||||
{
|
||||
_dotnetTestFullParams.ParentProcessId.Should().Be(ParentProcessId);
|
||||
_dotnetTestFullParamsWithProjectJson.ParentProcessId.Should().Be(ParentProcessId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -96,7 +106,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
|
|||
[Fact]
|
||||
public void It_converts_the_port_to_int_when_a_valid_one_is_passed()
|
||||
{
|
||||
_dotnetTestFullParams.Port.Should().Be(Port);
|
||||
_dotnetTestFullParamsWithProjectJson.Port.Should().Be(Port);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -108,7 +118,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
|
|||
[Fact]
|
||||
public void It_converts_the_framework_to_NugetFramework()
|
||||
{
|
||||
_dotnetTestFullParams.Framework.DotNetFrameworkName.Should().Be(".NETCoreApp,Version=v1.0");
|
||||
_dotnetTestFullParamsWithProjectJson.Framework.DotNetFrameworkName.Should().Be(".NETCoreApp,Version=v1.0");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -129,7 +139,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
|
|||
[Fact]
|
||||
public void It_sets_Output_when_one_is_passed_in()
|
||||
{
|
||||
_dotnetTestFullParams.Output.Should().Be(Output);
|
||||
_dotnetTestFullParamsWithProjectJson.Output.Should().Be(Output);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -141,7 +151,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
|
|||
[Fact]
|
||||
public void It_sets_BuildBasePath_when_one_is_passed_in()
|
||||
{
|
||||
_dotnetTestFullParams.BuildBasePath.Should().Be(Path.GetFullPath(BuildBasePath));
|
||||
_dotnetTestFullParamsWithProjectJson.BuildBasePath.Should().Be(Path.GetFullPath(BuildBasePath));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -153,7 +163,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
|
|||
[Fact]
|
||||
public void It_sets_Config_to_passed_in_value()
|
||||
{
|
||||
_dotnetTestFullParams.Config.Should().Be(Config);
|
||||
_dotnetTestFullParamsWithProjectJson.Config.Should().Be(Config);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -165,7 +175,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
|
|||
[Fact]
|
||||
public void It_sets_Runtime_when_one_is_passed_in()
|
||||
{
|
||||
_dotnetTestFullParams.Runtime.Should().Be(Runtime);
|
||||
_dotnetTestFullParamsWithProjectJson.Runtime.Should().Be(Runtime);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -177,14 +187,14 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
|
|||
[Fact]
|
||||
public void It_sets_any_remaining_params_to_RemainingArguments()
|
||||
{
|
||||
_dotnetTestFullParams.RemainingArguments.ShouldBeEquivalentTo(
|
||||
_dotnetTestFullParamsWithProjectJson.RemainingArguments.ShouldBeEquivalentTo(
|
||||
new [] { "--additional-parameters", "additional-parameter-value" });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void It_sets_no_build_to_true_when_it_is_passed()
|
||||
{
|
||||
_dotnetTestFullParams.NoBuild.Should().BeTrue();
|
||||
_dotnetTestFullParamsWithProjectJson.NoBuild.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -196,7 +206,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
|
|||
[Fact]
|
||||
public void It_sets_Help_to_false_when_help_is_not_passed_in()
|
||||
{
|
||||
_dotnetTestFullParams.Help.Should().BeFalse();
|
||||
_dotnetTestFullParamsWithProjectJson.Help.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -207,5 +217,65 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
|
|||
|
||||
dotnetTestParams.Help.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void It_has_the_testRunner_null_by_default()
|
||||
{
|
||||
_emptyDotnetTestParams.TestRunner.Should().BeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void It_throws_when_you_specify_a_testRunner_along_with_a_folder()
|
||||
{
|
||||
var dotnetTestParams = new DotnetTestParams();
|
||||
Action action = () => dotnetTestParams.Parse(new[]
|
||||
{
|
||||
"c:/some/path",
|
||||
"--test-runner", "someTestRunner"
|
||||
});
|
||||
|
||||
action
|
||||
.ShouldThrow<InvalidOperationException>()
|
||||
.WithMessage("You can only specify a test runner with a dll.");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void It_throws_when_you_specify_a_testRunner_along_with_a_project_json()
|
||||
{
|
||||
var dotnetTestParams = new DotnetTestParams();
|
||||
Action action = () => dotnetTestParams.Parse(new[]
|
||||
{
|
||||
ProjectJson,
|
||||
"--test-runner", "someTestRunner"
|
||||
});
|
||||
|
||||
action
|
||||
.ShouldThrow<InvalidOperationException>()
|
||||
.WithMessage("You can only specify a test runner with a dll.");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void It_succeeds_when_specifying_an_assembly()
|
||||
{
|
||||
_dotnetTestParamsWithAssembly.ProjectOrAssemblyPath.Should().Be(PathToAssemblyUnderTest);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void It_succeeds_when_specifying_a_test_runner_along_with_an_assembly()
|
||||
{
|
||||
_dotnetTestParamsWithAssembly.TestRunner.Should().Be(TestRunner);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void When_a_testRunner_is_successfully_specified_then_HasTestRunner_returns_true()
|
||||
{
|
||||
_dotnetTestParamsWithAssembly.HasTestRunner.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void When_a_testRunner_is_noy_specified_then_HasTestRunner_returns_false()
|
||||
{
|
||||
_dotnetTestFullParamsWithProjectJson.HasTestRunner.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,10 @@
|
|||
"version": "1.0.0"
|
||||
},
|
||||
"Newtonsoft.Json": "9.0.1",
|
||||
"dotnet": {
|
||||
"Microsoft.DotNet.Tools.Test": {
|
||||
"target": "project"
|
||||
},
|
||||
"Microsoft.DotNet.InternalAbstractions": {
|
||||
"target": "project"
|
||||
},
|
||||
"Microsoft.Win32.Registry": {
|
||||
|
@ -34,6 +37,7 @@
|
|||
]
|
||||
},
|
||||
"buildOptions": {
|
||||
"keyFile": "../../tools/test_key.snk",
|
||||
"copyToOutput": {
|
||||
"include": [
|
||||
"../../TestAssets/TestProjects/ProjectsWithTests/NetCoreAppOnlyProject/project.json"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue