public void GivenRelativeAbiFilePathInProject() { //given var factory = new GeneratorConfigurationFactory(); var context = new ProjectTestContext(this.GetType().Name, MethodBase.GetCurrentMethod().Name); try { context.CreateProject(); context.WriteFileToProject("solidity\\StandardContract.abi", TestContracts.StandardContract.ABI); context.WriteFileToProject("solidity\\StandardContract.bin", TestContracts.StandardContract.ByteCode); var generatorConfig = new ABICollectionConfiguration { ABIConfigurations = new List <ABIConfiguration> { new ABIConfiguration { ContractName = "StandardContractA", ABIFile = "solidity\\StandardContract.abi", BaseOutputPath = context.TargetProjectFolder } } }; generatorConfig.SaveToJson(context.TargetProjectFolder); //when var config = factory.FromProject(context.TargetProjectFolder, context.OutputAssemblyName).ToList(); //then Assert.Equal(1, config.Count); var abiConfig = config.ElementAt(0); Assert.NotNull(abiConfig); Assert.Equal(CodeGenLanguage.CSharp, abiConfig.CodeGenLanguage); Assert.Equal("StandardContractA", abiConfig.ContractName); Assert.Equal(JsonConvert.SerializeObject(TestContracts.StandardContract.GetContractAbi()), JsonConvert.SerializeObject(abiConfig.ContractABI)); Assert.Equal(TestContracts.StandardContract.ByteCode, abiConfig.ByteCode); Assert.Equal(context.TargetProjectFolder, abiConfig.BaseOutputPath); Assert.Equal(Path.GetFileNameWithoutExtension(context.OutputAssemblyName), abiConfig.BaseNamespace); Assert.Equal("StandardContractA.CQS", abiConfig.CQSNamespace); Assert.Equal("StandardContractA.DTO", abiConfig.DTONamespace); Assert.Equal("StandardContractA.Service", abiConfig.ServiceNamespace); } finally { context.CleanUp(); } }
public static void CreateTestGeneratorConfigFile(string outputFilePath) { var config = new ABICollectionConfiguration { ABIConfigurations = new List <ABIConfiguration> { new ABIConfiguration { ContractName = "StandardContract", ABIFile = "StandardContract.abi", BinFile = "StandardContract.bin" } } }; config.SaveToJson(outputFilePath); }
public void GivenRelativeAbiPathInProjectParent() { //given var factory = new GeneratorConfigurationFactory(); var context = new ProjectTestContext(this.GetType().Name, MethodBase.GetCurrentMethod().Name); try { context.CreateProject(); context.WriteFileToProject("..\\StandardContract.abi", TestContracts.StandardContract.ABI); var generatorConfig = new ABICollectionConfiguration { ABIConfigurations = new List <ABIConfiguration> { new ABIConfiguration { ContractName = "StandardContractA", ABIFile = "..\\StandardContract.abi", BaseOutputPath = context.TargetProjectFolder } } }; generatorConfig.SaveToJson(context.TargetProjectFolder); //when var config = factory.FromProject(context.TargetProjectFolder, context.OutputAssemblyName).ToList(); //then Assert.Equal(1, config.Count); var abiConfig = config.First(); Assert.NotNull(abiConfig); Assert.Equal(CodeGenLanguage.CSharp, abiConfig.CodeGenLanguage); Assert.Equal("StandardContractA", abiConfig.ContractName); Assert.Equal(JsonConvert.SerializeObject(TestContracts.StandardContract.GetContractAbi()), JsonConvert.SerializeObject(abiConfig.ContractABI)); } finally { context.CleanUp(); } }
private static IEnumerable <ContractProjectGenerator> CreateStubConfiguration() { var config = new ABICollectionConfiguration { ABIConfigurations = new List <ABIConfiguration> { new ABIConfiguration { ABI = TestContracts.StandardContract.ABI, ByteCode = TestContracts.StandardContract.ByteCode, ContractName = "StandardContract", BaseOutputPath = "c:/Temp", BaseNamespace = "DefaultNamespace", ServiceNamespace = "StandardContract.Service", DTONamespace = "StandardContract.DTO", CQSNamespace = "StandardContract.CQS", CodeGenLanguage = CodeGenLanguage.CSharp } } }; return(config.GetContractProjectGenerators("DefaultNamespace", "c:/Temp")); }