Beispiel #1
0
        public void TestClientNameCSharpNormalization()
        {
            var setting = new Settings
            {
                Namespace = "Test",
                Input = Path.Combine("Swagger", "swagger-x-ms-client-name.json")
            };

            var modeler = new SwaggerModeler(setting);
            var clientModel = modeler.Build();
            SwaggerExtensions.NormalizeClientModel(clientModel, setting);
            var namer = new CSharpCodeNamer();
            namer.NormalizeClientModel(clientModel);

            Assert.NotNull(clientModel);
            Assert.Equal(2, clientModel.Methods.Count);

            Assert.Equal(2, clientModel.Methods[0].Parameters.Where(p => !p.IsClientProperty).Count());

            Assert.Equal("subscription", clientModel.Methods[0].Parameters[0].GetClientName());
            Assert.Equal("version", clientModel.Methods[0].Parameters[1].GetClientName());
            Assert.Equal("subscription", clientModel.Methods[0].Parameters[0].Name);
            Assert.Equal("version", clientModel.Methods[0].Parameters[1].Name);

            Assert.Equal(2, clientModel.Properties.Count);
            Assert.Equal(0, clientModel.Methods[1].Parameters.Where(p => !p.IsClientProperty).Count());

            Assert.Equal("subscription", clientModel.Properties[0].GetClientName());
            Assert.Equal("_version", clientModel.Properties[1].GetClientName());
            Assert.Equal("Subscription", clientModel.Properties[0].Name);
            Assert.Equal("_version", clientModel.Properties[1].Name);

            var type = clientModel.ModelTypes.First();

            Assert.Equal("ErrorCode", type.Properties[0].Name);
            Assert.Equal("ErrorMessage", type.Properties[1].Name);
            Assert.Equal("ParentError", type.Properties[2].Name);
        }
 public CSharpCodeGenerator(Settings settings) : base(settings)
 {
     _namer = new CSharpCodeNamer();
     IsSingleFileGenerationSupported = true;
 }
 public CSharpCodeGenerator(Settings settings) : base(settings)
 {
     _namer = new CSharpCodeNamer();
     IsSingleFileGenerationSupported = true;
 }