forked from Azure/autorest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:Azure/AutoRest into netcore
- Loading branch information
Showing
322 changed files
with
57,647 additions
and
1,600 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
AutoRest/Generators/AzureResourceSchema/AzureResourceSchema.Tests/AcceptanceTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
using Microsoft.Rest.Generator.AzureResourceSchema; | ||
using Microsoft.Rest.Modeler.Swagger.Tests; | ||
using System.IO; | ||
using Xunit; | ||
|
||
namespace AutoRest.Generator.AzureResourceSchema.Tests | ||
{ | ||
[Collection("AutoRest Azure Resource Schema Tests")] | ||
public static class AcceptanceTests | ||
{ | ||
[Fact] | ||
public static void Storage() | ||
{ | ||
RunSwaggerTest("storage.json", "Storage"); | ||
} | ||
|
||
[Fact] | ||
public static void Batch() | ||
{ | ||
RunSwaggerTest("BatchManagement.json", "Batch"); | ||
} | ||
|
||
[Fact] | ||
public static void Cdn() | ||
{ | ||
RunSwaggerTest("cdn.json", "CDN"); | ||
} | ||
|
||
[Fact] | ||
public static void Compute() | ||
{ | ||
RunSwaggerTest("compute.json", "Compute"); | ||
} | ||
|
||
[Fact] | ||
public static void Network() | ||
{ | ||
RunSwaggerTest("network.json", "Network"); | ||
} | ||
|
||
[Fact] | ||
public static void Web() | ||
{ | ||
RunSwaggerTest("web.json", "Web"); | ||
} | ||
|
||
private static void RunSwaggerTest(string swaggerFileName, string expectedFolderName) | ||
{ | ||
SwaggerSpecHelper.RunTests<AzureResourceSchemaCodeGenerator>( | ||
Path.Combine("Swagger", swaggerFileName), | ||
Path.Combine("Expected", expectedFolderName)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
...rs/AzureResourceSchema/AzureResourceSchema.Tests/AzureResourceSchemaCodeGeneratorTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
using Microsoft.Rest.Generator.ClientModel; | ||
using Microsoft.Rest.Generator.Utilities; | ||
using Newtonsoft.Json.Linq; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace Microsoft.Rest.Generator.AzureResourceSchema.Tests | ||
{ | ||
[Collection("AutoRest Tests")] | ||
public class AzureResourceSchemaCodeGeneratorTests | ||
{ | ||
[Fact] | ||
public void Description() | ||
{ | ||
Assert.Equal("Azure Resource Schema generator", CreateGenerator().Description); | ||
} | ||
|
||
[Fact] | ||
public void ImplementationFileExtension() | ||
{ | ||
Assert.Equal(".json", CreateGenerator().ImplementationFileExtension); | ||
} | ||
|
||
[Fact] | ||
public void Name() | ||
{ | ||
Assert.Equal("AzureResourceSchema", CreateGenerator().Name); | ||
} | ||
|
||
[Fact] | ||
public void UsageInstructionsWithNoOutputFileSetting() | ||
{ | ||
AzureResourceSchemaCodeGenerator codeGen = CreateGenerator(); | ||
Assert.Equal("Your Azure Resource Schema(s) can be found in " + codeGen.Settings.OutputDirectory, codeGen.UsageInstructions); | ||
} | ||
|
||
[Fact] | ||
public void UsageInstructionsWithOutputFileSetting() | ||
{ | ||
Settings settings = new Settings() | ||
{ | ||
OutputFileName = "spam.json" | ||
}; | ||
AzureResourceSchemaCodeGenerator codeGen = CreateGenerator(settings); | ||
|
||
Assert.Equal("Your Azure Resource Schema(s) can be found in " + settings.OutputDirectory, codeGen.UsageInstructions); | ||
} | ||
|
||
[Fact] | ||
public void NormalizeClientModelDoesNothing() | ||
{ | ||
ServiceClient serviceClient = new ServiceClient(); | ||
CreateGenerator().NormalizeClientModel(serviceClient); | ||
|
||
// Nothing happens | ||
} | ||
|
||
private static AzureResourceSchemaCodeGenerator CreateGenerator() | ||
{ | ||
return CreateGenerator(new Settings()); | ||
} | ||
private static AzureResourceSchemaCodeGenerator CreateGenerator(Settings settings) | ||
{ | ||
return new AzureResourceSchemaCodeGenerator(settings); | ||
} | ||
|
||
private static async Task TestGenerate(string apiVersion, string[] methodUrls, string expectedJsonString) | ||
{ | ||
MemoryFileSystem fileSystem = new MemoryFileSystem(); | ||
|
||
Settings settings = new Settings(); | ||
settings.FileSystem = fileSystem; | ||
|
||
ServiceClient serviceClient = new ServiceClient(); | ||
serviceClient.ApiVersion = apiVersion; | ||
foreach(string methodUrl in methodUrls) | ||
{ | ||
serviceClient.Methods.Add(new Method() | ||
{ | ||
Url = methodUrl, | ||
HttpMethod = HttpMethod.Put, | ||
}); | ||
} | ||
await CreateGenerator(settings).Generate(serviceClient); | ||
|
||
Assert.Equal(2, fileSystem.VirtualStore.Count); | ||
|
||
string folderPath = fileSystem.VirtualStore.Keys.First(); | ||
Assert.Equal("Folder", fileSystem.VirtualStore[folderPath].ToString()); | ||
|
||
JObject expectedJSON = JObject.Parse(expectedJsonString); | ||
|
||
string fileContents = fileSystem.VirtualStore[fileSystem.VirtualStore.Keys.Skip(1).First()].ToString(); | ||
JObject actualJson = JObject.Parse(fileContents); | ||
|
||
Assert.Equal(expectedJSON, actualJson); | ||
} | ||
} | ||
} |
Oops, something went wrong.