public async Task Should_return_correct_grid_distance_and_point_count() { var designProfile = new DesignProfile { vertices = new List <DesignProfileVertex> { new DesignProfileVertex { station = 0.000, elevation = 597.4387F }, new DesignProfileVertex { station = 0.80197204271533173, elevation = 597.4356F }, new DesignProfileVertex { station = 1.6069349835347948, elevation = 597.434265F } }, GridDistanceBetweenProfilePoints = 13.951246308791798 }; var result = await MockGetProfile(designProfile); Assert.IsNotNull(result, ExecutorFailed); Assert.AreEqual(designProfile.GridDistanceBetweenProfilePoints, result.gridDistanceBetweenProfilePoints, WrongGridDistanceBetweenProfilePoints); Assert.AreEqual(designProfile.vertices.Count, result.results.Count, IncorrectNumberOfPoints); }
public async Task Should_fix_gap_points() { var designProfile = new DesignProfile { vertices = new List <DesignProfileVertex> { new DesignProfileVertex { station = 0.000, elevation = 597.4387F }, new DesignProfileVertex { station = 0.80197204271533173, elevation = (float)VelociraptorConstants.NO_HEIGHT }, new DesignProfileVertex { station = 1.6069349835347948, elevation = 597.434265F } }, GridDistanceBetweenProfilePoints = 13.951246308791798 }; var result = await MockGetProfile(designProfile); Assert.IsNotNull(result, ExecutorFailed); Assert.AreEqual(designProfile.GridDistanceBetweenProfilePoints, result.gridDistanceBetweenProfilePoints, WrongGridDistanceBetweenProfilePoints); Assert.AreEqual(designProfile.vertices.Count - 1, result.results.Count, IncorrectNumberOfPoints); Assert.AreEqual(ProfileCellType.Gap, result.results[0].cellType, "Wrong cellType 1"); Assert.AreEqual(designProfile.vertices[0].station, result.results[0].station, "Wrong station 1"); Assert.AreEqual(designProfile.vertices[0].elevation, result.results[0].elevation, "Wrong elevation 1"); Assert.AreEqual(ProfileCellType.Edge, result.results[1].cellType, "Wrong cellType 2"); Assert.AreEqual(designProfile.vertices[2].station, result.results[1].station, "Wrong station 2"); Assert.AreEqual(designProfile.vertices[2].elevation, result.results[1].elevation, "Wrong elevation 2"); }
private CompactionProfileResult <CompactionProfileVertex> ConvertProfileResult(MemoryStream ms) { log.LogDebug("Converting profile result"); var profileResult = new CompactionProfileResult <CompactionProfileVertex>(); var pdsiProfile = new DesignProfile(); pdsiProfile.ReadFromStream(ms); profileResult.results = pdsiProfile.vertices.ConvertAll(dpv => new CompactionProfileVertex { cellType = dpv.elevation >= VelociraptorConstants.NO_HEIGHT ? ProfileCellType.Gap : ProfileCellType.Edge, elevation = dpv.elevation >= VelociraptorConstants.NO_HEIGHT ? float.NaN : dpv.elevation, station = dpv.station }); profileResult.gridDistanceBetweenProfilePoints = pdsiProfile.GridDistanceBetweenProfilePoints; FixGaps(profileResult.results); return(profileResult); }
private async Task <CompactionProfileResult <CompactionProfileVertex> > MockGetProfile(DesignProfile designProfile) { var raptorClient = new Mock <IASNodeClient>(); var configStore = new Mock <IConfigurationStore>(); var ms = new MemoryStream(); //No serialization so do it by hand BinaryWriter writer = new BinaryWriter(ms); writer.Write(BitConverter.GetBytes(designProfile.vertices.Count)); foreach (var vertex in designProfile.vertices) { writer.Write(BitConverter.GetBytes(vertex.station)); writer.Write(BitConverter.GetBytes(vertex.elevation)); } writer.Write(BitConverter.GetBytes(designProfile.GridDistanceBetweenProfilePoints)); ms.Position = 0; raptorClient .Setup(x => x.GetDesignProfile(It.IsAny <TDesignProfilerServiceRPCVerb_CalculateDesignProfile_Args>())) .Returns(ms); var request = new CompactionProfileDesignRequest( 1234, null, null, null, -1, null, new ProfileGridPoints(), new ProfileLLPoints(), ValidationConstants3D.MIN_STATION, ValidationConstants3D.MIN_STATION); var executor = RequestExecutorContainerFactory .Build <CompactionDesignProfileExecutor>(logger, raptorClient.Object, configStore: configStore.Object); var result = await executor.ProcessAsync(request) as CompactionProfileResult <CompactionProfileVertex>; return(result); }