public void WhenContractNameIsNotSpecifiedUsesAbiFileName()
        {
            //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);
                context.WriteFileToProject("StandardContract.bin", TestContracts.StandardContract.ByteCode);

                //when
                var config = factory.FromAbi(
                    null, //contract name
                    "StandardContract.abi",
                    "StandardContract.bin",
                    Path.GetFileNameWithoutExtension(context.OutputAssemblyName),
                    context.TargetProjectFolder).ToList();

                //then
                Assert.Equal(1, config.Count);
                var abiConfig = config.First();
                Assert.Equal("StandardContract", abiConfig.ContractName);
            }
            finally
            {
                context.CleanUp();
            }
        }
示例#2
0
        public void GeneratesConfigurationFromAbiFilesInProject()
        {
            //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);
                context.WriteFileToProject("StandardContract.bin", TestContracts.StandardContract.ByteCode);

                //when
                var config = factory.FromAbi(
                    "StandardContract",
                    "StandardContract.abi",
                    "StandardContract.bin",
                    Path.GetFileNameWithoutExtension(context.OutputAssemblyName),
                    context.TargetProjectFolder).ToList();

                //then
                Assert.Equal(1, config.Count);
                var abiConfig = config.ElementAt(0);
                Assert.NotNull(abiConfig);
                Assert.Equal(CodeGenLanguage.CSharp, abiConfig.CodeGenLanguage);
                Assert.Equal("StandardContract", 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("StandardContract.ContractDefinition", abiConfig.CQSNamespace);
                Assert.Equal("StandardContract.ContractDefinition", abiConfig.DTONamespace);
                Assert.Equal("StandardContract", abiConfig.ServiceNamespace);
            }
            finally
            {
                context.CleanUp();
            }
        }