mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-06-22 17:51:15 +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:
@@ -0,0 +1,40 @@
|
||||
using FluentAssertions;
|
||||
|
||||
namespace SatelliteProvider.Tests;
|
||||
|
||||
public class AcceptanceCriteriaRT2Tests
|
||||
{
|
||||
[Fact]
|
||||
public void RT2_LinesAllFourPointTypes_AZ370_AC3()
|
||||
{
|
||||
var path = LocateAcceptanceCriteriaMd();
|
||||
if (path is null)
|
||||
{
|
||||
Assert.Fail("acceptance_criteria.md not found from test runtime — repo layout drift");
|
||||
}
|
||||
|
||||
var content = File.ReadAllText(path);
|
||||
var rt2Line = content.Split('\n').FirstOrDefault(line => line.Contains("| RT2 |"));
|
||||
|
||||
rt2Line.Should().NotBeNull("RT2 row must exist in the Route Management section");
|
||||
rt2Line!.Should().Contain("\"start\"");
|
||||
rt2Line.Should().Contain("\"end\"");
|
||||
rt2Line.Should().Contain("\"action\"");
|
||||
rt2Line.Should().Contain("\"intermediate\"");
|
||||
}
|
||||
|
||||
private static string? LocateAcceptanceCriteriaMd()
|
||||
{
|
||||
var dir = new DirectoryInfo(Directory.GetCurrentDirectory());
|
||||
while (dir is not null)
|
||||
{
|
||||
var candidate = Path.Combine(dir.FullName, "_docs", "00_problem", "acceptance_criteria.md");
|
||||
if (File.Exists(candidate))
|
||||
{
|
||||
return candidate;
|
||||
}
|
||||
dir = dir.Parent;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
using System.Data;
|
||||
using FluentAssertions;
|
||||
using Npgsql;
|
||||
using SatelliteProvider.Common.Enums;
|
||||
using SatelliteProvider.DataAccess.TypeHandlers;
|
||||
|
||||
namespace SatelliteProvider.Tests;
|
||||
|
||||
public class EnumStringTypeHandlerTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(RegionStatus.Queued, "queued")]
|
||||
[InlineData(RegionStatus.Processing, "processing")]
|
||||
[InlineData(RegionStatus.Completed, "completed")]
|
||||
[InlineData(RegionStatus.Failed, "failed")]
|
||||
public void SetValue_RegionStatus_WritesLowercaseString_AZ370_AC1(RegionStatus value, string expected)
|
||||
{
|
||||
var handler = new EnumStringTypeHandler<RegionStatus>();
|
||||
var param = new NpgsqlParameter();
|
||||
|
||||
handler.SetValue(param, value);
|
||||
|
||||
param.Value.Should().Be(expected);
|
||||
param.DbType.Should().Be(DbType.String);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(RoutePointType.Start, "start")]
|
||||
[InlineData(RoutePointType.End, "end")]
|
||||
[InlineData(RoutePointType.Action, "action")]
|
||||
[InlineData(RoutePointType.Intermediate, "intermediate")]
|
||||
public void SetValue_RoutePointType_WritesLowercaseString_AZ370_AC1(RoutePointType value, string expected)
|
||||
{
|
||||
var handler = new EnumStringTypeHandler<RoutePointType>();
|
||||
var param = new NpgsqlParameter();
|
||||
|
||||
handler.SetValue(param, value);
|
||||
|
||||
param.Value.Should().Be(expected);
|
||||
param.DbType.Should().Be(DbType.String);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("queued", RegionStatus.Queued)]
|
||||
[InlineData("processing", RegionStatus.Processing)]
|
||||
[InlineData("completed", RegionStatus.Completed)]
|
||||
[InlineData("failed", RegionStatus.Failed)]
|
||||
[InlineData("Completed", RegionStatus.Completed)]
|
||||
public void Parse_RegionStatus_AcceptsAnyCase_AZ370_AC2(string raw, RegionStatus expected)
|
||||
{
|
||||
var handler = new EnumStringTypeHandler<RegionStatus>();
|
||||
|
||||
var result = handler.Parse(raw);
|
||||
|
||||
result.Should().Be(expected);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("start", RoutePointType.Start)]
|
||||
[InlineData("end", RoutePointType.End)]
|
||||
[InlineData("action", RoutePointType.Action)]
|
||||
[InlineData("intermediate", RoutePointType.Intermediate)]
|
||||
public void Parse_RoutePointType_AcceptsLowercase_AZ370_AC2(string raw, RoutePointType expected)
|
||||
{
|
||||
var handler = new EnumStringTypeHandler<RoutePointType>();
|
||||
|
||||
var result = handler.Parse(raw);
|
||||
|
||||
result.Should().Be(expected);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(RegionStatus.Queued)]
|
||||
[InlineData(RegionStatus.Processing)]
|
||||
[InlineData(RegionStatus.Completed)]
|
||||
[InlineData(RegionStatus.Failed)]
|
||||
public void RoundTrip_RegionStatus_PreservesValue_AZ370_AC2(RegionStatus value)
|
||||
{
|
||||
var handler = new EnumStringTypeHandler<RegionStatus>();
|
||||
var param = new NpgsqlParameter();
|
||||
handler.SetValue(param, value);
|
||||
|
||||
var roundTripped = handler.Parse(param.Value!);
|
||||
|
||||
roundTripped.Should().Be(value);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(RoutePointType.Start)]
|
||||
[InlineData(RoutePointType.End)]
|
||||
[InlineData(RoutePointType.Action)]
|
||||
[InlineData(RoutePointType.Intermediate)]
|
||||
public void RoundTrip_RoutePointType_PreservesValue_AZ370_AC2(RoutePointType value)
|
||||
{
|
||||
var handler = new EnumStringTypeHandler<RoutePointType>();
|
||||
var param = new NpgsqlParameter();
|
||||
handler.SetValue(param, value);
|
||||
|
||||
var roundTripped = handler.Parse(param.Value!);
|
||||
|
||||
roundTripped.Should().Be(value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Parse_NullValue_ThrowsDataException()
|
||||
{
|
||||
var handler = new EnumStringTypeHandler<RegionStatus>();
|
||||
|
||||
Action act = () => handler.Parse(null!);
|
||||
|
||||
act.Should().Throw<DataException>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Parse_DbNullValue_ThrowsDataException()
|
||||
{
|
||||
var handler = new EnumStringTypeHandler<RegionStatus>();
|
||||
|
||||
Action act = () => handler.Parse(DBNull.Value);
|
||||
|
||||
act.Should().Throw<DataException>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Parse_UnknownString_ThrowsDataException()
|
||||
{
|
||||
var handler = new EnumStringTypeHandler<RegionStatus>();
|
||||
|
||||
Action act = () => handler.Parse("not-a-status");
|
||||
|
||||
act.Should().Throw<DataException>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RegisterAll_IsIdempotent()
|
||||
{
|
||||
DapperEnumTypeHandlers.RegisterAll();
|
||||
DapperEnumTypeHandlers.RegisterAll();
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using Microsoft.Extensions.Options;
|
||||
using Moq;
|
||||
using SatelliteProvider.Common.Configs;
|
||||
using SatelliteProvider.Common.DTO;
|
||||
using SatelliteProvider.Common.Enums;
|
||||
using SatelliteProvider.Common.Exceptions;
|
||||
using SatelliteProvider.Common.Interfaces;
|
||||
using SatelliteProvider.DataAccess.Models;
|
||||
@@ -57,10 +58,10 @@ public class RegionServiceTests : IDisposable
|
||||
|
||||
// Assert
|
||||
status.Id.Should().Be(id);
|
||||
status.Status.Should().Be("queued");
|
||||
status.Status.Should().Be(RegionStatus.Queued);
|
||||
regionRepo.Verify(r => r.InsertAsync(It.Is<RegionEntity>(re =>
|
||||
re.Id == id &&
|
||||
re.Status == "queued" &&
|
||||
re.Status == RegionStatus.Queued &&
|
||||
re.SizeMeters == 200 &&
|
||||
re.ZoomLevel == 18)), Times.Once);
|
||||
queue.Verify(q => q.EnqueueAsync(It.Is<RegionRequest>(rr =>
|
||||
@@ -83,7 +84,7 @@ public class RegionServiceTests : IDisposable
|
||||
SizeMeters = 200,
|
||||
ZoomLevel = 18,
|
||||
StitchTiles = false,
|
||||
Status = "processing",
|
||||
Status = RegionStatus.Processing,
|
||||
TilesDownloaded = 5,
|
||||
TilesReused = 3,
|
||||
CreatedAt = DateTime.UtcNow.AddMinutes(-5),
|
||||
@@ -100,7 +101,7 @@ public class RegionServiceTests : IDisposable
|
||||
|
||||
// Assert
|
||||
status.Id.Should().Be(id);
|
||||
status.Status.Should().Be("processing", "AZ-362: returns the existing region's current status, not 'queued'");
|
||||
status.Status.Should().Be(RegionStatus.Processing, "AZ-362: returns the existing region's current status, not 'queued'");
|
||||
regionRepo.Verify(r => r.InsertAsync(It.IsAny<RegionEntity>()), Times.Never,
|
||||
"AZ-362: duplicate Id must not re-insert");
|
||||
queue.VerifyNoOtherCalls();
|
||||
@@ -122,7 +123,7 @@ public class RegionServiceTests : IDisposable
|
||||
Longitude = 37.647063,
|
||||
SizeMeters = 200,
|
||||
ZoomLevel = 18,
|
||||
Status = "queued",
|
||||
Status = RegionStatus.Queued,
|
||||
StitchTiles = false,
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
UpdatedAt = DateTime.UtcNow,
|
||||
@@ -130,7 +131,7 @@ public class RegionServiceTests : IDisposable
|
||||
|
||||
regionRepo.Setup(r => r.GetByIdAsync(id)).ReturnsAsync(entity);
|
||||
|
||||
var capturedStatuses = new List<string>();
|
||||
var capturedStatuses = new List<RegionStatus>();
|
||||
regionRepo
|
||||
.Setup(r => r.UpdateAsync(It.IsAny<RegionEntity>()))
|
||||
.Callback<RegionEntity>(e => capturedStatuses.Add(e.Status))
|
||||
@@ -163,8 +164,8 @@ public class RegionServiceTests : IDisposable
|
||||
await service.ProcessRegionAsync(id);
|
||||
|
||||
// Assert
|
||||
capturedStatuses.Should().ContainInOrder("processing", "completed");
|
||||
entity.Status.Should().Be("completed");
|
||||
capturedStatuses.Should().ContainInOrder(RegionStatus.Processing, RegionStatus.Completed);
|
||||
entity.Status.Should().Be(RegionStatus.Completed);
|
||||
entity.CsvFilePath.Should().NotBeNullOrEmpty();
|
||||
entity.SummaryFilePath.Should().NotBeNullOrEmpty();
|
||||
entity.TilesDownloaded.Should().Be(1);
|
||||
@@ -204,7 +205,7 @@ public class RegionServiceTests : IDisposable
|
||||
Longitude = 37.647063,
|
||||
SizeMeters = 200,
|
||||
ZoomLevel = 18,
|
||||
Status = "queued",
|
||||
Status = RegionStatus.Queued,
|
||||
StitchTiles = false,
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
UpdatedAt = DateTime.UtcNow,
|
||||
@@ -212,7 +213,7 @@ public class RegionServiceTests : IDisposable
|
||||
|
||||
regionRepo.Setup(r => r.GetByIdAsync(id)).ReturnsAsync(entity);
|
||||
|
||||
var capturedStatuses = new List<string>();
|
||||
var capturedStatuses = new List<RegionStatus>();
|
||||
regionRepo
|
||||
.Setup(r => r.UpdateAsync(It.IsAny<RegionEntity>()))
|
||||
.Callback<RegionEntity>(e => capturedStatuses.Add(e.Status))
|
||||
@@ -233,8 +234,8 @@ public class RegionServiceTests : IDisposable
|
||||
await service.ProcessRegionAsync(id);
|
||||
|
||||
// Assert
|
||||
capturedStatuses.Should().ContainInOrder("processing", "failed");
|
||||
entity.Status.Should().Be("failed");
|
||||
capturedStatuses.Should().ContainInOrder(RegionStatus.Processing, RegionStatus.Failed);
|
||||
entity.Status.Should().Be(RegionStatus.Failed);
|
||||
entity.SummaryFilePath.Should().NotBeNullOrEmpty();
|
||||
File.Exists(entity.SummaryFilePath!).Should().BeTrue();
|
||||
File.ReadAllText(entity.SummaryFilePath!).Should().Contain("Rate limit exceeded");
|
||||
@@ -256,7 +257,7 @@ public class RegionServiceTests : IDisposable
|
||||
Longitude = 37.647063,
|
||||
SizeMeters = 500,
|
||||
ZoomLevel = 18,
|
||||
Status = "queued",
|
||||
Status = RegionStatus.Queued,
|
||||
StitchTiles = true,
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
UpdatedAt = DateTime.UtcNow,
|
||||
@@ -293,7 +294,7 @@ public class RegionServiceTests : IDisposable
|
||||
await service.ProcessRegionAsync(id);
|
||||
|
||||
// Assert
|
||||
entity.Status.Should().Be("completed");
|
||||
entity.Status.Should().Be(RegionStatus.Completed);
|
||||
var stitchedPath = Path.Combine(_readyDir, $"region_{id}_stitched.jpg");
|
||||
File.Exists(stitchedPath).Should().BeTrue("stitched image must exist when stitchTiles=true");
|
||||
}
|
||||
@@ -305,7 +306,7 @@ public class RegionServiceTests : IDisposable
|
||||
var regionRepo = new Mock<IRegionRepository>();
|
||||
var id = Guid.NewGuid();
|
||||
regionRepo.Setup(r => r.GetByIdAsync(id))
|
||||
.ReturnsAsync(new RegionEntity { Id = id, Status = "completed", TilesDownloaded = 5, TilesReused = 2 });
|
||||
.ReturnsAsync(new RegionEntity { Id = id, Status = RegionStatus.Completed, TilesDownloaded = 5, TilesReused = 2 });
|
||||
var service = BuildService(regionRepo, new Mock<IRegionRequestQueue>(), new Mock<ITileService>());
|
||||
|
||||
// Act
|
||||
@@ -313,7 +314,7 @@ public class RegionServiceTests : IDisposable
|
||||
|
||||
// Assert
|
||||
result.Should().NotBeNull();
|
||||
result!.Status.Should().Be("completed");
|
||||
result!.Status.Should().Be(RegionStatus.Completed);
|
||||
result.TilesDownloaded.Should().Be(5);
|
||||
result.TilesReused.Should().Be(2);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ using FluentAssertions;
|
||||
using Microsoft.Extensions.Options;
|
||||
using SatelliteProvider.Common.Configs;
|
||||
using SatelliteProvider.Common.DTO;
|
||||
using SatelliteProvider.Common.Enums;
|
||||
using SatelliteProvider.Common.Utils;
|
||||
using SatelliteProvider.Services.RouteManagement;
|
||||
using SatelliteProvider.Tests.Fixtures;
|
||||
@@ -26,10 +27,10 @@ public class RoutePointGraphBuilderTests
|
||||
|
||||
var graph = sut.Build(input);
|
||||
|
||||
graph.Points.First().PointType.Should().Be("start");
|
||||
graph.Points.Last().PointType.Should().Be("end");
|
||||
graph.Points.First().PointType.Should().Be(RoutePointType.Start);
|
||||
graph.Points.Last().PointType.Should().Be(RoutePointType.End);
|
||||
graph.Points.Skip(1).Take(graph.Points.Count - 2)
|
||||
.Should().OnlyContain(p => p.PointType == "intermediate");
|
||||
.Should().OnlyContain(p => p.PointType == RoutePointType.Intermediate);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -60,10 +61,10 @@ public class RoutePointGraphBuilderTests
|
||||
|
||||
var graph = sut.Build(input);
|
||||
|
||||
graph.Points.Count(p => p.PointType == "start").Should().Be(1);
|
||||
graph.Points.Count(p => p.PointType == "end").Should().Be(1);
|
||||
graph.Points.Count(p => p.PointType == "action").Should().Be(8);
|
||||
graph.Points.Should().Contain(p => p.PointType == "intermediate");
|
||||
graph.Points.Count(p => p.PointType == RoutePointType.Start).Should().Be(1);
|
||||
graph.Points.Count(p => p.PointType == RoutePointType.End).Should().Be(1);
|
||||
graph.Points.Count(p => p.PointType == RoutePointType.Action).Should().Be(8);
|
||||
graph.Points.Should().Contain(p => p.PointType == RoutePointType.Intermediate);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using Microsoft.Extensions.Options;
|
||||
using Moq;
|
||||
using SatelliteProvider.Common.Configs;
|
||||
using SatelliteProvider.Common.DTO;
|
||||
using SatelliteProvider.Common.Enums;
|
||||
using SatelliteProvider.Common.Interfaces;
|
||||
using SatelliteProvider.Common.Utils;
|
||||
using SatelliteProvider.DataAccess.Models;
|
||||
@@ -59,8 +60,8 @@ public class RouteServiceTests
|
||||
};
|
||||
var existingPoints = new List<RoutePointEntity>
|
||||
{
|
||||
new() { Id = Guid.NewGuid(), RouteId = existingId, SequenceNumber = 0, Latitude = 47.46, Longitude = 37.64, PointType = "start", SegmentIndex = 0 },
|
||||
new() { Id = Guid.NewGuid(), RouteId = existingId, SequenceNumber = 1, Latitude = 47.47, Longitude = 37.65, PointType = "end", SegmentIndex = 0 },
|
||||
new() { Id = Guid.NewGuid(), RouteId = existingId, SequenceNumber = 0, Latitude = 47.46, Longitude = 37.64, PointType = RoutePointType.Start, SegmentIndex = 0 },
|
||||
new() { Id = Guid.NewGuid(), RouteId = existingId, SequenceNumber = 1, Latitude = 47.47, Longitude = 37.65, PointType = RoutePointType.End, SegmentIndex = 0 },
|
||||
};
|
||||
var routeRepo = new Mock<IRouteRepository>(MockBehavior.Strict);
|
||||
routeRepo.Setup(r => r.GetByIdAsync(existingId)).ReturnsAsync(existingEntity);
|
||||
@@ -125,9 +126,9 @@ public class RouteServiceTests
|
||||
var result = await service.CreateRouteAsync(request);
|
||||
|
||||
// Assert
|
||||
result.Points.First().PointType.Should().Be("start", "first user-supplied point");
|
||||
result.Points.Last().PointType.Should().Be("end", "last user-supplied point");
|
||||
result.Points.Skip(1).Take(result.Points.Count - 2).Should().OnlyContain(p => p.PointType == "intermediate",
|
||||
result.Points.First().PointType.Should().Be(RoutePointType.Start, "first user-supplied point");
|
||||
result.Points.Last().PointType.Should().Be(RoutePointType.End, "last user-supplied point");
|
||||
result.Points.Skip(1).Take(result.Points.Count - 2).Should().OnlyContain(p => p.PointType == RoutePointType.Intermediate,
|
||||
"every middle point in a 2-point route is interpolated");
|
||||
}
|
||||
|
||||
@@ -142,10 +143,10 @@ public class RouteServiceTests
|
||||
var result = await service.CreateRouteAsync(request);
|
||||
|
||||
// Assert
|
||||
result.Points.Count(p => p.PointType == "start").Should().Be(1);
|
||||
result.Points.Count(p => p.PointType == "end").Should().Be(1);
|
||||
result.Points.Count(p => p.PointType == "action").Should().Be(8, "8 middle user-supplied waypoints in a 10-point route");
|
||||
result.Points.Should().Contain(p => p.PointType == "intermediate", "long route always interpolates");
|
||||
result.Points.Count(p => p.PointType == RoutePointType.Start).Should().Be(1);
|
||||
result.Points.Count(p => p.PointType == RoutePointType.End).Should().Be(1);
|
||||
result.Points.Count(p => p.PointType == RoutePointType.Action).Should().Be(8, "8 middle user-supplied waypoints in a 10-point route");
|
||||
result.Points.Should().Contain(p => p.PointType == RoutePointType.Intermediate, "long route always interpolates");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -159,9 +160,9 @@ public class RouteServiceTests
|
||||
var result = await service.CreateRouteAsync(request);
|
||||
|
||||
// Assert
|
||||
result.Points.Count(p => p.PointType == "start").Should().Be(1);
|
||||
result.Points.Count(p => p.PointType == "end").Should().Be(1);
|
||||
result.Points.Count(p => p.PointType == "action").Should().Be(18, "18 middle user-supplied waypoints in a 20-point route");
|
||||
result.Points.Count(p => p.PointType == RoutePointType.Start).Should().Be(1);
|
||||
result.Points.Count(p => p.PointType == RoutePointType.End).Should().Be(1);
|
||||
result.Points.Count(p => p.PointType == RoutePointType.Action).Should().Be(18, "18 middle user-supplied waypoints in a 20-point route");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -274,7 +275,7 @@ public class RouteServiceTests
|
||||
|
||||
regionService
|
||||
.Setup(r => r.RequestRegionAsync(It.IsAny<Guid>(), It.IsAny<double>(), It.IsAny<double>(), It.IsAny<double>(), It.IsAny<int>(), false))
|
||||
.ReturnsAsync(new RegionStatus { Status = "queued" });
|
||||
.ReturnsAsync(new RegionStatusResponse { Status = RegionStatus.Queued });
|
||||
|
||||
var service = BuildService(routeRepo, regionService);
|
||||
|
||||
@@ -319,8 +320,8 @@ public class RouteServiceTests
|
||||
routeRepo.Setup(r => r.GetByIdAsync(id)).ReturnsAsync(routeEntity);
|
||||
routeRepo.Setup(r => r.GetRoutePointsAsync(id)).ReturnsAsync(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 },
|
||||
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 },
|
||||
});
|
||||
|
||||
var service = BuildService(routeRepo, new Mock<IRegionService>());
|
||||
@@ -332,8 +333,8 @@ public class RouteServiceTests
|
||||
result.Should().NotBeNull();
|
||||
result!.Id.Should().Be(id);
|
||||
result.Points.Should().HaveCount(2);
|
||||
result.Points[0].PointType.Should().Be("start");
|
||||
result.Points[1].PointType.Should().Be("end");
|
||||
result.Points[0].PointType.Should().Be(RoutePointType.Start);
|
||||
result.Points[1].PointType.Should().Be(RoutePointType.End);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user