public void CanGenerateFrontEndImplementation() { // arrange var workspace = LoadExampleWebAppWorkspace(); // act var codeModel = ReadCodeModel(workspace); var uiMetadata = new WebUIMetadata(codeModel); var output = new TestCodeGeneratorOutput(); var adapter = new HyperappAdapter(codeModel, new ComponentAdapterFactory(), output); adapter.GenerateImplementations(uiMetadata); // assert //WriteOutputToDisk(output, "FrontEnd"); AssertOutputs( output.IndexSourceFilesByNormalPath(), subFolder: "FrontEnd", "build/index.html", "src/index.js", "src/components/form.js", "src/services/greeting-service.js"); }
public void CanGenerateBackEndImplementation() { // arrange var workspace = LoadExampleWebAppWorkspace(); // act var codeModel = ReadCodeModel(workspace); var uiMetadata = new WebUIMetadata(codeModel); var output = new TestCodeGeneratorOutput(); var adapter = new AspNetAdapter(codeModel, output); adapter.GenerateImplementations(uiMetadata); // assert //WriteOutputToDisk(output, "BackEnd"); AssertOutputs( output.IndexSourceFilesByNormalPath(), subFolder: "BackEnd", "AspNetAdapter/InvalidModelAutoResponderAttribute.cs", "App/Services/WebApi/GreetingServiceController.cs"); }
private void WriteOutputToDisk(TestCodeGeneratorOutput output, string subFolder) { var outputPath = Path.Combine(@"C:\temp\codegen", subFolder); foreach (var pair in output.IndexSourceFilesByNormalPath()) { var filePath = Path.Combine(outputPath, pair.Key); var folderPath = Path.GetDirectoryName(filePath); if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } using (var file = File.Create(filePath)) { pair.Value.Position = 0; pair.Value.CopyTo(file); file.Flush(); } } }