mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-06-22 18:01:14 +00:00
[AZ-370] Refactor C17: status / point-type enums + AC RT2 update
Replaces bare strings with two enums in Common/Enums/:
RegionStatus { Queued, Processing, Completed, Failed }
RoutePointType { Start, End, Action, Intermediate }
Adds a Dapper EnumStringTypeHandler<T> (DataAccess/TypeHandlers/)
that round-trips enums to/from lowercase strings, registered once
at startup via DapperEnumTypeHandlers.RegisterAll(). DataAccess now
references Common (project ref) so entities can carry the enum types.
Sites converted: RegionService (5), RouteProcessingService (3),
RoutePointGraphBuilder (4), entity Status/PointType columns. Log
message and summary file format preserved via .ToLowerInvariant().
API JSON contract preserved by adding JsonStringEnumConverter with
JsonNamingPolicy.CamelCase to the http JSON options — single-word
enum members serialize to the same lowercase strings as before.
DTO renamed: Common.DTO.RegionStatus -> RegionStatusResponse to
free the RegionStatus name for the new enum (forced by the task's
explicit enum name); the renamed DTO has no public-API impact at
the JSON wire level. Stale doc references updated.
AC RT2 in _docs/00_problem/acceptance_criteria.md now lists all 4
point types (start/end/action/intermediate).
Tests: 171 / 171 unit + 5 / 5 smoke green (was 141 + 5; +30 new tests
covering type handler round-trip, set/parse, unknown-value rejection,
idempotent registration, and the AC RT2 doc check).
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using FluentAssertions;
|
||||
using SatelliteProvider.Common.DTO;
|
||||
using SatelliteProvider.Common.Enums;
|
||||
using SatelliteProvider.DataAccess.Models;
|
||||
using SatelliteProvider.Services.RouteManagement;
|
||||
|
||||
@@ -33,8 +34,8 @@ public class RouteResponseMapperTests
|
||||
var entity = BuildEntity(id);
|
||||
var dtos = new List<RoutePointDto>
|
||||
{
|
||||
new() { Latitude = 1, Longitude = 2, PointType = "start", SequenceNumber = 0, SegmentIndex = 0 },
|
||||
new() { Latitude = 3, Longitude = 4, PointType = "end", SequenceNumber = 1, SegmentIndex = 1, DistanceFromPrevious = 100.0 },
|
||||
new() { Latitude = 1, Longitude = 2, PointType = RoutePointType.Start, SequenceNumber = 0, SegmentIndex = 0 },
|
||||
new() { Latitude = 3, Longitude = 4, PointType = RoutePointType.End, SequenceNumber = 1, SegmentIndex = 1, DistanceFromPrevious = 100.0 },
|
||||
};
|
||||
var sut = new RouteResponseMapper();
|
||||
|
||||
@@ -65,17 +66,17 @@ public class RouteResponseMapperTests
|
||||
var entity = BuildEntity(id);
|
||||
var pointEntities = new List<RoutePointEntity>
|
||||
{
|
||||
new() { Id = Guid.NewGuid(), RouteId = id, SequenceNumber = 0, Latitude = 1, Longitude = 2, PointType = "start", SegmentIndex = 0 },
|
||||
new() { Id = Guid.NewGuid(), RouteId = id, SequenceNumber = 1, Latitude = 3, Longitude = 4, PointType = "end", SegmentIndex = 1, DistanceFromPrevious = 100.0 },
|
||||
new() { Id = Guid.NewGuid(), RouteId = id, SequenceNumber = 0, Latitude = 1, Longitude = 2, PointType = RoutePointType.Start, SegmentIndex = 0 },
|
||||
new() { Id = Guid.NewGuid(), RouteId = id, SequenceNumber = 1, Latitude = 3, Longitude = 4, PointType = RoutePointType.End, SegmentIndex = 1, DistanceFromPrevious = 100.0 },
|
||||
};
|
||||
var sut = new RouteResponseMapper();
|
||||
|
||||
var response = sut.Map(entity, pointEntities);
|
||||
|
||||
response.Points.Should().HaveCount(2);
|
||||
response.Points[0].PointType.Should().Be("start");
|
||||
response.Points[0].PointType.Should().Be(RoutePointType.Start);
|
||||
response.Points[0].Latitude.Should().Be(1);
|
||||
response.Points[1].PointType.Should().Be("end");
|
||||
response.Points[1].PointType.Should().Be(RoutePointType.End);
|
||||
response.Points[1].DistanceFromPrevious.Should().Be(100.0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user