public void Detect_ReturnsWithoutOutputType( string outputTypeName, string expectedOutputType) { // Arrange // create .csproj var projectFile = "test.csproj"; var sourceRepo = new Mock <ISourceRepo>(); sourceRepo .Setup(repo => repo.EnumerateFiles(It.IsAny <string>(), It.IsAny <bool>())) .Returns(new[] { projectFile }); // no outputtype test sourceRepo .Setup(repo => repo.ReadFile(It.IsAny <string>())) .Returns(SampleProjectFileContents.ProjectFileWithOutOutputTypePlaceHolder.Replace( "#OutputType#", outputTypeName)); // file context containing XML var context = CreateContext(sourceRepo.Object); // initiailize Detector var detector = CreateDetector(projectFile); // Act DotNetCorePlatformDetectorResult result = (DotNetCorePlatformDetectorResult)detector.Detect(context); Assert.NotNull(result); // check our outputType is there Assert.Equal(expectedOutputType, result.OutputType); }
public void GeneratedBuildSnippet_AOTCompilationInstallCommandWillExecute_WhenBlazorWasmDotNet6App() { // Arrange var installationScript = "test-script"; var dotNetCorePlatform = CreateDotNetCorePlatform( isDotNetCoreVersionAlreadyInstalled: true, dotNetCoreInstallationScript: installationScript); var repo = new MemorySourceRepo(); repo.AddFile(ProjectFileAzureBlazorWasmClientWithTargetFramework6, "test.csproj"); var context = CreateContext(repo); var detectedResult = new DotNetCorePlatformDetectorResult { Platform = DotNetCoreConstants.PlatformName, PlatformVersion = "6.0", InstallAOTWorkloads = true, ProjectFile = "test.csproj", }; // Act var buildScriptSnippet = dotNetCorePlatform.GenerateBashBuildScriptSnippet(context, detectedResult); // Assert Assert.NotNull(buildScriptSnippet); Assert.Contains(DotNetCoreConstants.InstallBlazorWebAssemblyAOTWorkloadCommand, buildScriptSnippet.BashBuildScriptSnippet); }
private static PlatformDetectorResult GetPlatformDetectorResult(string name, string version) { var result = new PlatformDetectorResult(); switch (name) { case DotNetCoreConstants.PlatformName: result = new DotNetCorePlatformDetectorResult(); break; case NodeConstants.PlatformName: result = new NodePlatformDetectorResult(); break; case PythonConstants.PlatformName: result = new PythonPlatformDetectorResult(); break; case HugoConstants.PlatformName: result = new PlatformDetectorResult(); break; case PhpConstants.PlatformName: result = new PhpPlatformDetectorResult(); break; case JavaConstants.PlatformName: result = new JavaPlatformDetectorResult(); break; case RubyConstants.PlatformName: result = new RubyPlatformDetectorResult(); break; } result.Platform = name; result.PlatformVersion = version; return(result); }