Add test cases
All checks were successful
Build, Push and Run Container / build (push) Successful in 27s
All checks were successful
Build, Push and Run Container / build (push) Successful in 27s
This commit is contained in:
@@ -12,7 +12,7 @@ public class MQTTClient : IHostedService
|
||||
|
||||
private readonly IMqttClient client;
|
||||
|
||||
public MQTTClient(ILogger<MQTTClient> logger, IOptions<MQTTClientConfiguration> options, IOptions<MQTTServerConfiguration> serverOptions, IMessageProcessor messageProcessor)
|
||||
public MQTTClient(ILogger<MQTTClient> logger, IOptions<MQTTClientConfiguration> options, IOptions<MQTTServerConfiguration> serverOptions, MessageProcessor messageProcessor)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.configuration = options.Value;
|
||||
|
||||
@@ -7,12 +7,7 @@ using SzakatsA.Result;
|
||||
|
||||
namespace ProofOfConcept.Services;
|
||||
|
||||
public interface IMessageProcessor
|
||||
{
|
||||
Task ProcessMessage(string vin, string field, string value);
|
||||
}
|
||||
|
||||
public class MessageProcessor : IMessageProcessor
|
||||
public class MessageProcessor
|
||||
{
|
||||
private readonly ILogger<MessageProcessor> logger;
|
||||
private MessageProcessorConfiguration configuration;
|
||||
@@ -89,7 +84,7 @@ public class MessageProcessor : IMessageProcessor
|
||||
await StopParkingAsync(vin);
|
||||
}
|
||||
|
||||
private async Task StartParkingAsync(string vin)
|
||||
public async Task StartParkingAsync(string vin)
|
||||
{
|
||||
this.logger.LogTrace("Start parking for {vin}...", vin);
|
||||
|
||||
@@ -130,7 +125,7 @@ public class MessageProcessor : IMessageProcessor
|
||||
this.logger.LogError(zoneLookupResult.Exception, "Can't start parking: error while determining parking zone");
|
||||
}
|
||||
|
||||
private async Task StopParkingAsync(string vin)
|
||||
public async Task StopParkingAsync(string vin)
|
||||
{
|
||||
this.logger.LogTrace("Stopping parking for {vin}...", vin);
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Diagnostics;
|
||||
using Microsoft.Extensions.Options;
|
||||
using NetTopologySuite.Features;
|
||||
using NetTopologySuite.Geometries;
|
||||
@@ -45,14 +46,21 @@ public class ZoneDeterminatorService
|
||||
return Result.Success(zone.Attributes["zoneid"].ToString()!);
|
||||
}
|
||||
|
||||
private async Task InitializeAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task InitializeAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
this.logger.LogTrace("Initializing...");
|
||||
|
||||
Stopwatch sw = Stopwatch.StartNew();
|
||||
|
||||
this.logger.LogTrace("Reading file...");
|
||||
string geojson = await File.ReadAllTextAsync(this.configuration.ZoneFilePath, cancellationToken);
|
||||
this.logger.LogTrace("File read in {Elapsed} ms", sw.ElapsedMilliseconds);
|
||||
|
||||
this.logger.LogTrace("Parsing geojson...");
|
||||
GeoJsonReader reader = new GeoJsonReader();
|
||||
this.parkingZones = reader.Read<FeatureCollection>(geojson);
|
||||
|
||||
this.logger.LogTrace("Geojson parsed in {Elapsed} ms: {FeatureCount} features", sw.ElapsedMilliseconds, this.parkingZones.Count);
|
||||
|
||||
this.initialized = true;
|
||||
this.logger.LogInformation("Initialized");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user