Exemple #1
0
        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");
        }
Exemple #2
0
        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");
        }
Exemple #3
0
        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();
                }
            }
        }