< Summary

Information
Class: MyNet.Google.Maps.GoogleMapsHelper
Assembly: MyNet.Google
File(s): https://raw.githubusercontent.com/sandre58/MyNet/5aaaab311aa14541478b9e402357d98b657a23e4/src/MyNet.Google/Maps/GoogleMapsHelper.cs
Tag: 342_31701152804
Line coverage
92%
Covered lines: 13
Uncovered lines: 1
Coverable lines: 14
Total lines: 54
Line coverage: 92.8%
Branch coverage
100%
Covered branches: 8
Total branches: 8
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
OpenGoogleMaps(...)100%210%
GetGoogleMapsUrl(...)100%22100%
ToDictionary(...)100%66100%

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/5aaaab311aa14541478b9e402357d98b657a23e4/src/MyNet.Google/Maps/GoogleMapsHelper.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="GoogleMapsHelper.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7using System;
 8using System.Collections.Generic;
 9using System.Linq;
 10using MyNet.Primitives.Helpers;
 11
 12namespace MyNet.Google.Maps;
 13
 14public static class GoogleMapsHelper
 15{
 16    public const string Url = "https://maps.google.com/maps";
 17
 018    public static void OpenGoogleMaps(GoogleMapsSettings settings) => ProcessHelper.Start(GetGoogleMapsUrl(settings));
 19
 20    public static string GetGoogleMapsUrl(GoogleMapsSettings settings)
 21    {
 1222        var url = Url;
 1223        var parameters = settings.ToDictionary();
 1224        if (parameters.Count != 0)
 25        {
 926            url += $"?{string.Join("&", settings.ToDictionary().Select(x => $"{x.Key}={x.Value}"))}";
 27        }
 28
 1229        return url;
 30    }
 31
 32    private static Dictionary<string, string> ToDictionary(this GoogleMapsSettings settings)
 33    {
 2134        var result = new Dictionary<string, string>();
 35
 2136        if (settings.HideLeftPanel)
 37        {
 638            result.Add("output", "embed");
 39        }
 40
 2141        if (!string.IsNullOrEmpty(settings.Address))
 42        {
 1243            result.Add("q", settings.Address.Replace(" ", "+", StringComparison.OrdinalIgnoreCase));
 44        }
 45
 2146        if (settings.Coordinates is not null)
 47        {
 648            result.Add("ll", $"{settings.Coordinates.Latitude},{settings.Coordinates.Longitude}");
 49        }
 50
 2151        return result;
 52    }
 53}
 54