public void tool_should_generate_controller_revisions_if_attribute_on_controller() { #if DEBUG var assemblyPath = "../../../../openapi-to-terraform.Tests.TestAPIControllerRevisions/bin/Debug/net5.0/openapi-to-terraform.Tests.TestAPIControllerRevisions.dll"; #else var assemblyPath = "../../../../openapi-to-terraform.Tests.TestAPIControllerRevisions/bin/Release/net5.0/openapi-to-terraform.Tests.TestAPIControllerRevisions.dll"; #endif var convertedAssemblyPath = Path.Combine(Directory.GetCurrentDirectory(), assemblyPath); var openApiPath = "samples/controllerRevs.v1.json"; var openApiText = File.ReadAllText(openApiPath); var docTree = new OpenApiParser(openApiText).Read(); Assembly startupAssembly = Assembly.LoadFrom(convertedAssemblyPath); var revisions = RevisionsGenerator.Generate(startupAssembly, docTree); IDictionary <string, JToken> revisionsFileParsed = JObject.Parse(revisions); revisionsFileParsed.Keys.Count.Should().Be(1); // Only one controller with one action in openapi file, so should be one key var revisionsCount = revisionsFileParsed.First().Value.Count(); revisionsCount.Should().Be(2); // The controller has two revisions defined, so there should be two here }
public void tool_should_generate_no_revisions_if_no_attributes() { #if DEBUG var assemblyPath = "../../../../openapi-to-terraform.Tests.TestAPINoRevs/bin/Debug/net5.0/openapi-to-terraform.Tests.TestAPINoRevs.dll"; #else var assemblyPath = "../../../../openapi-to-terraform.Tests.TestAPINoRevs/bin/Release/net5.0/openapi-to-terraform.Tests.TestAPINoRevs.dll"; #endif var convertedAssemblyPath = Path.Combine(Directory.GetCurrentDirectory(), assemblyPath); var openApiPath = "samples/noRevs.v1.json"; var openApiText = File.ReadAllText(openApiPath); var docTree = new OpenApiParser(openApiText).Read(); Assembly startupAssembly = Assembly.LoadFrom(convertedAssemblyPath); var revisions = RevisionsGenerator.Generate(startupAssembly, docTree); IDictionary <string, JToken> revisionsFileParsed = JObject.Parse(revisions); revisionsFileParsed.Keys.Count.Should().Be(1); var revisionsFirstCount = revisionsFileParsed.First().Value.Count(); revisionsFirstCount.Should().Be(1); }