Ejemplo n.º 1
0
 public void CodeWriterCreatesDirectory()
 {
     var settings = new Settings
     {
         CodeGenerator = "CSharp",
         FileSystem = _fileSystem,
         OutputDirectory = Path.GetTempPath()
     };
     SampleCodeGenerator codeGenerator = new SampleCodeGenerator(settings);
     codeGenerator.Generate(new ServiceClient()).GetAwaiter().GetResult();
     Assert.Contains(Path.Combine(settings.OutputDirectory, "Models"), _fileSystem.VirtualStore.Keys);
 }
Ejemplo n.º 2
0
 public void CodeWriterOverwritesExistingFile()
 {
     var settings = new Settings
     {
         CodeGenerator = "CSharp",
         FileSystem = _fileSystem,
         OutputDirectory = Path.GetTempPath()
     };
     string existingContents = "this is dummy";
     string path = Path.Combine(settings.OutputDirectory, "Models", "Pet.cs");
     _fileSystem.VirtualStore[path] = new StringBuilder(existingContents);
     var codeGenerator = new SampleCodeGenerator(settings);
     codeGenerator.Generate(new ServiceClient()).GetAwaiter().GetResult();
     Assert.NotEqual(existingContents, _fileSystem.VirtualStore[path].ToString());
 }
Ejemplo n.º 3
0
        public void OutputToSingleFile()
        {
            var settings = new Settings
            {
                Modeler = "Swagger",
                CodeGenerator = "CSharp",
                Input = "RedisResource.json",
                FileSystem = _fileSystem,
                OutputDirectory = Path.GetTempPath(),
                OutputFileName = "test.file.cs"
            };

            string path = Path.Combine(settings.OutputDirectory, "test.file.cs");
            var codeGenerator = new SampleCodeGenerator(settings);
            codeGenerator.Generate(new ServiceClient()).GetAwaiter().GetResult();
            Assert.Equal(4, _fileSystem.VirtualStore.Count);
            Assert.True(_fileSystem.VirtualStore.ContainsKey(path));
            Assert.True(_fileSystem.VirtualStore.ContainsKey("AutoRest.json"));
            Assert.True(_fileSystem.VirtualStore.ContainsKey("RedisResource.json"));
        }