Skip to content
Snippets Groups Projects
Commit 112aeaa4 authored by Klaus Fischer's avatar Klaus Fischer
Browse files

Extracted Router from Sender

parent cf2197a0
No related branches found
No related tags found
1 merge request!6Routing Api
namespace FitConnect; using FitConnect.Models;
namespace FitConnect;
public interface IRouter { public interface IRouter {
/// <summary>
/// Finding areas for the filter with paging
/// </summary>
/// <param name="filter">Search string for the area, use * as wildcard</param>
/// <param name="totalCount">out var for the total count</param>
/// <param name="offset"></param>
/// <param name="limit"></param>
/// <example>
/// var areas = GetAreas("Erlang*", out var _, 0, 10)
/// </example>
/// <returns></returns>
public IEnumerable<Area> GetAreas(string filter, out int totalCount, int offset = 0,
int limit = 100);
public Task<List<FitConnect.Services.Models.v1.Routes.Route>> FindDestinationsAsync( public Task<List<FitConnect.Services.Models.v1.Routes.Route>> FindDestinationsAsync(
string leiaKey, string? ags = null, string leiaKey, string? ags = null,
string? ars = null, string? ars = null,
......
...@@ -30,17 +30,4 @@ public interface ISender : IFitConnectClient { ...@@ -30,17 +30,4 @@ public interface ISender : IFitConnectClient {
public ISenderWithDestination WithDestination(string destinationId); public ISenderWithDestination WithDestination(string destinationId);
/// <summary>
/// Finding areas for the filter with paging
/// </summary>
/// <param name="filter">Search string for the area, use * as wildcard</param>
/// <param name="totalCount">out var for the total count</param>
/// <param name="offset"></param>
/// <param name="limit"></param>
/// <example>
/// var areas = GetAreas("Erlang*", out var _, 0, 10)
/// </example>
/// <returns></returns>
public IEnumerable<Area> GetAreas(string filter, out int totalCount, int offset = 0,
int limit = 100);
} }
...@@ -17,4 +17,19 @@ public class Router : IRouter { ...@@ -17,4 +17,19 @@ public class Router : IRouter {
string? areaId = null) => await RouteService.GetDestinationIdAsync(leiaKey, ags, ars, areaId); string? areaId = null) => await RouteService.GetDestinationIdAsync(leiaKey, ags, ars, areaId);
/// <summary>
/// Finding Areas
/// </summary>
/// <param name="filter"></param>
/// <param name="totalCount"></param>
/// <param name="offset"></param>
/// <param name="limit"></param>
/// <returns></returns>
public IEnumerable<Area> GetAreas(string filter, out int totalCount, int offset = 0,
int limit = 100) {
var dto = RouteService.GetAreas(filter, offset, limit).Result;
totalCount = dto?.TotalCount ?? 0;
return dto?.Areas ?? new List<Area>();
}
} }
...@@ -225,20 +225,6 @@ public class Sender : FitConnectClient, ISender, ISenderWithDestination, ...@@ -225,20 +225,6 @@ public class Sender : FitConnectClient, ISender, ISenderWithDestination,
return JsonConvert.SerializeObject(metaData); return JsonConvert.SerializeObject(metaData);
} }
/// <summary>
/// Finding Areas
/// </summary>
/// <param name="filter"></param>
/// <param name="totalCount"></param>
/// <param name="offset"></param>
/// <param name="limit"></param>
/// <returns></returns>
public IEnumerable<Area> GetAreas(string filter, out int totalCount, int offset = 0,
int limit = 100) {
var dto = RouteService.GetAreas(filter, offset, limit).Result;
totalCount = dto?.TotalCount ?? 0;
return dto?.Areas ?? new List<Area>();
}
/// <summary> /// <summary>
/// Uploading the encrypted data to the server /// Uploading the encrypted data to the server
......
...@@ -68,4 +68,11 @@ public class RoutingTests { ...@@ -68,4 +68,11 @@ public class RoutingTests {
route.DestinationId.Should().NotBeNull(); route.DestinationId.Should().NotBeNull();
route.DestinationSignature.Should().NotBeNull(); route.DestinationSignature.Should().NotBeNull();
} }
[Test]
public void GetAreas_ShouldGetAreasFromServer() {
// Arrange
var areas = _router.GetAreas("Furth*", out var _);
areas.Should().HaveCountGreaterThan(0);
}
} }
...@@ -169,12 +169,6 @@ public class SenderTestHappyPath : SenderTestBase { ...@@ -169,12 +169,6 @@ public class SenderTestHappyPath : SenderTestBase {
submission.Should().NotBeNull(); submission.Should().NotBeNull();
} }
[Test]
public void GetAreas_ShouldGetAreasFromServer() {
// Arrange
var areas = Sender.GetAreas("Furth*", out var _);
areas.Should().HaveCountGreaterThan(0);
}
[Test] [Test]
public void GetDestinations_ShouldGetDestinationsFromServer() { public void GetDestinations_ShouldGetDestinationsFromServer() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment