Thank you for your interest in contributing to BiatecTokensApi! This document provides guidelines and instructions for contributing to the project.
By participating in this project, you agree to maintain a respectful and inclusive environment for all contributors.
- Fork the repository on GitHub
- Clone your fork locally
- Create a new branch for your feature or bug fix
- Make your changes
- Submit a pull request
- .NET 8.0 SDK or later
- Visual Studio 2022 or Visual Studio Code
- Docker (optional, for containerized deployment)
# Restore dependencies
dotnet restore BiatecTokensApi.sln
# Build the solution
dotnet build BiatecTokensApi.sln --configuration Release
# Build in Debug mode with XML documentation
dotnet build BiatecTokensApi.sln --configuration Debug# Run the API
dotnet run --project BiatecTokensApi/BiatecTokensApi.csproj
# The API will be available at https://localhost:7000
# Swagger documentation: https://localhost:7000/swaggerThe API requires configuration for:
- Algorand networks and authentication (ARC-0014)
- IPFS integration for ARC3 metadata
- EVM blockchain settings for ERC20 tokens
For local development, use user secrets:
dotnet user-secrets set "App:Account" "your-mnemonic-phrase"
dotnet user-secrets set "IPFSConfig:Username" "your-ipfs-username"
dotnet user-secrets set "IPFSConfig:Password" "your-ipfs-password"The project uses NUnit for unit and integration testing. We maintain high test coverage standards to ensure code quality and reliability.
# Run all tests
dotnet test BiatecTokensTests/BiatecTokensTests.csproj --verbosity normal
# Run tests excluding integration tests that require real endpoints
dotnet test BiatecTokensTests/BiatecTokensTests.csproj \
--filter "FullyQualifiedName!~RealEndpoint" \
--verbosity normal# Run tests with code coverage collection
dotnet test BiatecTokensTests/BiatecTokensTests.csproj \
--collect:"XPlat Code Coverage" \
--filter "FullyQualifiedName!~RealEndpoint" \
--verbosity normal
# Generate HTML coverage report (requires reportgenerator tool)
dotnet tool install --global dotnet-reportgenerator-globaltool
reportgenerator \
-reports:"**/coverage.cobertura.xml" \
-targetdir:"coveragereport" \
-reporttypes:Html# Run specific test class
dotnet test BiatecTokensTests/BiatecTokensTests.csproj \
--filter "FullyQualifiedName~TokenServiceTests" \
--verbosity detailed
# Run specific test method
dotnet test BiatecTokensTests/BiatecTokensTests.csproj \
--filter "FullyQualifiedName~TokenServiceTests.SpecificTestMethod" \
--verbosity detailedThe project enforces code coverage thresholds in CI to maintain and improve code quality. We are on an incremental path to reach target coverage levels.
Current Thresholds (enforced in CI):
- Line Coverage: Minimum 15%
- Branch Coverage: Minimum 8%
Target Coverage (to be reached incrementally):
- Line Coverage: 80%
- Branch Coverage: 70%
Pull requests that reduce coverage below the current thresholds will fail CI checks. We encourage contributors to add comprehensive tests with each PR to help us reach the target coverage levels.
Coverage Progress:
- β Initial: 11.66% line / 3.32% branch
- β Phase 1: 15% line / 8% branch (Current - validation & models)
- π― Phase 2: 35% line / 25% branch (Next milestone - service layer with mocks)
- π― Phase 3: 60% line / 50% branch (Integration tests)
- π― Phase 4: 80% line / 70% branch (Target - comprehensive coverage)
Follow the AAA (Arrange-Act-Assert) pattern:
[Test]
public void MethodName_Scenario_ExpectedResult()
{
// Arrange - Set up test data and dependencies
var mockService = new Mock<IService>();
var sut = new SystemUnderTest(mockService.Object);
// Act - Execute the method being tested
var result = sut.MethodName(input);
// Assert - Verify the expected outcome
Assert.That(result, Is.Not.Null);
Assert.That(result.Success, Is.True);
}Use descriptive test names that clearly indicate:
- The method being tested
- The scenario or condition
- The expected outcome
Examples:
CreateToken_ValidRequest_ReturnsSuccessCreateToken_NullRequest_ThrowsArgumentNullExceptionCreateToken_InvalidChainId_ReturnsError
Use Moq for mocking dependencies:
var mockLogger = new Mock<ILogger<MyService>>();
var mockConfig = new Mock<IOptionsMonitor<MyConfig>>();
mockConfig.Setup(x => x.CurrentValue).Returns(new MyConfig { /* setup */ });- Unit Tests: Test individual methods and classes in isolation with mocked dependencies
- Integration Tests: Test interactions between components
- Real Endpoint Tests: Tests that require actual network connections (excluded from CI by default)
The test project is organized as follows:
BiatecTokensTests/
βββ ApiIntegrationTests.cs # End-to-end API tests
βββ Erc20TokenTests.cs # ERC20 token functionality tests
βββ TokenServiceTests.cs # Token service unit tests
βββ TokenControllerTests.cs # Controller endpoint tests
βββ IPFSRepositoryTests.cs # IPFS integration tests
βββ IPFSRepositoryIntegrationTests.cs # IPFS integration with mocks
βββ IPFSRepositoryRealEndpointTests.cs # Real IPFS endpoint tests (excluded from CI)
βββ TDDExampleTests.cs # TDD examples and patterns
βββ TestHelper.cs # Shared test utilities
In Visual Studio:
- Open Test Explorer (Test > Test Explorer)
- Right-click a test and select "Debug"
In Visual Studio Code:
- Install the ".NET Core Test Explorer" extension
- Use the Test Explorer sidebar to run/debug tests
From command line:
# Run tests in debug mode with detailed output
dotnet test BiatecTokensTests/BiatecTokensTests.csproj \
--verbosity detailed \
--logger "console;verbosity=detailed"-
Create a feature branch from
mastergit checkout -b feature/your-feature-name
-
Make your changes following the code style guidelines
-
Add tests for new functionality
- Ensure all new code has adequate test coverage
- Run tests locally before submitting
-
Update documentation if needed
- Update XML documentation comments
- Update README.md if adding new features
- Update OPENAPI.md for API changes
-
Run all checks locally
# Build dotnet build BiatecTokensApi.sln --configuration Release # Run tests with coverage dotnet test BiatecTokensTests/BiatecTokensTests.csproj \ --collect:"XPlat Code Coverage" \ --filter "FullyQualifiedName!~RealEndpoint"
-
Commit your changes with clear, descriptive commit messages
git add . git commit -m "Add feature: description of change"
-
Push to your fork
git push origin feature/your-feature-name
-
Open a Pull Request on GitHub
- Provide a clear title and description
- Reference any related issues
- Tag reviewers if needed
Before your pull request can be merged, it must:
- β Pass all CI checks (build, tests, coverage thresholds)
- β Meet code coverage thresholds (current: 15% line, 8% branch; target: 80% line, 70% branch)
- β Receive at least 1 approval from a maintainer or code owner
- β Have all conversations resolved
- β
Have no merge conflicts with
master - β Include tests for new functionality
- β Follow the project's code style
- β Have clear, descriptive commit messages
- β Include updated documentation if needed
Note: Branch protection rules should be configured by repository administrators to enforce these requirements. See BRANCH_PROTECTION.md for configuration details.
Follow standard C# naming conventions:
- PascalCase for public members, classes, methods, properties
- camelCase for private fields, local variables, parameters
- Prefix private fields with underscore:
_privateField
- Add XML documentation comments (
///) for all public APIs - Include
<summary>,<param>,<returns>, and<exception>tags - Documentation is generated in Debug builds to
doc/documentation.xml
Example:
/// <summary>
/// Creates a new ERC20 token with the specified parameters.
/// </summary>
/// <param name="request">The token creation request.</param>
/// <returns>The deployment response with transaction details.</returns>
/// <exception cref="ArgumentNullException">Thrown when request is null.</exception>
public async Task<TokenCreationResponse> CreateTokenAsync(CreateTokenRequest request)
{
// Implementation
}- Use explicit types instead of
varwhen type is not obvious - Enable and address nullable reference types warnings
- Keep methods focused and single-purpose
- Prefer composition over inheritance
- Use dependency injection for services
- Validate all input parameters
- Handle exceptions appropriately
- Log important operations and errors
- Never expose sensitive information in logs or errors
β οΈ Never commit secrets, API keys, or private keys- Use user secrets for local development
- Use environment variables for production
- Validate and sanitize all inputs
- Use proper authentication and authorization
- Follow blockchain security best practices
- Test on testnet before mainnet
If you have questions or need help:
- Check existing issues on GitHub
- Review the documentation in README.md and OPENAPI.md
- Ask questions in pull request discussions
- Review the custom instructions in
.github/copilot-instructions.md
By contributing to this project, you agree that your contributions will be licensed under the same license as the project.
Thank you for contributing to BiatecTokensApi! π