private DefaultBuildScriptGenerator CreateDefaultScriptGenerator( IProgrammingPlatform[] platforms, BuildScriptGeneratorOptions commonOptions, IEnumerable <IChecker> checkers = null) { commonOptions = commonOptions ?? new BuildScriptGeneratorOptions(); commonOptions.SourceDir = "/app"; commonOptions.DestinationDir = "/output"; var defaultPlatformDetector = new DefaultPlatformDetector( platforms, new DefaultStandardOutputWriter()); var envScriptProvider = new BuildScriptGenerator.PlatformsInstallationScriptProvider( platforms, defaultPlatformDetector, new DefaultStandardOutputWriter()); return(new DefaultBuildScriptGenerator( defaultPlatformDetector, envScriptProvider, Options.Create(commonOptions), new DefaultCompatiblePlatformDetector( platforms, NullLogger <DefaultCompatiblePlatformDetector> .Instance, Options.Create(commonOptions)), checkers, NullLogger <DefaultBuildScriptGenerator> .Instance, new DefaultStandardOutputWriter())); }
private PlatformsInstallationScriptProvider CreateEnvironmentSetupScriptProvider( IEnumerable <IProgrammingPlatform> platforms) { var platformDetector = new DefaultPlatformDetector( platforms, new DefaultStandardOutputWriter()); return(new PlatformsInstallationScriptProvider( platforms, platformDetector, new DefaultStandardOutputWriter())); }
public void Detect_ReturnsResult_MultiplePlatform_DotNetCoreReactApp() { Mock <IPlatformDetector> mockNodePlatformDetector = new Mock <IPlatformDetector>(); Mock <IPlatformDetector> mockDotnetcorePlatformDetector = new Mock <IPlatformDetector>(); IEnumerable <IPlatformDetector> platformDetectors = new List <IPlatformDetector>() { mockNodePlatformDetector.Object, mockDotnetcorePlatformDetector.Object }; var options = new Mock <IOptions <DetectorOptions> >(); var sourceRepo = new MemorySourceRepo(); var detector = new DefaultPlatformDetector( platformDetectors, NullLogger <DefaultPlatformDetector> .Instance, options.Object); var context = CreateContext(sourceRepo); var detectionResult1 = new PlatformDetectorResult(); detectionResult1.Platform = "node"; detectionResult1.PlatformVersion = "12.16.1"; var detectionResult2 = new PlatformDetectorResult(); detectionResult2.Platform = "dotnetcore"; detectionResult2.PlatformVersion = "3.1"; mockNodePlatformDetector.Setup(x => x.DetectorPlatformName).Returns(PlatformName.Node); mockDotnetcorePlatformDetector.Setup(x => x.DetectorPlatformName).Returns(PlatformName.DotNetCore); mockNodePlatformDetector.Setup(x => x.Detect(context)).Returns(detectionResult1); mockDotnetcorePlatformDetector.Setup(x => x.Detect(context)).Returns(detectionResult2); IPlatformDetector nodePlatformDetector = mockNodePlatformDetector.Object; IPlatformDetector dotnetcorePlatformDetector = mockDotnetcorePlatformDetector.Object; // Act var detectionResults = detector.GetAllDetectedPlatforms(context); // Assert Assert.NotNull(detectionResults); Assert.Equal(2, detectionResults.Count); }