< Summary

Information
Class: EF.Blockchain.Server.Mappers.BlockMapper
Assembly: EF.Blockchain.Server
File(s): C:\dev\@web3\web3-001-ef-blockchain\backend\EF.Blockchain\src\EF.Blockchain.Server\Mappers\BlockMapper.cs
Line coverage
93%
Covered lines: 31
Uncovered lines: 2
Coverable lines: 33
Total lines: 48
Line coverage: 93.9%
Branch coverage
50%
Covered branches: 6
Total branches: 12
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
ToDomain(...)50%6693.75%
ToDto(...)50%6694.11%

File(s)

C:\dev\@web3\web3-001-ef-blockchain\backend\EF.Blockchain\src\EF.Blockchain.Server\Mappers\BlockMapper.cs

#LineLine coverage
 1using EF.Blockchain.Domain;
 2using EF.Blockchain.Server.Dtos;
 3
 4namespace EF.Blockchain.Server.Mappers;
 5
 6public static class BlockMapper
 7{
 8    public static Block ToDomain(BlockDto dto)
 169    {
 1610        if (dto == null)
 011            return null;
 12
 1613        var transactions = dto.Transactions?
 1614            .Select(TransactionMapper.ToDomain)
 1615            .ToList() ?? new List<Transaction>();
 16
 1617        return new Block(
 1618            index: dto.Index,
 1619            previousHash: dto.PreviousHash,
 1620            transactions: transactions,
 1621            timestamp: dto.Timestamp,
 1622            hash: dto.Hash,
 1623            nonce: dto.Nonce,
 1624            miner: dto.Miner
 1625        );
 1626    }
 27
 28    public static BlockDto ToDto(Block domain)
 3229    {
 3230        if (domain == null)
 031            return null;
 32
 3233        var transactions = domain.Transactions?
 3234            .Select(TransactionMapper.ToDto)
 3235            .ToList() ?? new List<TransactionDto>();
 36
 3237        return new BlockDto
 3238        {
 3239            Index = domain.Index,
 3240            PreviousHash = domain.PreviousHash,
 3241            Transactions = transactions,
 3242            Timestamp = domain.Timestamp,
 3243            Hash = domain.Hash,
 3244            Nonce = domain.Nonce,
 3245            Miner = domain.Miner
 3246        };
 3247    }
 48}