public void OnExecute_Should_Create_Generator(
            IConsoleOutput console,
            IAutoRestOptions options,
            IProcessLauncher processLauncher,
            IProgressReporter progressReporter,
            IAutoRestCodeGeneratorFactory factory,
            IOpenApiDocumentFactory documentFactory,
            string swaggerFile)
        {
            new AutoRestCommand(
                console,
                options,
                processLauncher,
                progressReporter,
                factory,
                documentFactory)
            {
                SwaggerFile = swaggerFile
            }
            .OnExecute();

            Mock.Get(factory)
            .Verify(
                c => c.Create(
                    swaggerFile,
                    "GeneratedCode",
                    options,
                    processLauncher,
                    documentFactory));
        }
        public void OnExecuteAsync_Should_NotThrow(
            IConsoleOutput console,
            IAutoRestOptions options,
            IProcessLauncher processLauncher,
            IProgressReporter progressReporter,
            IAutoRestCodeGeneratorFactory factory,
            ICodeGenerator generator,
            IOpenApiDocumentFactory documentFactory,
            string outputFile,
            string code)
        {
            var sut = new AutoRestCommand(
                console,
                options,
                processLauncher,
                progressReporter,
                factory,
                documentFactory)
            {
                OutputFile = outputFile
            };

            Mock.Get(generator).Setup(c => c.GenerateCode(progressReporter)).Returns(code);
            new Func <int>(sut.OnExecute).Should().NotThrow();
        }
 public async Task OnExecuteAsync_Should_Create_Generator(
     IConsoleOutput console,
     IAutoRestOptions options,
     IProcessLauncher processLauncher,
     IProgressReporter progressReporter,
     IAutoRestCodeGeneratorFactory factory,
     IOpenApiDocumentFactory documentFactory,
     string swaggerFile)
 => await new AutoRestCommand(
     console,
     options,
     processLauncher,
     progressReporter,
     factory,
     documentFactory)
 {
     SwaggerFile = swaggerFile
 }
 .OnExecuteAsync()
 .ContinueWith(
     t => Mock.Get(factory)
     .Verify(
         c => c.Create(
             swaggerFile,
             "GeneratedCode",
             options,
             processLauncher,
             documentFactory)));
Exemplo n.º 4
0
 public AutoRestSingleFileCustomTool(
     IAutoRestCodeGeneratorFactory factory,
     IAutoRestOptions options,
     IProcessLauncher processLauncher)
 {
     this.factory         = factory ?? throw new ArgumentNullException(nameof(factory));
     this.options         = options ?? throw new ArgumentNullException(nameof(options));
     this.processLauncher = processLauncher ?? throw new ArgumentNullException(nameof(processLauncher));
 }
Exemplo n.º 5
0
 public AutoRestCommand(
     IConsoleOutput console,
     IAutoRestOptions options,
     IProcessLauncher processLauncher,
     IProgressReporter progressReporter,
     IAutoRestCodeGeneratorFactory factory) : base(console, progressReporter)
 {
     this.options         = options ?? throw new ArgumentNullException(nameof(options));
     this.processLauncher = processLauncher ?? throw new ArgumentNullException(nameof(processLauncher));
     this.factory         = factory ?? throw new ArgumentNullException(nameof(factory));
 }
 public AutoRestSingleFileCustomTool(
     IAutoRestCodeGeneratorFactory factory,
     IAutoRestOptions options,
     IProcessLauncher processLauncher,
     IOpenApiDocumentFactory documentFactory,
     IDependencyInstaller dependencyInstaller)
 {
     this.factory             = factory ?? throw new ArgumentNullException(nameof(factory));
     this.options             = options ?? throw new ArgumentNullException(nameof(options));
     this.processLauncher     = processLauncher ?? throw new ArgumentNullException(nameof(processLauncher));
     this.documentFactory     = documentFactory ?? throw new ArgumentNullException(nameof(documentFactory));
     this.dependencyInstaller = dependencyInstaller;
 }
 public AutoRestCommand(
     IConsoleOutput console,
     IAutoRestOptions options,
     IProcessLauncher processLauncher,
     IProgressReporter progressReporter,
     IAutoRestCodeGeneratorFactory factory,
     IOpenApiDocumentFactory documentFactory,
     IDependencyInstaller dependencyInstaller) : base(console, progressReporter)
 {
     this.options             = options ?? throw new ArgumentNullException(nameof(options));
     this.processLauncher     = processLauncher ?? throw new ArgumentNullException(nameof(processLauncher));
     this.factory             = factory ?? throw new ArgumentNullException(nameof(factory));
     this.documentFactory     = documentFactory ?? throw new ArgumentNullException(nameof(documentFactory));
     this.dependencyInstaller = dependencyInstaller ?? throw new ArgumentNullException(nameof(dependencyInstaller));
 }
 public void Constructor_Should_Throw_On_Null_IProcessLauncher(
     IConsoleOutput console,
     IAutoRestOptions options,
     IProgressReporter progressReporter,
     IAutoRestCodeGeneratorFactory factory,
     IOpenApiDocumentFactory documentFactory)
 => new Action(
     () => new AutoRestCommand(
         console,
         options,
         null,
         progressReporter,
         factory,
         documentFactory))
 .Should()
 .ThrowExactly <ArgumentNullException>();
        public void OnExecute_Should_Create_Generator(
            [Frozen] IAutoRestCodeGeneratorFactory factory,
            AutoRestCommand sut)
        {
            sut.OnExecute();

            Mock.Get(factory)
            .Verify(
                c => c.Create(
                    sut.SwaggerFile,
                    sut.DefaultNamespace,
                    It.IsAny <IAutoRestOptions>(),
                    It.IsAny <IProcessLauncher>(),
                    It.IsAny <IOpenApiDocumentFactory>(),
                    It.IsAny <IDependencyInstaller>()));
        }