public void ConvertsPageResultsToPageTypeTest() { var settings = new Settings { Input = Path.Combine("Swagger", "azure-paging.json"), Header = "NONE", Modeler = "Swagger" }; settings.FileSystem = new MemoryFileSystem(); settings.FileSystem.CreateDirectory(Path.GetDirectoryName(settings.Input)); settings.FileSystem.WriteFile(settings.Input, File.ReadAllText(settings.Input)); SwaggerModeler modeler = new SwaggerModeler(settings); var serviceClient = modeler.Build(); var codeNamer = new AzureCSharpCodeNamer(); codeNamer.NormalizePaginatedMethods(serviceClient); Assert.Equal("Page<Product>", serviceClient.Methods[0].ReturnType.Name); Assert.Equal("Object", serviceClient.Methods[1].ReturnType.Name); Assert.Equal("Page<Product>", serviceClient.Methods[1].Responses.ElementAt(0).Value.Name); Assert.Equal("String", serviceClient.Methods[1].Responses.ElementAt(1).Value.Name); Assert.Equal("Object", serviceClient.Methods[2].ReturnType.Name); Assert.Equal("Page<Product>", serviceClient.Methods[2].Responses.ElementAt(0).Value.Name); Assert.Equal("Page<Product>", serviceClient.Methods[2].Responses.ElementAt(1).Value.Name); Assert.Equal("Object", serviceClient.Methods[3].ReturnType.Name); Assert.Equal("Page<Product>", serviceClient.Methods[3].Responses.ElementAt(0).Value.Name); Assert.Equal("Page<ProductChild>", serviceClient.Methods[3].Responses.ElementAt(1).Value.Name); Assert.Equal(4, serviceClient.ModelTypes.Count); Assert.False(serviceClient.ModelTypes.Any(t => t.Name.Equals("ProducResult", StringComparison.OrdinalIgnoreCase))); Assert.False(serviceClient.ModelTypes.Any(t => t.Name.Equals("ProducResult2", StringComparison.OrdinalIgnoreCase))); Assert.False(serviceClient.ModelTypes.Any(t => t.Name.Equals("ProducResult3", StringComparison.OrdinalIgnoreCase))); }
public void ConvertsPageResultsToPageTypeTest() { var settings = new Settings { Input = Path.Combine("Swagger", "azure-paging.json"), Header = "NONE", Modeler = "Swagger", CodeGenerator = "CSharp" }; settings.FileSystem = new MemoryFileSystem(); settings.FileSystem.CreateDirectory(Path.GetDirectoryName(settings.Input)); settings.FileSystem.WriteFile(settings.Input, File.ReadAllText(settings.Input)); SwaggerModeler modeler = new SwaggerModeler(settings); var serviceClient = modeler.Build(); var codeNamer = new AzureCSharpCodeNamer(); var objName = codeNamer.NormalizeTypeReference(PrimaryType.Object).Name; var strName = codeNamer.NormalizeTypeReference(PrimaryType.String).Name; IDictionary <KeyValuePair <string, string>, string> pageClass = new Dictionary <KeyValuePair <string, string>, string>(); codeNamer.NormalizePaginatedMethods(serviceClient, pageClass); Assert.Equal("Page<Product>", serviceClient.Methods[0].ReturnType.Body.Name); Assert.Equal(objName, serviceClient.Methods[1].ReturnType.Body.Name); Assert.Equal("Page<Product>", serviceClient.Methods[1].Responses.ElementAt(0).Value.Body.Name); Assert.Equal(strName, serviceClient.Methods[1].Responses.ElementAt(1).Value.Body.Name); Assert.Equal(objName, serviceClient.Methods[2].ReturnType.Body.Name); Assert.Equal("Page<Product>", serviceClient.Methods[2].Responses.ElementAt(0).Value.Body.Name); Assert.Equal("Page<Product>", serviceClient.Methods[2].Responses.ElementAt(1).Value.Body.Name); Assert.Equal(objName, serviceClient.Methods[3].ReturnType.Body.Name); Assert.Equal("Page<Product>", serviceClient.Methods[3].Responses.ElementAt(0).Value.Body.Name); Assert.Equal("Page<ProductChild>", serviceClient.Methods[3].Responses.ElementAt(1).Value.Body.Name); Assert.Equal(4, serviceClient.ModelTypes.Count); Assert.False(serviceClient.ModelTypes.Any(t => t.Name.Equals("ProducResult", StringComparison.OrdinalIgnoreCase))); Assert.False(serviceClient.ModelTypes.Any(t => t.Name.Equals("ProducResult2", StringComparison.OrdinalIgnoreCase))); Assert.False(serviceClient.ModelTypes.Any(t => t.Name.Equals("ProducResult3", StringComparison.OrdinalIgnoreCase))); }
public AzureCSharpCodeGenerator(Settings settings) : base(settings) { _namer = new AzureCSharpCodeNamer(); IsSingleFileGenerationSupported = true; pageClasses = new Dictionary<KeyValuePair<string, string>, string>(); }
public AzureCSharpCodeGenerator(Settings settings) : base(settings) { _namer = new AzureCSharpCodeNamer(); IsSingleFileGenerationSupported = true; pageClasses = new Dictionary <KeyValuePair <string, string>, string>(); }
public AzureCSharpCodeGenerator(Settings settings) : base(settings) { _namer = new AzureCSharpCodeNamer(); IsSingleFileGenerationSupported = true; }
public AzureCSharpCodeGenerator(Settings settings) : base(settings) { _namer = new AzureCSharpCodeNamer(); }