< Summary

Information
Class: MyNet.Geography.CountryExtensions
Assembly: MyNet.Geography
File(s): https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Geography/Extensions/CountryExtensions.cs
Tag: 323_28699572109
Line coverage
0%
Covered lines: 0
Uncovered lines: 2
Coverable lines: 2
Total lines: 32
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
GetFlag(...)0%2040%

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Geography/Extensions/CountryExtensions.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="CountryExtensions.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7using System;
 8using System.IO;
 9
 10#pragma warning disable IDE0130 // Namespace does not match folder structure
 11namespace MyNet.Geography;
 12#pragma warning restore IDE0130 // Namespace does not match folder structure
 13
 14public static class CountryExtensions
 15{
 16    extension(Country country)
 17    {
 18        /// <summary>
 19        /// Retrieves the flag of the specified country in the given size using the provided flag provider. The flag is 
 20        /// </summary>
 21        /// <param name="provider">The flag provider to use for retrieving the flag.</param>
 22        /// <param name="size">The size of the flag to retrieve.</param>
 23        /// <returns>A MemoryStream containing the flag image data.</returns>
 24        /// <exception cref="InvalidOperationException">Thrown if the flag cannot be found.</exception>
 25        public MemoryStream GetFlag(ICountryFlagProvider provider, FlagSize size)
 26        {
 027            var bytes = provider.GetBytes(country, size);
 028            return bytes is not { Length: > 0 } ? throw new InvalidOperationException($"Flag not found for country '{cou
 29        }
 30    }
 31}
 32