public void Execute_OutputsTable_PlatformAndVersionNotDetected() { // Arrange var sourceDir = Path.Combine(_testDirPath, "appdir"); Directory.CreateDirectory(sourceDir); var detectCommand = new DetectCommand { SourceDir = sourceDir, }; var testConsole = new TestConsole(); // Act var exitCode = detectCommand.Execute(GetServiceProvider(detectCommand), testConsole); // Assert Assert.Equal(ProcessConstants.ExitSuccess, exitCode); Assert.Contains( $"Platform : Not Detected", testConsole.StdOutput); Assert.Contains( $"PlatformVersion: Not Detected", testConsole.StdOutput); }
public void Execute_OutputsTable_MultiplatformNamesAndVersions() { // Arrange var sourceDir = Path.Combine(_testDirPath, "multiappdir"); Directory.CreateDirectory(sourceDir); File.WriteAllText(Path.Combine(sourceDir, NodeConstants.PackageJsonFileName), "\n"); File.WriteAllText(Path.Combine(sourceDir, PhpConstants.ComposerFileName), "{\"require\":{\"php\":\"5.6.0\"}}"); var detectCommand = new DetectCommand { SourceDir = sourceDir, }; var testConsole = new TestConsole(); // Act var exitCode = detectCommand.Execute(GetServiceProvider(detectCommand), testConsole); // Assert Assert.Equal(ProcessConstants.ExitSuccess, exitCode); Assert.Contains( $"{NodeConstants.PlatformName}", testConsole.StdOutput); Assert.Contains( $"Not Detected", testConsole.StdOutput); Assert.Contains( $"{PhpConstants.PlatformName}", testConsole.StdOutput); Assert.Contains( $"5.6.0", testConsole.StdOutput); }
public void Execute_OutputsJson_MultiplatformNames_WithVersionsNotDetected() { // Arrange var sourceDir = Path.Combine(_testDirPath, "multiappdir"); Directory.CreateDirectory(sourceDir); File.WriteAllText(Path.Combine(sourceDir, NodeConstants.PackageJsonFileName), "\n"); File.WriteAllText(Path.Combine(sourceDir, PhpConstants.ComposerFileName), "\n"); var detectCommand = new DetectCommand { SourceDir = sourceDir, OutputFormat = "json", }; var testConsole = new TestConsole(); // Act var exitCode = detectCommand.Execute(GetServiceProvider(detectCommand), testConsole); // Assert Assert.Equal(ProcessConstants.ExitSuccess, exitCode); Assert.Contains( $"\"Platform\": \"{PhpConstants.PlatformName}\"", testConsole.StdOutput); Assert.Contains( $"\"Platform\": \"{NodeConstants.PlatformName}\"", testConsole.StdOutput); Assert.Contains( "\"PlatformVersion\": \"\"", testConsole.StdOutput); }
public void Execute_OutputsTable_PhpPlatformAndVersion_WhenComposerFileExplicitsVersion() { // Arrange var srcDir = Path.Combine(_testDirPath, "phpappdir"); Directory.CreateDirectory(srcDir); File.WriteAllText(Path.Combine(srcDir, PhpConstants.ComposerFileName), "{\"require\":{\"php\":\"5.6.0\"}}"); var cmd = new DetectCommand { SourceDir = srcDir, }; var testConsole = new TestConsole(); // Act int exitCode = cmd.Execute(GetServiceProvider(cmd), testConsole); // Assert Assert.Equal(ProcessConstants.ExitSuccess, exitCode); Assert.Contains( $"{PhpConstants.PlatformName}", testConsole.StdOutput); Assert.Contains( $"5.6.0", testConsole.StdOutput); }
public void Execute_OutputsTable_NodePlatform_WithVersionNotDetected_WhenJsonFileIsEmpty() { // Arrange var sourceDir = Path.Combine(_testDirPath, "nodeappdir"); Directory.CreateDirectory(sourceDir); File.WriteAllText(Path.Combine(sourceDir, NodeConstants.PackageJsonFileName), "\n"); var detectCommand = new DetectCommand { SourceDir = sourceDir, }; var testConsole = new TestConsole(); // Act var exitCode = detectCommand.Execute(GetServiceProvider(detectCommand), testConsole); // Assert Assert.Equal(ProcessConstants.ExitSuccess, exitCode); Assert.Contains( $"{NodeConstants.PlatformName}", testConsole.StdOutput); Assert.Contains( $"Not Detected", testConsole.StdOutput); }
public void Execute_OutputsJson_NodePlatformAndVersionAndFrameworkInfos() { string PackageJsonWithNodeVersion = @"{ ""name"": ""mynodeapp"", ""version"": ""1.0.0"", ""main"": ""server.js"", ""devDependencies"": { ""aurelia-cli"": ""1.3.1"", ""svelte"": ""3.0.0"", }, ""dependencies"": { ""jquery"": ""3.5.1"", ""react"": ""16.12.0"", }, ""author"": ""Dev"", ""engines"" : { ""node"" : ""6.11.0"" } }"; // Arrange var sourceDir = Path.Combine(_testDirPath, "nodeappdir"); Directory.CreateDirectory(sourceDir); File.WriteAllText(Path.Combine(sourceDir, NodeConstants.PackageJsonFileName), PackageJsonWithNodeVersion); var detectCommand = new DetectCommand { SourceDir = sourceDir, OutputFormat = "json", }; var testConsole = new TestConsole(); // Act var exitCode = detectCommand.Execute(GetServiceProvider(detectCommand), testConsole); // Assert Assert.Equal(ProcessConstants.ExitSuccess, exitCode); Assert.Contains( $"\"Platform\": \"{NodeConstants.PlatformName}\"", testConsole.StdOutput); Assert.Contains( "\"PlatformVersion\": \"6.11.0\"", testConsole.StdOutput); Assert.Contains( $"\"Framework\": \"Aurelia\"", testConsole.StdOutput); Assert.Contains( $"\"Framework\": \"React\"", testConsole.StdOutput); }
public void Execute_OutputsJson_DotNetCorePlatformAndVersionAndProjectFile() { string ProjectFileWithMultipleProperties = @" <Project Sdk=""Microsoft.NET.Sdk.Web""> <PropertyGroup> <LangVersion>7.3</LangVersion> </PropertyGroup> <PropertyGroup> <TargetFramework>netcoreapp2.1</TargetFramework> <LangVersion>7.3</LangVersion> </PropertyGroup> </Project>"; // Arrange var sourceDir = Path.Combine(_testDirPath, "dotnetcoreappdir"); var projectFile = "webapp.csproj"; Directory.CreateDirectory(sourceDir); File.WriteAllText(Path.Combine(sourceDir, projectFile), ProjectFileWithMultipleProperties); var detectCommand = new DetectCommand { SourceDir = sourceDir, OutputFormat = "json", }; var testConsole = new TestConsole(); // Act var exitCode = detectCommand.Execute(GetServiceProvider(detectCommand), testConsole); // Assert Assert.Equal(ProcessConstants.ExitSuccess, exitCode); Assert.Contains( $"\"Platform\": \"{DotNetCoreConstants.PlatformName}\"", testConsole.StdOutput); Assert.Contains( "\"PlatformVersion\": \"2.1\"", testConsole.StdOutput); Assert.Contains( $"\"ProjectFile\": \"{projectFile}\"", testConsole.StdOutput); }
public void Execute_OutputsJson_NodePlatformAndVersion_WhenJsonFileExplicitsVersion() { string PackageJsonWithNodeVersion = @"{ ""name"": ""mynodeapp"", ""version"": ""1.0.0"", ""description"": ""test app"", ""main"": ""server.js"", ""scripts"": { ""test"": ""echo \""Error: no test specified\"" && exit 1"", ""start"": ""node server.js"" }, ""author"": ""Dev"", ""license"": ""ISC"", ""engines"" : { ""node"" : ""6.11.0"" } }"; // Arrange var sourceDir = Path.Combine(_testDirPath, "nodeappdir"); Directory.CreateDirectory(sourceDir); File.WriteAllText(Path.Combine(sourceDir, NodeConstants.PackageJsonFileName), PackageJsonWithNodeVersion); var detectCommand = new DetectCommand { SourceDir = sourceDir, OutputFormat = "json", }; var testConsole = new TestConsole(); // Act var exitCode = detectCommand.Execute(GetServiceProvider(detectCommand), testConsole); // Assert Assert.Equal(ProcessConstants.ExitSuccess, exitCode); Assert.Contains( $"\"Platform\": \"{NodeConstants.PlatformName}\"", testConsole.StdOutput); Assert.Contains( "\"PlatformVersion\": \"6.11.0\"", testConsole.StdOutput); }