コード例 #1
0
        public void WriteProjectFile(GenerateProjectFileCommand command)
        {
            var projectGenerator = new NetStandardLibraryGenerator(command.ProjectName, command.CodeLanguage);
            var generatedFile    = projectGenerator.GenerateFileContent(command.Path);

            GeneratedFileWriter.WriteFileToDisk(generatedFile);
        }
コード例 #2
0
        public void GeneratedProjectBuildsSuccessfully(CodeGenLanguage codeGenLanguage)
        {
            var context = new ProjectTestContext(GetType().Name,
                                                 $"{MethodBase.GetCurrentMethod().Name}{codeGenLanguage}");

            try
            {
                //given
                context.TargetFramework = "netstandard2.0";
                context.CreateEmptyProject();
                var fullProjectFilePath = Path.Combine(context.TargetProjectFolder,
                                                       context.ProjectName + CodeGenLanguageExt.ProjectFileExtensions[codeGenLanguage]);

                var generator = new NetStandardLibraryGenerator(fullProjectFilePath, codeGenLanguage)
                {
                    NethereumWeb3Version = Constants.NethereumWeb3Version
                };

                //when
                //code gen proj file
                var projectFile = generator.GenerateFileContent(context.TargetProjectFolder);
                GeneratedFileWriter.WriteFileToDisk(projectFile);

                //add in some code gen class files
                var contractMetaData = TestContracts.StandardContract;
                var contractABI      = new GeneratorModelABIDeserialiser().DeserialiseABI(contractMetaData.ABI);

                var contractProjectGenerator = new ContractProjectGenerator(
                    contractABI,
                    "StandardContract",
                    contractMetaData.ByteCode,
                    context.ProjectName,
                    "StandardContract.Service",
                    "StandardContract.CQS",
                    "StandardContract.DTO",
                    context.TargetProjectFolder,
                    Path.DirectorySeparatorChar.ToString(),
                    codeGenLanguage)
                {
                    AddRootNamespaceOnVbProjectsToImportStatements = false
                };

                var generatedFiles = contractProjectGenerator.GenerateAll();
                GeneratedFileWriter.WriteFilesToDisk(generatedFiles);

                context.BuildProject();

                //then
                Assert.True(context.BuildHasSucceeded());
            }
            finally
            {
                context.CleanUp();
            }
        }