Skip to content

Commit 6dd8bc6

Browse files
committed
Minor cleanup.
1 parent 18fd8e6 commit 6dd8bc6

3 files changed

Lines changed: 9 additions & 12 deletions

File tree

src/AzureMapsControl.Components/Map/IMapAdderService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
internal interface IMapAdderService : IMapService
66
{
7-
ValueTask AddMapAsync(Map map);
7+
public ValueTask AddMapAsync(Map map);
88

9-
ValueTask RemoveMapAsync(string mapId);
9+
public ValueTask RemoveMapAsync(string mapId);
1010
}
1111
}

src/AzureMapsControl.Components/Map/MapService.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ public Map Map
2323
{
2424
get
2525
{
26-
if (!string.IsNullOrEmpty(_latestMapId) && _maps.ContainsKey(_latestMapId))
26+
if (!string.IsNullOrEmpty(_latestMapId) && _maps.TryGetValue(_latestMapId, out var map))
2727
{
28-
return _maps[_latestMapId];
28+
return map;
2929
}
3030

31-
if (_maps.Count > 0)
31+
if (!_maps.IsEmpty)
3232
{
3333
return _maps.Values.First();
3434
}
@@ -41,10 +41,7 @@ public Map Map
4141

4242
public event MapReadyEvent OnMapReadyAsync;
4343

44-
public Map GetMap(string mapId)
45-
{
46-
return _maps.TryGetValue(mapId, out var map) ? map : null;
47-
}
44+
public Map GetMap(string mapId) => _maps.TryGetValue(mapId, out var map) ? map : null;
4845

4946
public async ValueTask AddMapAsync(Map map)
5047
{
@@ -66,7 +63,7 @@ public async ValueTask RemoveMapAsync(string mapId)
6663
_logger?.LogAzureMapsControlInfo(AzureMapLogEvent.MapService_AddMapAsync, "Removing map instance");
6764
_logger?.LogAzureMapsControlDebug(AzureMapLogEvent.MapService_AddMapAsync, $"Map ID: {mapId}");
6865

69-
if (_maps.TryRemove(mapId, out var removedMap))
66+
if (_maps.TryRemove(mapId, out _))
7067
{
7168
// If we're removing the latest map, update the latest map ID
7269
if (_latestMapId == mapId)

tests/AzureMapsControl.Components.Tests/Map/MapServiceMultipleMaps.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public void Should_ReturnNull_WhenNoMapsExist()
175175
}
176176

177177
[Fact]
178-
public async Task Should_ReturnNull_ForNonExistentMapId()
178+
public async Task Should_ReturnNull_ForNonExistentMapId_Async()
179179
{
180180
var service = new MapService(null);
181181
await service.AddMapAsync(new Map("map1"));
@@ -190,7 +190,7 @@ public async Task Should_HandleRapidAddRemoveSequence_Async()
190190
{
191191
var service = new MapService(null);
192192

193-
for (int i = 0; i < 5; i++)
193+
for (var i = 0; i < 5; i++)
194194
{
195195
var map = new Map($"map{i}");
196196
await service.AddMapAsync(map);

0 commit comments

Comments
 (0)