Пример #1
0
        public void MapFilterResultHasMachineDirectionFilterToCombinedFilter()
        {
            var filter       = new Filter(forwardDirection: true);
            var filterResult = new FilterResult(filter: filter, returnEarliest: true);

            filterResult.Validate();

            var combinedFilter = AutoMapperUtility.Automapper.Map <CombinedFilter>(filterResult);

            combinedFilter.AttributeFilter.HasMachineDirectionFilter.Should().BeTrue();
            combinedFilter.AttributeFilter.MachineDirection.Should().Be(MachineDirection.Forward);

            filter         = new Filter(forwardDirection: false);
            filterResult   = new FilterResult(filter: filter, returnEarliest: true);
            combinedFilter = AutoMapperUtility.Automapper.Map <CombinedFilter>(filterResult);
            combinedFilter.AttributeFilter.HasMachineDirectionFilter.Should().BeTrue();
            combinedFilter.AttributeFilter.MachineDirection.Should().Be(MachineDirection.Reverse);

            filter = new Filter(
                null, null, null, null,
                new List <MachineDetails>(0), null, null,
                null, null, null, null
                );
            filterResult   = new FilterResult(filter: filter, returnEarliest: true);
            combinedFilter = AutoMapperUtility.Automapper.Map <CombinedFilter>(filterResult);
            combinedFilter.AttributeFilter.HasMachineDirectionFilter.Should().BeFalse();
            combinedFilter.AttributeFilter.MachineDirection.Should().Be(MachineDirection.Unknown);
        }
Пример #2
0
        public void MapFilterResultHasMachineFilterToCombinedFilter_WithMachines()
        {
            var contributingMachines = new List <MachineDetails>()
            {
                new MachineDetails(Consts.NULL_LEGACY_ASSETID, "Big yella 1", false, Guid.NewGuid()), new MachineDetails(Consts.NULL_LEGACY_ASSETID, "Big yella 2", true, Guid.NewGuid())
            };
            var filter       = new Filter(contributingMachines: contributingMachines);
            var filterResult = new FilterResult(filter: filter);

            filterResult.Validate();

            var combinedFilter = AutoMapperUtility.Automapper.Map <CombinedFilter>(filterResult);

            combinedFilter.AttributeFilter.HasMachineFilter.Should().BeTrue();
            combinedFilter.AttributeFilter.MachinesList.Length.Should().Be(2);
            combinedFilter.AttributeFilter.MachinesList[0].Should().Be((Guid)(contributingMachines[0].AssetUid ?? null));
            combinedFilter.AttributeFilter.MachinesList[1].Should().Be((Guid)(contributingMachines[1].AssetUid ?? null));

            var siteModel = DIContext.Obtain <ISiteModels>().GetSiteModel(DITagFileFixture.NewSiteModelGuid, true);

            siteModel.Machines.CreateNew("Test Machine 1", "", MachineType.Dozer, DeviceTypeEnum.SNM940, false, Guid.NewGuid());
            siteModel.Machines.CreateNew("Test Machine 2", "", MachineType.Dozer, DeviceTypeEnum.SNM940, false, Guid.NewGuid());
            siteModel.Machines.CreateNew("Test Machine 3", "", MachineType.Dozer, DeviceTypeEnum.SNM940, false, contributingMachines[0].AssetUid.Value);

            combinedFilter.AttributeFilter.SiteModel = siteModel;
            var internalMachineIdBitArray = combinedFilter.AttributeFilter.GetMachineIDsSet();

            internalMachineIdBitArray.Should().NotBeNull();
            internalMachineIdBitArray.Count.Should().Be(3);
            internalMachineIdBitArray[0].Should().BeFalse();
            internalMachineIdBitArray[1].Should().BeFalse();
            internalMachineIdBitArray[2].Should().BeTrue();
        }
Пример #3
0
        public void MapFilterResultWithPolygonToCombinedFilter()
        {
            var polygonLonLat = new List <WGSPoint> {
                new WGSPoint(1, 1), new WGSPoint(2, 2), new WGSPoint(3, 3)
            };
            var filterResult = new FilterResult(polygonLL: polygonLonLat, returnEarliest: true);

            filterResult.Validate();

            var combinedFilter = AutoMapperUtility.Automapper.Map <CombinedFilter>(filterResult);

            combinedFilter.AttributeFilter.Should().NotBeNull();
            combinedFilter.AttributeFilter.ReturnEarliestFilteredCellPass.Should().BeTrue();

            combinedFilter.AttributeFilter.SurveyedSurfaceExclusionList.Should().NotBeNull();
            combinedFilter.AttributeFilter.SurveyedSurfaceExclusionList.Should().BeEmpty();

            combinedFilter.SpatialFilter.Should().NotBeNull();
            combinedFilter.SpatialFilter.CoordsAreGrid.Should().BeFalse();
            combinedFilter.SpatialFilter.IsSpatial.Should().BeTrue();
            combinedFilter.SpatialFilter.Fence.Should().NotBeNull();
            combinedFilter.SpatialFilter.Fence.Points.Should().NotBeNull();
            combinedFilter.SpatialFilter.Fence.Points.Count.Should().Be(polygonLonLat.Count);
            for (int i = 0; i < combinedFilter.SpatialFilter.Fence.Points.Count; i++)
            {
                combinedFilter.SpatialFilter.Fence.Points[i].X.Should().Be(filterResult.PolygonLL[i].Lon);
                combinedFilter.SpatialFilter.Fence.Points[i].Y.Should().Be(filterResult.PolygonLL[i].Lat);
            }
        }
Пример #4
0
        public void MapFilterResultHasNoFiltersToCombinedFilter()
        {
            var filterResult = new FilterResult(filter: new Filter());

            filterResult.Validate();

            var combinedFilter = AutoMapperUtility.Automapper.Map <CombinedFilter>(filterResult);

            combinedFilter.AttributeFilter.Should().NotBeNull();

            combinedFilter.AttributeFilter.HasTimeFilter.Should().BeFalse();
            combinedFilter.AttributeFilter.HasMachineFilter.Should().BeFalse();
            combinedFilter.AttributeFilter.HasMachineDirectionFilter.Should().BeFalse();
            combinedFilter.AttributeFilter.HasDesignFilter.Should().BeFalse();
            combinedFilter.AttributeFilter.HasVibeStateFilter.Should().BeFalse();
            combinedFilter.AttributeFilter.HasLayerStateFilter.Should().BeFalse();
            combinedFilter.AttributeFilter.HasElevationMappingModeFilter.Should().BeFalse();
            combinedFilter.AttributeFilter.HasElevationTypeFilter.Should().BeFalse();
            combinedFilter.AttributeFilter.HasGCSGuidanceModeFilter.Should().BeFalse();
            combinedFilter.AttributeFilter.HasGPSAccuracyFilter.Should().BeFalse();
            combinedFilter.AttributeFilter.HasGPSToleranceFilter.Should().BeFalse();
            combinedFilter.AttributeFilter.HasPositioningTechFilter.Should().BeFalse();
            combinedFilter.AttributeFilter.HasLayerIDFilter.Should().BeFalse();
            combinedFilter.AttributeFilter.HasElevationRangeFilter.Should().BeFalse();
            combinedFilter.AttributeFilter.HasPassTypeFilter.Should().BeFalse();
            combinedFilter.AttributeFilter.HasCompactionMachinesOnlyFilter.Should().BeFalse();
            combinedFilter.AttributeFilter.HasTemperatureRangeFilter.Should().BeFalse();
            combinedFilter.AttributeFilter.HasPassCountRangeFilter.Should().BeFalse();
        }
Пример #5
0
        public void MapFilterResultHasVibeStateFilterToCombinedFilter()
        {
            var filter       = new Filter(vibeStateOn: true);
            var filterResult = new FilterResult(filter: filter);

            filterResult.Validate();

            var combinedFilter = AutoMapperUtility.Automapper.Map <CombinedFilter>(filterResult);

            combinedFilter.AttributeFilter.HasVibeStateFilter.Should().BeTrue();
        }
Пример #6
0
        public void MapFilterResultHasLayerIdFilterToCombinedFilter()
        {
            var layerType    = FilterLayerMethod.TagfileLayerNumber;
            var filter       = new Filter(layerNumber: 45);
            var filterResult = new FilterResult(filter: filter, layerType: layerType, returnEarliest: true);

            filterResult.Validate();

            var combinedFilter = AutoMapperUtility.Automapper.Map <CombinedFilter>(filterResult);

            combinedFilter.AttributeFilter.HasLayerIDFilter.Should().BeTrue();
            combinedFilter.AttributeFilter.LayerID.Should().Be(45);
        }
Пример #7
0
        public void MapFilterResultHasPassCountRangeFilterToCombinedFilter()
        {
            var filter       = new Filter(passCountRangeMin: 34, passCountRangeMax: 89);
            var filterResult = new FilterResult(filter: filter, returnEarliest: true);

            filterResult.Validate();

            var combinedFilter = AutoMapperUtility.Automapper.Map <CombinedFilter>(filterResult);

            combinedFilter.AttributeFilter.HasPassCountRangeFilter.Should().BeTrue();
            combinedFilter.AttributeFilter.PassCountRangeMin.Should().Be(34);
            combinedFilter.AttributeFilter.PassCountRangeMax.Should().Be(89);
        }
Пример #8
0
        public void MapFilterResultHasMachineDesignFilterToCombinedFilter()
        {
            var onMachineDesignId = 66;
            var filter            = new Filter(onMachineDesignId: onMachineDesignId);
            var filterResult      = new FilterResult(filter: filter, returnEarliest: true);

            filterResult.Validate();

            var combinedFilter = AutoMapperUtility.Automapper.Map <CombinedFilter>(filterResult);

            combinedFilter.AttributeFilter.HasDesignFilter.Should().BeTrue();
            combinedFilter.AttributeFilter.DesignNameID.Should().Be(onMachineDesignId);
        }
Пример #9
0
        public void MapFilterResultHasGCSGuidanceModeFilterToCombinedFilter()
        {
            var automaticsType = AutomaticsType.Automatics;
            var filter         = new Filter(automaticsType: automaticsType);
            var filterResult   = new FilterResult(filter: filter, returnEarliest: true);

            filterResult.Validate();

            var combinedFilter = AutoMapperUtility.Automapper.Map <CombinedFilter>(filterResult);

            combinedFilter.AttributeFilter.HasGCSGuidanceModeFilter.Should().BeTrue();
            combinedFilter.AttributeFilter.GCSGuidanceMode.Should().Be(automaticsType);
        }
Пример #10
0
        public void MapFilterResultHasElevationTypeFilterToCombinedFilter()
        {
            var filter       = new Filter(elevationType: MasterData.Models.Models.ElevationType.First);
            var filterResult = new FilterResult(filter: filter, returnEarliest: true);

            filterResult.Validate();

            var combinedFilter = AutoMapperUtility.Automapper.Map <CombinedFilter>(filterResult);

            combinedFilter.AttributeFilter.Should().NotBeNull();
            combinedFilter.AttributeFilter.ReturnEarliestFilteredCellPass.Should().BeTrue();
            combinedFilter.AttributeFilter.HasElevationTypeFilter.Should().BeTrue();
            combinedFilter.AttributeFilter.ElevationType.Should().Be(ElevationType.First);
        }
Пример #11
0
        public void Initialize(ILogger log, IConfigurationStore configurationStore, IFileImportProxy fileImportProxy, ICompactionSettingsManager settingsManager, Guid?projectUid, long projectId, CompactionProjectSettings projectSettings, CompactionProjectSettingsColors projectSettingsColors, IHeaderDictionary headers, FilterResult filter, DesignDescriptor designDescriptor)
        {
            filter?.Validate(); // Should be moved to FilterResult.CreateFilterObsolete().

            Log = log;
            ConfigurationStore = configurationStore;
            FileImportProxy    = fileImportProxy;
            SettingsManager    = settingsManager;

            ProjectUid            = projectUid;
            ProjectId             = projectId;
            Headers               = headers;
            ProjectSettings       = projectSettings;
            ProjectSettingsColors = projectSettingsColors;
            Filter           = filter;
            DesignDescriptor = designDescriptor;
        }
Пример #12
0
        public void MapFilterResultHasExcludedSurveyedSurfacesToCombinedFilter()
        {
            var id1         = Guid.NewGuid();
            var id2         = Guid.NewGuid();
            var excludedIds = new List <Guid> {
                id1, id2
            };
            var filterResult = new FilterResult(excludedSurveyedSurfaceUids: excludedIds, returnEarliest: true);

            filterResult.Validate();

            var combinedFilter = AutoMapperUtility.Automapper.Map <CombinedFilter>(filterResult);

            combinedFilter.AttributeFilter.SurveyedSurfaceExclusionList.Should().NotBeNull();
            combinedFilter.AttributeFilter.SurveyedSurfaceExclusionList.Length.Should().Be(excludedIds.Count);
            combinedFilter.AttributeFilter.SurveyedSurfaceExclusionList[0].Should().Be(id1);
            combinedFilter.AttributeFilter.SurveyedSurfaceExclusionList[1].Should().Be(id2);
        }
Пример #13
0
        public void MapFilterResultHasTimeFilterToCombinedFilter()
        {
            var filter = new Filter(
                startUtc: DateTime.SpecifyKind(new DateTime(2018, 1, 10), DateTimeKind.Utc),
                endUtc: DateTime.SpecifyKind(new DateTime(2019, 2, 11), DateTimeKind.Utc)
                );
            var filterResult = new FilterResult(filter: filter);

            filterResult.Validate();

            var combinedFilter = AutoMapperUtility.Automapper.Map <CombinedFilter>(filterResult);

            combinedFilter.AttributeFilter.Should().NotBeNull();

            combinedFilter.AttributeFilter.HasTimeFilter.Should().BeTrue();
            combinedFilter.AttributeFilter.StartTime.Should().Be((DateTime)(filter.StartUtc ?? null));
            combinedFilter.AttributeFilter.EndTime.Should().Be((DateTime)(filter.EndUtc ?? null));
        }
Пример #14
0
        public void MapFilterResultNoPolygonToCombinedFilter()
        {
            var filterResult = new FilterResult(returnEarliest: true);

            filterResult.Validate();

            var combinedFilter = AutoMapperUtility.Automapper.Map <CombinedFilter>(filterResult);

            combinedFilter.AttributeFilter.Should().NotBeNull();
            combinedFilter.AttributeFilter.ReturnEarliestFilteredCellPass.Should().BeTrue();

            combinedFilter.AttributeFilter.SurveyedSurfaceExclusionList.Should().NotBeNull();
            combinedFilter.AttributeFilter.SurveyedSurfaceExclusionList.Should().BeEmpty();

            combinedFilter.SpatialFilter.Should().NotBeNull();
            combinedFilter.SpatialFilter.CoordsAreGrid.Should().BeFalse();
            combinedFilter.SpatialFilter.IsSpatial.Should().BeFalse();
            combinedFilter.SpatialFilter.Fence.Should().BeNull();
        }
Пример #15
0
        public void MapFilterResultHasLayerStateFilterToCombinedFilter()
        {
            FilterLayerMethod?layerType = FilterLayerMethod.Automatic;
            var filter       = new Filter();
            var filterResult = new FilterResult(filter: filter, layerType: layerType, returnEarliest: true);

            filterResult.Validate();

            var combinedFilter = AutoMapperUtility.Automapper.Map <CombinedFilter>(filterResult);

            combinedFilter.AttributeFilter.HasLayerStateFilter.Should().BeTrue();
            combinedFilter.AttributeFilter.LayerState.Should().Be(LayerState.On);

            filterResult = new FilterResult(filter: filter, returnEarliest: true);
            filterResult.Validate();

            combinedFilter = AutoMapperUtility.Automapper.Map <CombinedFilter>(filterResult);
            combinedFilter.AttributeFilter.HasLayerStateFilter.Should().BeFalse();
            combinedFilter.AttributeFilter.LayerState.Should().Be(LayerState.Off);
        }
Пример #16
0
        public void ValidateVolumesFilters(VolumesType computeVolType, FilterResult filter1, long filterId1, FilterResult filter2, long filterId2)
        {
            switch (computeVolType)
            {
            case VolumesType.Between2Filters:
                if ((filter1 == null && filterId1 <= 0) || (filter2 == null && filterId2 <= 0))
                {
                    throw new TwoFiltersRequiredException(HttpStatusCode.BadRequest,
                                                          new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError,
                                                                                      string.Format("Two filters required for filter to filter volumes display")));
                }

                break;

            case VolumesType.BetweenDesignAndFilter:
            case VolumesType.BetweenFilterAndDesign:
                if (filter1 == null && filterId1 <= 0 && filter2 == null && filterId2 <= 0)
                {
                    throw new SingleFilterRequiredException(HttpStatusCode.BadRequest,
                                                            new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError,
                                                                                        string.Format("One filter required for design to filter or filter to design volumes display")));
                }
                break;

            default:
                throw new ServiceException(HttpStatusCode.BadRequest,
                                           new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError,
                                                                       string.Format("This type of volumes calculation is not supported")));
            }
            if (filter1 != null)
            {
                filter1.Validate();
            }

            if (filter2 != null)
            {
                filter2.Validate();
            }
        }
Пример #17
0
        public void MapFilterResultHasMachineFilterToCombinedFilter()
        {
            var contributingMachines = new List <MachineDetails>()
            {
                new MachineDetails(Consts.NULL_LEGACY_ASSETID, "Big yella 1", false, Guid.NewGuid()), new MachineDetails(Consts.NULL_LEGACY_ASSETID, "Big yella 2", true, Guid.NewGuid())
            };
            var filter       = new Filter(contributingMachines: contributingMachines);
            var filterResult = new FilterResult(filter: filter);

            filterResult.Validate();

            var combinedFilter = AutoMapperUtility.Automapper.Map <CombinedFilter>(filterResult);

            combinedFilter.AttributeFilter.HasMachineFilter.Should().BeTrue();
            combinedFilter.AttributeFilter.MachinesList.Length.Should().Be(2);
            combinedFilter.AttributeFilter.MachinesList[0].Should().Be((Guid)(contributingMachines[0].AssetUid ?? null));
            combinedFilter.AttributeFilter.MachinesList[1].Should().Be((Guid)(contributingMachines[1].AssetUid ?? null));

            var internalMachineIdBitArray = combinedFilter.AttributeFilter.GetMachineIDsSet();

            internalMachineIdBitArray.Should().NotBeNull();
            internalMachineIdBitArray.Count.Should().Be(0);
        }