Ejemplo n.º 1
0
        public void MapStationOffsetRequestToApplicationArgument(
            Guid projectUid, FilterResult filter,
            bool reportElevation, bool reportCmv, bool reportMdp, bool reportPassCount, bool reportTemperature, bool reportCutFill,
            Guid?cutFillDesignUid, double?cutfillDesignOffset, Guid alignmentDesignUid,
            double crossSectionInterval, double startStation, double endStation, double[] offsets, bool useOverrides)
        {
            var overrides = useOverrides
        ? new OverridingTargets(75, true, 70, 90, 0, false, 80, 125, new TargetPassCountRange(4, 10),
                                new TemperatureSettings(120, 70, true), null)
        : null;

            var liftSettings = useOverrides
        ? new LiftSettings(true, false, SummaryType.Compaction,
                           SummaryType.WorkInProgress, 0.2f, LiftDetectionType.AutoMapReset, LiftThicknessType.Compacted,
                           new LiftThicknessTarget {
                TargetLiftThickness = 0.75f, AboveToleranceLiftThickness = 0.3f, BelowToleranceLiftThickness = 0.2f
            },
                           true, 0.5f, true, 0.3, 0.7)
        : null;

            var request = CompactionReportStationOffsetTRexRequest.CreateRequest(
                projectUid, filter,
                reportElevation, reportCmv, reportMdp, reportPassCount, reportTemperature, reportCutFill,
                cutFillDesignUid, cutfillDesignOffset, alignmentDesignUid,
                crossSectionInterval, startStation, endStation, offsets, overrides, liftSettings);

            var result = AutoMapperUtility.Automapper.Map <StationOffsetReportRequestArgument_ApplicationService>(request);

            Assert.Equal(request.ProjectUid, result.ProjectID);
            Assert.Null(result.Filters);
            Assert.Equal(request.ReportElevation, result.ReportElevation);
            Assert.Equal(request.ReportCutFill, result.ReportCutFill);
            Assert.Equal(request.ReportCmv, result.ReportCmv);
            Assert.Equal(request.ReportMdp, result.ReportMdp);
            Assert.Equal(request.ReportPassCount, result.ReportPassCount);
            Assert.Equal(request.ReportTemperature, result.ReportTemperature);
            Assert.Equal(request.CutFillDesignUid ?? Guid.Empty, result.ReferenceDesign.DesignID);
            Assert.Equal(request.CutFillDesignOffset ?? 0, result.ReferenceDesign.Offset);
            Assert.Equal(request.AlignmentDesignUid, result.AlignmentDesignUid);
            Assert.Equal(request.CrossSectionInterval, result.CrossSectionInterval);
            Assert.Equal(request.StartStation, result.StartStation);
            Assert.Equal(request.EndStation, result.EndStation);
            Assert.Equal(request.Offsets.Length, result.Offsets.Length);
            Assert.Equal(request.Offsets[2], result.Offsets[2]);
            //Overrides mapping tested separately in AutoMapperTests
            if (useOverrides)
            {
                Assert.NotNull(result.Overrides);
                Assert.NotNull(result.LiftParams);
            }
            else
            {
                Assert.Null(result.Overrides);
                Assert.Null(result.LiftParams);
            }
        }
Ejemplo n.º 2
0
        public void StationOffsetTRexRequest_Successful(
            Guid projectUid, FilterResult filter,
            bool reportElevation, bool reportCmv, bool reportMdp, bool reportPassCount, bool reportTemperature, bool reportCutFill,
            Guid?cutFillDesignUid, double?cutfillDesignOffset, Guid alignmentDesignUid,
            double crossSectionInterval, double startStation, double endStation, double[] offsets)
        {
            var request = CompactionReportStationOffsetTRexRequest.CreateRequest(
                projectUid, filter,
                reportElevation, reportCmv, reportMdp, reportPassCount, reportTemperature, reportCutFill,
                cutFillDesignUid, cutfillDesignOffset, alignmentDesignUid,
                crossSectionInterval, startStation, endStation, offsets, null, null);

            request.Validate();
        }
Ejemplo n.º 3
0
        public async Task StationOffsetReportExecutor_GotSiteAndFilter()
        {
            bool   reportElevation      = true;
            bool   reportCmv            = true;
            bool   reportMdp            = true;
            bool   reportPassCount      = true;
            bool   reportTemperature    = true;
            bool   reportCutFill        = false;
            Guid?  cutFillDesignUid     = null;
            double?cutFillDesignOffset  = null;
            var    alignmentDesignUid   = Guid.NewGuid();
            double crossSectionInterval = 1.0;
            double startStation         = 100;
            double endStation           = 200;

            double[] offsets = { -1, 0, 1 };

            var filter = new Productivity3D.Filter.Abstractions.Models.Filter(
                DateTime.SpecifyKind(new DateTime(2018, 1, 10), DateTimeKind.Utc),
                DateTime.SpecifyKind(new DateTime(2019, 2, 11), DateTimeKind.Utc), "", "",
                new List <MachineDetails>(), null, null, null, null, null, null
                );
            var filterResult = new FilterResult(null, filter, null, null, null, null, null, null, null);
            var siteModel    = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();

            var request = CompactionReportStationOffsetTRexRequest.CreateRequest(
                siteModel.ID, filterResult,
                reportElevation, reportCmv, reportMdp, reportPassCount, reportTemperature, reportCutFill,
                cutFillDesignUid, cutFillDesignOffset, alignmentDesignUid,
                crossSectionInterval, startStation, endStation, offsets, null, null);

            request.Validate();

            // Mock the export request functionality to return an empty report reponse to stimulate the desired success
            var mockCompute = IgniteMock.Immutable.mockCompute;

            mockCompute.Setup(x => x.ApplyAsync(It.IsAny <StationOffsetReportRequestComputeFunc_ApplicationService>(), It.IsAny <StationOffsetReportRequestArgument_ApplicationService>(), It.IsAny <CancellationToken>()))
            .Returns((StationOffsetReportRequestComputeFunc_ApplicationService func, StationOffsetReportRequestArgument_ApplicationService argument, CancellationToken token) => Task.FromResult(new StationOffsetReportRequestResponse_ApplicationService()));

            var executor = RequestExecutorContainer
                           .Build <StationOffsetReportExecutor>(DIContext.Obtain <IConfigurationStore>(),
                                                                DIContext.Obtain <ILoggerFactory>(),
                                                                DIContext.Obtain <IServiceExceptionHandler>());
            var result = await executor.ProcessAsync(request) as GriddedReportDataResult;

            result.Code.Should().Be(ContractExecutionStatesEnum.ExecutedSuccessfully);
            result.GriddedData.Should().NotBeNull();
            result.GriddedData.Should().NotBeEmpty();
        }
Ejemplo n.º 4
0
        public void StationOffsetTRexRequest_Unsuccessful(
            Guid projectUid, FilterResult filter,
            bool reportElevation, bool reportCmv, bool reportMdp, bool reportPassCount, bool reportTemperature, bool reportCutFill,
            Guid?cutFillDesignUid, double?cutfillDesignOffset, Guid alignmentDesignUid,
            double crossSectionInterval, double startStation, double endStation, double[] offsets,
            string errorMessage)
        {
            var request = CompactionReportStationOffsetTRexRequest.CreateRequest(
                projectUid, filter,
                reportElevation, reportCmv, reportMdp, reportPassCount, reportTemperature, reportCutFill,
                cutFillDesignUid, cutfillDesignOffset, alignmentDesignUid,
                crossSectionInterval, startStation, endStation, offsets, null, null);
            var ex = Assert.Throws <ServiceException>(() => request.Validate());

            Assert.Equal(HttpStatusCode.BadRequest, ex.Code);
            Assert.Equal(ContractExecutionStatesEnum.ValidationError, ex.GetResult.Code);
            Assert.Equal(errorMessage, ex.GetResult.Message);
        }
Ejemplo n.º 5
0
        public void ValidateReportData_AlignmentFailed(Guid projectUid, Guid?cutFillDesignUid, double?cutFillDesignOffset, Guid alignmentDesignUid)
        {
            var mockSiteModel  = new Mock <ISiteModel>();
            var mockSiteModels = new Mock <ISiteModels>();

            mockSiteModels.Setup(x => x.GetSiteModel(It.IsAny <Guid>(), It.IsAny <bool>())).Returns(mockSiteModel.Object);

            var mockDesigns       = new Mock <IDesigns>();
            var mockDesignManager = new Mock <IDesignManager>();

            mockDesignManager.Setup(x => x.List(It.IsAny <Guid>())).Returns(mockDesigns.Object);
            mockDesigns.Setup(x => x.Locate(It.IsAny <Guid>())).Returns((IDesign)null);

            var mockAlignments       = new Mock <IAlignments>();
            var mockAlignmentManager = new Mock <IAlignmentManager>();

            mockAlignmentManager.Setup(x => x.List(It.IsAny <Guid>())).Returns(mockAlignments.Object);
            mockAlignments.Setup(x => x.Locate(It.IsAny <Guid>())).Returns((IAlignment)null);

            DIBuilder
            .New()
            .AddLogging()
            .Add(x => x.AddSingleton <ISiteModels>(mockSiteModels.Object))
            .Add(x => x.AddSingleton <IDesignManager>(mockDesignManager.Object))
            .Add(x => x.AddSingleton <IAlignmentManager>(mockAlignmentManager.Object))
            .Add(x => x.AddTransient <IReportDataValidationUtility, ReportDataValidationUtility>())
            .Complete();

            var request = CompactionReportStationOffsetTRexRequest.CreateRequest(
                projectUid, null,
                true, true, true, true, true, true,
                cutFillDesignUid, cutFillDesignOffset, alignmentDesignUid,
                2.0, 100, 200, new[] { -1.0, 0, 1.3 }, null, null);

            var ex = Assert.Throws <ServiceException>(() => DIContext.Obtain <IReportDataValidationUtility>().ValidateData(nameof(ValidateReportData_AlignmentFailed), request.ProjectUid, request));

            Assert.Equal(System.Net.HttpStatusCode.BadRequest, ex.Code);
            Assert.Equal(ContractExecutionStatesEnum.ValidationError, ex.GetResult.Code);
            Assert.Equal($"Alignment design {alignmentDesignUid} is not found.", ex.GetResult.Message);
        }
Ejemplo n.º 6
0
        public void ValidateReportData_AlignmentIncludingCutFill_Success(Guid projectUid, Guid cutFillDesignUid, double?cutFillDesignOffset, Guid alignmentDesignUid)
        {
            var mockSiteModel  = new Mock <ISiteModel>();
            var mockSiteModels = new Mock <ISiteModels>();

            mockSiteModels.Setup(x => x.GetSiteModel(It.IsAny <Guid>(), It.IsAny <bool>())).Returns(mockSiteModel.Object);

            var mockDesign        = new Mock <IDesign>();
            var mockDesigns       = new Mock <IDesigns>();
            var mockDesignManager = new Mock <IDesignManager>();

            mockDesignManager.Setup(x => x.List(It.IsAny <Guid>())).Returns(mockDesigns.Object);
            mockDesigns.Setup(x => x.Locate(It.IsAny <Guid>())).Returns(mockDesign.Object);

            var mockAlignment        = new Mock <IAlignment>();
            var mockAlignments       = new Mock <IAlignments>();
            var mockAlignmentManager = new Mock <IAlignmentManager>();

            mockAlignmentManager.Setup(x => x.List(It.IsAny <Guid>())).Returns(mockAlignments.Object);
            mockAlignments.Setup(x => x.Locate(It.IsAny <Guid>())).Returns(mockAlignment.Object);

            DIBuilder
            .New()
            .AddLogging()
            .Add(x => x.AddSingleton <ISiteModels>(mockSiteModels.Object))
            .Add(x => x.AddSingleton <IDesignManager>(mockDesignManager.Object))
            .Add(x => x.AddSingleton <IAlignmentManager>(mockAlignmentManager.Object))
            .Add(x => x.AddTransient <IReportDataValidationUtility, ReportDataValidationUtility>())
            .Complete();

            var request = CompactionReportStationOffsetTRexRequest.CreateRequest(
                projectUid, null,
                true, true, true, true, true, true,
                cutFillDesignUid, cutFillDesignOffset, alignmentDesignUid,
                2.0, 100, 200, new[] { -1.0, 0, 1.3 }, null, null);

            var isOk = DIContext.Obtain <IReportDataValidationUtility>().ValidateData(nameof(ValidateReportData_AlignmentIncludingCutFill_Success), request.ProjectUid, request);

            Assert.True(isOk);
        }
Ejemplo n.º 7
0
        public void MapStationOffsetRequestToResult(
            Guid projectUid, FilterResult filter,
            bool reportElevation, bool reportCmv, bool reportMdp, bool reportPassCount, bool reportTemperature, bool reportCutFill,
            Guid?cutFillDesignUid, double?cutfillDesignOffset, Guid alignmentDesignUid,
            double crossSectionInterval, double startStation, double endStation, double[] offsets)
        {
            var request = CompactionReportStationOffsetTRexRequest.CreateRequest(
                projectUid, filter,
                reportElevation, reportCmv, reportMdp, reportPassCount, reportTemperature, reportCutFill,
                cutFillDesignUid, cutfillDesignOffset, alignmentDesignUid,
                crossSectionInterval, startStation, endStation, offsets, null, null);

            var result = AutoMapperUtility.Automapper.Map <StationOffsetReportData_ApplicationService>(request);

            Assert.Equal(request.ReportElevation, result.ReportElevation);
            Assert.Equal(request.ReportCutFill, result.ReportCutFill);
            Assert.Equal(request.ReportCmv, result.ReportCmv);
            Assert.Equal(request.ReportMdp, result.ReportMdp);
            Assert.Equal(request.ReportPassCount, result.ReportPassCount);
            Assert.Equal(request.ReportTemperature, result.ReportTemperature);
            Assert.Equal(0, result.NumberOfRows);
            Assert.NotNull(result.Rows);
        }
Ejemplo n.º 8
0
        public async Task StationOffsetReportExecutor_SiteModelNotFound()
        {
            var          projectUid           = Guid.NewGuid();
            FilterResult filter               = null;
            bool         reportElevation      = true;
            bool         reportCmv            = true;
            bool         reportMdp            = true;
            bool         reportPassCount      = true;
            bool         reportTemperature    = true;
            bool         reportCutFill        = false;
            Guid?        cutFillDesignUid     = null;
            double?      cutFillDesignOffset  = null;
            var          alignmentDesignUid   = Guid.NewGuid();
            double       crossSectionInterval = 1.0;
            double       startStation         = 100;
            double       endStation           = 200;
            var          offsets              = new double[] { -1, 0, 1 };

            var request = CompactionReportStationOffsetTRexRequest.CreateRequest(
                projectUid, filter,
                reportElevation, reportCmv, reportMdp, reportPassCount, reportTemperature, reportCutFill,
                cutFillDesignUid, cutFillDesignOffset, alignmentDesignUid,
                crossSectionInterval, startStation, endStation, offsets, null, null);

            request.Validate();

            var executor = RequestExecutorContainer
                           .Build <StationOffsetReportExecutor>(DIContext.Obtain <IConfigurationStore>(),
                                                                DIContext.Obtain <ILoggerFactory>(),
                                                                DIContext.Obtain <IServiceExceptionHandler>());
            var result = await Assert.ThrowsAsync <ServiceException>(() => executor.ProcessAsync(request));

            Assert.Equal(HttpStatusCode.BadRequest, result.Code);
            Assert.Equal(ContractExecutionStatesEnum.InternalProcessingError, result.GetResult.Code);
            Assert.Equal($"Site model {projectUid} is unavailable", result.GetResult.Message);
        }