< Summary

Information
Class: LifeChart.Infrastructure.CrisisResources.StaticCrisisResourceService
Assembly: LifeChart.Infrastructure
File(s): /home/runner/work/lifechart/lifechart/src/LifeChart.Infrastructure/CrisisResources/StaticCrisisResourceService.cs
Tag: 113_29159449707
Line coverage
0%
Covered lines: 0
Uncovered lines: 40
Coverable lines: 40
Total lines: 54
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%210%
GetForRegionAsync(...)0%620%

File(s)

/home/runner/work/lifechart/lifechart/src/LifeChart.Infrastructure/CrisisResources/StaticCrisisResourceService.cs

#LineLine coverage
 1using LifeChart.Application.DTOs;
 2using LifeChart.Application.Interfaces;
 3
 4namespace LifeChart.Infrastructure.CrisisResources;
 5
 6public class StaticCrisisResourceService : ICrisisResourceService
 7{
 08    private static readonly Dictionary<string, List<CrisisResourceDto>> Resources = new()
 09    {
 010        ["DE"] =
 011        [
 012            new("Telefonseelsorge", "0800 111 0 111", "https://www.telefonseelsorge.de", true),
 013            new("Telefonseelsorge", "0800 111 0 222", "https://www.telefonseelsorge.de", true)
 014        ],
 015        ["AT"] =
 016        [
 017            new("Telefonseelsorge Österreich", "142", "https://www.telefonseelsorge.at", true)
 018        ],
 019        ["CH"] =
 020        [
 021            new("Die Dargebotene Hand", "143", "https://www.143.ch", true)
 022        ],
 023        ["GB"] =
 024        [
 025            new("Samaritans", "116 123", "https://www.samaritans.org", true)
 026        ],
 027        ["US"] =
 028        [
 029            new("988 Suicide & Crisis Lifeline", "988", "https://988lifeline.org", true)
 030        ],
 031        ["AU"] =
 032        [
 033            new("Lifeline Australia", "13 11 14", "https://www.lifeline.org.au", true)
 034        ],
 035        ["CA"] =
 036        [
 037            new("Crisis Services Canada", "1-833-456-4566", "https://www.crisisservicescanada.ca", true)
 038        ]
 039    };
 40
 041    private static readonly List<CrisisResourceDto> FallbackResources =
 042    [
 043        new("findahelpline.com", "", "https://findahelpline.com", true)
 044    ];
 45
 46    public Task<IEnumerable<CrisisResourceDto>> GetForRegionAsync(string regionCode)
 47    {
 048        var result = Resources.TryGetValue(regionCode.ToUpperInvariant(), out var resources)
 049            ? resources
 050            : FallbackResources;
 51
 052        return Task.FromResult<IEnumerable<CrisisResourceDto>>(result);
 53    }
 54}