{"id":19903243,"url":"https://github.com/nethereum/nethereum.contracts.integrationtester","last_synced_at":"2025-11-25T11:02:36.198Z","repository":{"id":89828885,"uuid":"126830566","full_name":"Nethereum/Nethereum.Contracts.IntegrationTester","owner":"Nethereum","description":"Nethereum.Contracts.IntegrationTester","archived":false,"fork":false,"pushed_at":"2018-08-07T11:14:50.000Z","size":33,"stargazers_count":1,"open_issues_count":5,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-11T21:24:49.233Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Nethereum.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-26T13:09:14.000Z","updated_at":"2018-08-07T11:14:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"cf94bc5e-0eb5-4bc7-ad29-a0550f8e3117","html_url":"https://github.com/Nethereum/Nethereum.Contracts.IntegrationTester","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nethereum%2FNethereum.Contracts.IntegrationTester","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nethereum%2FNethereum.Contracts.IntegrationTester/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nethereum%2FNethereum.Contracts.IntegrationTester/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nethereum%2FNethereum.Contracts.IntegrationTester/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Nethereum","download_url":"https://codeload.github.com/Nethereum/Nethereum.Contracts.IntegrationTester/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241330760,"owners_count":19945230,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T20:22:43.292Z","updated_at":"2025-11-25T11:02:31.159Z","avatar_url":"https://github.com/Nethereum.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nethereum Integration Tester\n\nThe Nethereum Integration Tester provides a simple way to test your smart contracts, message input, outputs and events using a \"BDD style\".\n\nThe aim is to provide a way to black box test complex requirements driven by data messages, focusing on business logic but also providing a readable output, which could be exported for reporting, validation and requirement matching.\n\n## How does it work?\n\nGiven a simple default setup scenario as follows:\n\n```csharp\npublic class DefaultScenario\n{\n    public static string ReceiverAddress = \"0x31230d2cce102216644c59daE5baed380d84830c\";\n\n    public static StandardTokenDeployment GetDeploymentMessage()\n    {\n        return new StandardTokenDeployment()\n        {\n            InitialAmount = 10000000,\n            TokenName = \"TST\",\n            TokenSymbol = \"TST\",\n            DecimalUnits = 18,\n            FromAddress = DefaultTestAccountConstants.Address\n        };\n    }\n\n    public static BalanceOfFunction GetBalanceOfOwnerMessage()\n    {\n        return new BalanceOfFunction()\n        {\n            Owner = DefaultTestAccountConstants.Address\n        };\n    }\n\n}\n```\nIn which we setup the default data for deployment of a standard token smart contract, and a simple message to query the balance of the owner.\n\nWe could create a simple XUnit Theory as follows:\n\n```csharp\n[Theory]\n[InlineData(10000)]\n[InlineData(5000)]\n[InlineData(300)]\npublic async Task AfterDeployment_BalanceOwner_ShouldBeTheSameAsInitialSupply(int initialSupply)\n{\n    var contractDeploymentDefault = DefaultScenario.GetDeploymentMessage();\n    contractDeploymentDefault.InitialAmount = initialSupply;\n\n    GivenADeployedContract(contractDeploymentDefault);\n\n    var balanceOfExpecedResult = new BalanceOfOutputDTO() { Balance = initialSupply };\n\n    WhenQueryingThen(DefaultScenario.GetBalanceOfOwnerMessage(), balanceOfExpecedResult);\n}\n```\n\nWe can see here two helper methods:\n\n* **GivenADeployedContract** : This method deploys a contract using the message provided and log the input.\n* **WhenQueryingThen**: This method first makes a contract query and assert the results based on a provided expectation.\n\n## Xunit Output:\n\nThe xunit ouput of the test, can help us visualised the data and ensure the requirements are matched.\n\n```\nTest Name:\tStandardToken.IntegrationTests.StandardContractTest.AfterDeployment_BalanceOwner_ShouldBeTheSameAsInitialSupply(initialSupply: 300)\nTest Outcome:\tPassed\nResult StandardOutput:\t\nGiven I Deploy Contract:\nnew MyContractNameDeployment()\n{\n    AmountToSend = new BigInteger()\n    {\n        _sign = 0\n        _bits = null\n    }\n    Gas = null\n    GasPrice = null\n    FromAddress = \"0x12890D2cce102216644c59daE5baed380d84830c\"\n    ByteCode = \"6060604052341561000f57600080fd5b6040516107ae3803806107ae833981016040528080519190602001805182019190602001805191906020018051600160a060020a03331660009081526001602052604081208790558690559091019050600383805161007292916020019061009f565b506004805460ff191660ff8416179055600581805161009592916020019061009f565b505050505061013a565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106100e057805160ff191683800117855561010d565b8280016001018555821561010d579182015b8281111561010d5782518255916020019190600101906100f2565b5061011992915061011d565b5090565b61013791905b808211156101195760008155600101610123565b90565b610665806101496000396000f3006060604052600436106100ae5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100b3578063095ea7b31461013d57806318160ddd1461017357806323b872dd1461019857806327e235e3146101c0578063313ce567146101df5780635c6581651461020857806370a082311461022d57806395d89b411461024c578063a9059cbb1461025f578063dd62ed3e14610281575b600080fd5b34156100be57600080fd5b6100c66102a6565b60405160208082528190810183818151815260200191508051906020019080838360005b838110156101025780820151838201526020016100ea565b50505050905090810190601f16801561012f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561014857600080fd5b61015f600160a060020a0360043516602435610344565b604051901515815260200160405180910390f35b341561017e57600080fd5b6101866103b0565b60405190815260200160405180910390f35b34156101a357600080fd5b61015f600160a060020a03600435811690602435166044356103b6565b34156101cb57600080fd5b610186600160a060020a03600435166104bc565b34156101ea57600080fd5b6101f26104ce565b60405160ff909116815260200160405180910390f35b341561021357600080fd5b610186600160a060020a03600435811690602435166104d7565b341561023857600080fd5b610186600160a060020a03600435166104f4565b341561025757600080fd5b6100c661050f565b341561026a57600080fd5b61015f600160a060020a036004351660243561057a565b341561028c57600080fd5b610186600160a060020a036004358116906024351661060e565b60038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561033c5780601f106103115761010080835404028352916020019161033c565b820191906000526020600020905b81548152906001019060200180831161031f57829003601f168201915b505050505081565b600160a060020a03338116600081815260026020908152604080832094871680845294909152808220859055909291907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259085905190815260200160405180910390a350600192915050565b60005481565b600160a060020a0380841660008181526002602090815260408083203390951683529381528382205492825260019052918220548390108015906103fa5750828110155b151561040557600080fd5b600160a060020a038085166000908152600160205260408082208054870190559187168152208054849003905560001981101561046a57600160a060020a03808616600090815260026020908152604080832033909416835292905220805484900390555b83600160a060020a031685600160a060020a03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405190815260200160405180910390a3506001949350505050565b60016020526000908152604090205481565b60045460ff1681565b600260209081526000928352604080842090915290825290205481565b600160a060020a031660009081526001602052604090205490565b60058054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561033c5780601f106103115761010080835404028352916020019161033c565b600160a060020a033316600090815260016020526040812054829010156105a057600080fd5b600160a060020a033381166000818152600160205260408082208054879003905592861680825290839020805486019055917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9085905190815260200160405180910390a350600192915050565b600160a060020a039182166000908152600260209081526040808320939094168252919091522054905600a165627a7a723058201145b253e40a502d8bd264f98d66de641dec0c9e4a25e35eaba523821e0fb6ad0029\"\n    InitialAmount = new BigInteger()\n    {\n        _sign = 300\n        _bits = null\n    }\n    TokenName = \"TST\"\n    DecimalUnits = 18\n    TokenSymbol = \"TST\"\n}\nWhen Querying Function:\nnew BalanceOfFunction()\n{\n    AmountToSend = new BigInteger()\n    {\n        _sign = 0\n        _bits = null\n    }\n    Gas = null\n    GasPrice = null\n    FromAddress = null\n    Owner = \"0x12890D2cce102216644c59daE5baed380d84830c\"\n}\nThen the Expected result is:\nnew BalanceOfOutputDTO()\n{\n    Balance = new BigInteger()\n    {\n        _sign = 300\n        _bits = null\n    }\n}\n\n```\n\n## Transactions and Events\n\nAnother common situation is the testing of Transactions and Events, this example demonstrates how can you easily validate the \"Transfer\" event associated with a transaction, and query the balance afterwards.\n\n```csharp\n[Theory]\n[InlineData(10000)]\n[InlineData(5000)]\n[InlineData(300)]\npublic async Task Transfering_ShouldIncreaseTheBalanceOfReceiver(int valueToSend)\n{\n  var contractDeploymentDefault = DefaultScenario.GetDeploymentMessage();\n            \n    Assert.False(valueToSend \u003e contractDeploymentDefault.InitialAmount, \"value to send is bigger than the total supply, please adjust the test data\");\n\n    GivenADeployedContract(contractDeploymentDefault);\n\n    var receiver = DefaultScenario.ReceiverAddress;\n\n    var transferMessage = new TransferFunction()\n    {\n        Value = valueToSend,\n        FromAddress = DefaultTestAccountConstants.Address,\n        To = receiver,\n    };\n\n    var expectedEvent = new TransferEventDTO()\n    {\n        From = DefaultTestAccountConstants.Address.ToLower(), //lower case return from geth\n        To = DefaultScenario.ReceiverAddress.ToLower(),\n        Value = valueToSend\n    };\n\n    GivenATransaction(transferMessage).\n                                ThenExpectAnEvent(expectedEvent);\n\n    var queryBalanceReceiverMessage = new BalanceOfFunction() {Owner = DefaultScenario.ReceiverAddress};\n    var balanceOfExpectedResult = new BalanceOfOutputDTO() {Balance = valueToSend};\n\n    WhenQuerying\u003cBalanceOfFunction, BalanceOfOutputDTO\u003e(queryBalanceReceiverMessage)\n                                                          .ThenExpectResult(balanceOfExpectedResult);         \n}\n\n```\n\nWe can see here the extra helper methods:\n\n* **GivenATransaction** : This method sends a transaction.\n* **ThenExpectAnEvent** : This methods validates an event of the same type and result exists\n* **WhenQuerying\u003cBalanceOfFunction, BalanceOfOutputDTO\u003e**: This method makes a call / query to the contract\n* **ThenExpectResult**: This method validates the result of the query / call matches the expected value\n\n## Installation requirements.\nThere is no nuget package for this yet, for now the only option is to download the project and use the sample as a reference to get started.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnethereum%2Fnethereum.contracts.integrationtester","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnethereum%2Fnethereum.contracts.integrationtester","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnethereum%2Fnethereum.contracts.integrationtester/lists"}