Exemple #1
0
        public void ResolveEmptyValuesWithDefaults_EmptyContractNameIsDefaultedToNameOfAbiFile()
        {
            //given
            var abiConfiguration = new ABIConfiguration {
                ABIFile = _abiFileAbsolutePath, ContractName = null
            };

            //when
            abiConfiguration.ResolveEmptyValuesWithDefaults("Sample.Contract", _projectPath);

            //then
            Assert.Equal("StandardContract", abiConfiguration.ContractName);
        }
Exemple #2
0
        public void ResolveEmptyValuesWithDefaults_WhenBinFileIsEmptyItWillBeFoundWhenInTheSameFolderAsAbi()
        {
            //given

            var abiConfiguration = new ABIConfiguration {
                ABIFile = _abiFileAbsolutePath, BinFile = null, ByteCode = null
            };

            //when
            abiConfiguration.ResolveEmptyValuesWithDefaults("Sample.Contract", _projectPath);

            //then
            Assert.Equal(TestContracts.StandardContract.ByteCode, abiConfiguration.ByteCode);
        }
Exemple #3
0
        public void ResolveEmptyValuesWithDefaults_BinFileCanBeARelativePath()
        {
            //given

            var abiConfiguration = new ABIConfiguration {
                ABIFile = _abiFileAbsolutePath, BinFile = "StandardContract.bin"
            };

            //when
            abiConfiguration.ResolveEmptyValuesWithDefaults("Sample.Contract", _projectPath);

            //then
            Assert.Equal(TestContracts.StandardContract.ByteCode, abiConfiguration.ByteCode);
        }
Exemple #4
0
        public void ResolveEmptyValuesWithDefaults_WhenAbiContentIsEmptyItIsReadFromAbiFile()
        {
            //given

            var abiConfiguration = new ABIConfiguration {
                ABI = null, ABIFile = _abiFileAbsolutePath
            };

            //when
            abiConfiguration.ResolveEmptyValuesWithDefaults("Sample.Contract", _projectPath);

            //then
            Assert.Equal(TestContracts.StandardContract.ABI, abiConfiguration.ABI);
        }
Exemple #5
0
        public void ResolveEmptyValuesWithDefaults_AbiFileCanBeRelativePath()
        {
            //given

            var abiConfiguration = new ABIConfiguration {
                ABI = null, ABIFile = Path.GetRelativePath(_projectPath, _abiFileAbsolutePath)
            };

            //when
            abiConfiguration.ResolveEmptyValuesWithDefaults("Sample.Contract", _projectPath);

            //then
            Assert.Equal(TestContracts.StandardContract.ABI, abiConfiguration.ABI);
        }
Exemple #6
0
        public void ResolveEmptyValuesWithDefaults_AbiFileCanBeInParentFolderOfTheProjectRoot()
        {
            //given
            var solidityFolder      = CreateSolidityFolderInParentOfProjectRoot();
            var abiInSolidityFolder = Path.Combine(solidityFolder, Path.GetFileName(_abiFileAbsolutePath));

            File.Copy(_abiFileAbsolutePath, abiInSolidityFolder, true);

            var abiConfiguration = new ABIConfiguration {
                ABI = null, ABIFile = "..\\solidity\\StandardContract.abi"
            };

            //when
            abiConfiguration.ResolveEmptyValuesWithDefaults("Sample.Contract", _projectPath);

            //then
            Assert.Equal(TestContracts.StandardContract.ABI, abiConfiguration.ABI);
        }
Exemple #7
0
        private void GenerateFilesForItem(ABIConfiguration item)
        {
            var generator = new ContractProjectGenerator(
                item.CreateContractABI(),
                item.ContractName,
                item.ByteCode,
                item.BaseNamespace,
                item.ServiceNamespace,
                item.CQSNamespace,
                item.DTONamespace,
                item.BaseOutputPath,
                Path.DirectorySeparatorChar.ToString(),
                item.CodeGenLanguage
                );

            var generatedFiles = generator.GenerateAll();

            _generatedFileWriter.WriteFiles(generatedFiles);
        }