Esempio n. 1
0
        public async Task CSVExportExecutor_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;
            double?gridInterval        = null;
            var    gridReportOption    = GridReportOption.Automatic;
            double startNorthing       = 800000;
            double startEasting        = 400000;
            double endNorthing         = 800010;
            double endEasting          = 400010;
            double azimuth             = 4;

            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 = new CompactionReportGridTRexRequest(
                siteModel.ID, filterResult,
                reportElevation, reportCmv, reportMdp, reportPassCount, reportTemperature, reportCutFill,
                cutFillDesignUid, cutFillDesignOffset,
                gridInterval, gridReportOption, startNorthing, startEasting, endNorthing, endEasting, azimuth, null, null);

            request.Validate();

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

            mockCompute.Setup(x => x.ApplyAsync(It.IsAny <GriddedReportRequestComputeFunc>(), It.IsAny <GriddedReportRequestArgument>(), It.IsAny <CancellationToken>())).Returns((GriddedReportRequestComputeFunc func, GriddedReportRequestArgument argument, CancellationToken token) => Task.FromResult(new GriddedReportRequestResponse()));

            var executor = RequestExecutorContainer
                           .Build <GriddedReportExecutor>(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();
        }
Esempio n. 2
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();
        }
Esempio n. 3
0
        public async Task CSVExportExecutor_GotFilterWithContributingMachines()
        {
            var fileName   = "gotAFilename";
            var coordType  = CoordType.Northeast;
            var outputType = OutputTypes.VedaAllPasses;

            string[] machineNames         = { "first machineName" };
            var      userPreferences      = new UserPreferences();
            var      contributingMachines = new List <MachineDetails>()
            {
                new MachineDetails(Consts.NULL_LEGACY_ASSETID, "Machine Name", false, Guid.NewGuid())
            };
            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), "", "",
                contributingMachines, null, ElevationType.First, null, null, null, null
                );
            var filterResult = new FilterResult(null, filter, null, null, null, null, null, null, null);
            var siteModel    = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();

            var request = new CompactionVetaExportRequest(
                siteModel.ID, filterResult, fileName,
                coordType, outputType, userPreferences, machineNames, null, null);

            request.Validate();
            var compactionCSVExportRequest = AutoMapperUtility.Automapper.Map <CompactionCSVExportRequest>(request);

            // Mock the CSV export request functionality to return a null CSV export reponse to stimulate tyhe desired internal processing error
            var mockCompute = IgniteMock.Immutable.mockCompute;

            mockCompute.Setup(x => x.ApplyAsync(It.IsAny <CSVExportRequestComputeFunc>(), It.IsAny <CSVExportRequestArgument>(), It.IsAny <CancellationToken>())).Returns((CSVExportRequestComputeFunc func, CSVExportRequestArgument argument, CancellationToken token) => Task.FromResult <CSVExportRequestResponse>(null));

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

            result.Code.Should().Be(HttpStatusCode.InternalServerError);
            result.GetResult.Code.Should().Be(ContractExecutionStatesEnum.InternalProcessingError);
            result.GetResult.Message.Should().Be("Failed to complete TRex request: CSVExportExecutor with error: Failed to configure internal pipeline.");
        }
Esempio n. 4
0
        public void CSVExportHelper_DateRangeFromFilter()
        {
            var filter = new Productivity3D.Filter.Abstractions.Models.Filter(
                DateTime.SpecifyKind(new DateTime(2019, 1, 10), DateTimeKind.Utc),
                null, "", "",
                new List <MachineDetails>(), null, null, null, null, null, null
                );
            var filterResult = new FilterResult(null, filter, null, null, null, null, null, null, null);

            var siteModel = DIContext.Obtain <ISiteModels>().GetSiteModel(DITagFileFixture.NewSiteModelGuid, true);
            var machine   = siteModel.Machines.CreateNew("Test Machine 1", "", MachineType.Dozer, DeviceTypeEnum.SNM940, false, Guid.NewGuid());
            var startTime = DateTime.UtcNow.AddHours(-5);
            var endTime   = startTime.AddHours(2);

            siteModel.MachinesTargetValues[machine.InternalSiteModelMachineIndex].StartEndRecordedDataEvents.PutValueAtDate(startTime, ProductionEventType.StartEvent);
            siteModel.MachinesTargetValues[machine.InternalSiteModelMachineIndex].StartEndRecordedDataEvents.PutValueAtDate(endTime, ProductionEventType.EndEvent);

            var startEndDate = CSVExportHelper.GetDateRange(siteModel, filterResult);

            filter.StartUtc.Should().NotBeNull();
            startEndDate.startUtc.Should().Be(filter.StartUtc.Value);
            startEndDate.endUtc.Should().Be(endTime);
        }