public AutoRestCSharpCodeGenerator( string swaggerFile, string defaultNamespace, IAutoRestOptions options, IProcessLauncher processLauncher, IOpenApiDocumentFactory documentFactory, IDependencyInstaller dependencyInstaller, IAutoRestArgumentProvider argumentProvider = null) { SwaggerFile = swaggerFile; DefaultNamespace = defaultNamespace; this.processLauncher = processLauncher; this.documentFactory = documentFactory ?? throw new ArgumentNullException(nameof(documentFactory)); this.dependencyInstaller = dependencyInstaller ?? throw new ArgumentNullException(nameof(dependencyInstaller)); this.argumentProvider = argumentProvider ?? new AutoRestArgumentProvider(options); }
public void Tries_Again_Upon_ProcessLaunchException_For_OpenApi_v2( [Frozen] IOpenApiDocumentFactory factory, [Frozen] IProcessLauncher processLauncher, [Frozen] IAutoRestArgumentProvider argumentProvider, AutoRestCSharpCodeGenerator sut, IProgressReporter progress, ProcessLaunchException exception, string arguments) { arguments += "--version=[some version]"; Mock.Get(processLauncher) .Setup( c => c.Start( It.IsAny <string>(), arguments, It.IsAny <string>())) .Throws(exception); Mock.Get(argumentProvider) .Setup( c => c.GetLegacyArguments( It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())) .Returns(arguments); ArrangeOpenApiDocumentFactory(factory); sut.GenerateCode(progress); Mock.Get(processLauncher) .Verify( c => c.Start( It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()), Times.Exactly(2)); }