Fixing broken tests after my changes to the CommandResolvers.
This commit is contained in:
parent
55c00a7e45
commit
e8f2dabcdb
8 changed files with 48 additions and 11 deletions
|
@ -23,5 +23,24 @@ namespace Microsoft.Extensions.EnvironmentAbstractions
|
|||
{
|
||||
return Directory.GetFiles(path, searchPattern);
|
||||
}
|
||||
|
||||
public string GetDirectoryFullName(string path)
|
||||
{
|
||||
var directoryFullName = string.Empty;
|
||||
if (Exists(path))
|
||||
{
|
||||
directoryFullName = new DirectoryInfo(path).FullName;
|
||||
}
|
||||
else
|
||||
{
|
||||
var fileInfo = new FileInfo(path);
|
||||
if (fileInfo.Directory != null)
|
||||
{
|
||||
directoryFullName = fileInfo.Directory.FullName;
|
||||
}
|
||||
}
|
||||
|
||||
return directoryFullName;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -12,5 +12,7 @@ namespace Microsoft.Extensions.EnvironmentAbstractions
|
|||
ITemporaryDirectory CreateTemporaryDirectory();
|
||||
|
||||
IEnumerable<string> GetFiles(string path, string searchPattern);
|
||||
|
||||
string GetDirectoryFullName(string path);
|
||||
}
|
||||
}
|
|
@ -58,6 +58,7 @@ namespace Microsoft.DotNet.Tools.Test
|
|||
}
|
||||
catch (Exception ex) when (!(ex is GracefulException))
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
TestHostTracing.Source.TraceEvent(TraceEventType.Error, 0, ex.ToString());
|
||||
return -2;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace Microsoft.DotNet.Tools.Test
|
|||
|
||||
internal AssemblyTestRunnerResolver(string assemblyUnderTest, IDirectory directory)
|
||||
{
|
||||
_directoryOfAssemblyUnderTest = new FileInfo(assemblyUnderTest).Directory.FullName;
|
||||
_directoryOfAssemblyUnderTest = directory.GetDirectoryFullName(assemblyUnderTest);
|
||||
_directory = directory;
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,6 +123,11 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public string GetDirectoryFullName(string path)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool Exists(string path)
|
||||
{
|
||||
return _files.Keys.Any(k => k.StartsWith(path));
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,6 +84,11 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
|
|||
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}/{fileName}");
|
||||
|
|
Loading…
Reference in a new issue