private static void AssertEmptyMapData(MapDataCollection mapDataCollection)
        {
            Assert.AreEqual("Grasbekleding erosie kruin en binnentalud", mapDataCollection.Name);

            List <MapData> mapDataList = mapDataCollection.Collection.ToList();

            Assert.AreEqual(5, mapDataList.Count);

            var referenceLineMapData              = (MapLineData)mapDataList[referenceLineIndex];
            var dikeProfilesMapData               = (MapLineData)mapDataList[dikeProfilesIndex];
            var foreshoreProfilesMapData          = (MapLineData)mapDataList[foreshoreProfilesIndex];
            var hydraulicBoundaryLocationsMapData = (MapPointData)mapDataList[hydraulicBoundaryLocationsIndex];
            var calculationsMapData               = (MapLineData)mapDataList[calculationsIndex];

            CollectionAssert.IsEmpty(referenceLineMapData.Features);
            CollectionAssert.IsEmpty(dikeProfilesMapData.Features);
            CollectionAssert.IsEmpty(foreshoreProfilesMapData.Features);
            CollectionAssert.IsEmpty(hydraulicBoundaryLocationsMapData.Features);
            CollectionAssert.IsEmpty(calculationsMapData.Features);

            Assert.AreEqual("Referentielijn", referenceLineMapData.Name);
            Assert.AreEqual("Dijkprofielen", dikeProfilesMapData.Name);
            Assert.AreEqual("Voorlandprofielen", foreshoreProfilesMapData.Name);
            Assert.AreEqual("Hydraulische belastingen", hydraulicBoundaryLocationsMapData.Name);
            Assert.AreEqual("Berekeningen", calculationsMapData.Name);
        }
Ejemplo n.º 2
0
        public void GivenBackgroundData_WhenBackgroundDataChangedToOtherTypeAndNotified_ThenNewInstanceSetOnBackgroundMapData(
            BackgroundData originalBackgroundData,
            BackgroundData newBackgroundData)
        {
            // Given
            var mocks    = new MockRepository();
            var observer = mocks.StrictMock <IObserver>();

            mocks.ReplayAll();

            using (new UseCustomSettingsHelper(testSettingsHelper))
                using (new UseCustomTileSourceFactoryConfig(new TestTileSourceFactory(BackgroundDataConverter.ConvertFrom(originalBackgroundData))))
                {
                    var riskeerMapControl = new RiskeerMapControl();
                    var mapDataCollection = new MapDataCollection("Collection");

                    riskeerMapControl.SetAllData(mapDataCollection, originalBackgroundData);
                    riskeerMapControl.MapControl.BackgroundMapData.Attach(observer);

                    ImageBasedMapData oldMapData = riskeerMapControl.MapControl.BackgroundMapData;

                    // When
                    originalBackgroundData.Name          = newBackgroundData.Name;
                    originalBackgroundData.IsVisible     = newBackgroundData.IsVisible;
                    originalBackgroundData.Transparency  = newBackgroundData.Transparency;
                    originalBackgroundData.Configuration = newBackgroundData.Configuration;
                    originalBackgroundData.NotifyObservers();

                    // Then
                    Assert.IsNotNull(riskeerMapControl.MapControl.BackgroundMapData);
                    Assert.AreNotSame(oldMapData, riskeerMapControl.MapControl.BackgroundMapData);
                    Assert.AreNotEqual(oldMapData.GetType(), riskeerMapControl.MapControl.BackgroundMapData.GetType());
                    mocks.VerifyAll(); // Expect no observers notified
                }
        }
Ejemplo n.º 3
0
        public void GivenBackgroundData_WhenBackgroundDataChangedButSameTypeAndNotified_ThenBackgroundMapDataUpdatedAndNotified()
        {
            // Given
            var mocks    = new MockRepository();
            var observer = mocks.StrictMock <IObserver>();

            observer.Expect(o => o.UpdateObserver());
            mocks.ReplayAll();

            WmtsMapData    mapData           = WmtsMapDataTestHelper.CreateDefaultPdokMapData();
            BackgroundData backgroundData    = BackgroundDataConverter.ConvertTo(mapData);
            var            mapDataCollection = new MapDataCollection("Collection");

            using (new UseCustomSettingsHelper(testSettingsHelper))
                using (new UseCustomTileSourceFactoryConfig(mapData))
                {
                    var riskeerMapControl = new RiskeerMapControl();
                    riskeerMapControl.SetAllData(mapDataCollection, backgroundData);
                    riskeerMapControl.MapControl.BackgroundMapData.Attach(observer);

                    ImageBasedMapData oldBackgroundMapData = riskeerMapControl.MapControl.BackgroundMapData;

                    // When
                    backgroundData.Transparency = (RoundedDouble)0.3;
                    backgroundData.NotifyObservers();

                    // Then
                    Assert.AreSame(oldBackgroundMapData, riskeerMapControl.MapControl.BackgroundMapData);
                    Assert.AreEqual(0.3, riskeerMapControl.MapControl.BackgroundMapData.Transparency.Value);
                    mocks.VerifyAll();
                }
        }
        public void ContextMenuStrip_EnabledZoomToAllContextMenuItemClicked_DoZoomToVisibleData()
        {
            // Setup
            var mapData             = new MapDataCollection("A");
            var featureBasedMapData = new TestFeatureBasedMapData
            {
                IsVisible = true,
                Features  = new[]
                {
                    new MapFeature(Enumerable.Empty <MapGeometry>())
                }
            };

            mapData.Add(featureBasedMapData);

            var builder = new CustomItemsOnlyContextMenuBuilder();

            contextMenuBuilderProvider.Stub(p => p.Get(null, null)).IgnoreArguments().Return(builder);
            var mapControl = mocks.StrictMock <IMapControl>();

            mapControl.Expect(c => c.Data).Return(mapData);
            mapControl.Expect(c => c.ZoomToVisibleLayers(mapData));
            mocks.ReplayAll();

            mapLegendView.MapControl = mapControl;

            using (ContextMenuStrip contextMenu = info.ContextMenuStrip(GetContext(mapData), null, null))
            {
                // Call
                contextMenu.Items[contextMenuZoomToAllIndex].PerformClick();

                // Assert
                // Assert expectancies are called in TearDown()
            }
        }
Ejemplo n.º 5
0
        public void RemoveAllData_Always_RemovesAllDataFromMapControl()
        {
            // Setup
            var            mapDataCollection = new MapDataCollection("Collection");
            WmtsMapData    backgroundMapData = WmtsMapDataTestHelper.CreateDefaultPdokMapData();
            BackgroundData backgroundData    = BackgroundDataConverter.ConvertTo(backgroundMapData);

            using (new UseCustomSettingsHelper(testSettingsHelper))
                using (new UseCustomTileSourceFactoryConfig(backgroundMapData))
                    using (var riskeerMapControl = new RiskeerMapControl())
                    {
                        riskeerMapControl.SetAllData(mapDataCollection, backgroundData);

                        // Precondition
                        Assert.IsNotNull(riskeerMapControl.MapControl.Data);
                        Assert.IsNotNull(riskeerMapControl.MapControl.BackgroundMapData);

                        // Call
                        riskeerMapControl.RemoveAllData();

                        // Assert
                        Assert.IsNull(riskeerMapControl.MapControl.Data);
                        Assert.IsNull(riskeerMapControl.MapControl.BackgroundMapData);
                    }
        }
        public void ContextMenuStrip_VisibleFeatureBasedMapDataWithFeaturesInMapDataCollection_ZoomToAllItemEnabled()
        {
            // Setup
            var featureBasedMapData = new TestFeatureBasedMapData
            {
                IsVisible = true,
                Features  = new[]
                {
                    new MapFeature(Enumerable.Empty <MapGeometry>())
                }
            };

            var mapDataCollection = new MapDataCollection("test data");

            mapDataCollection.Add(featureBasedMapData);

            using (var treeViewControl = new TreeViewControl())
            {
                var builder = new CustomItemsOnlyContextMenuBuilder();
                contextMenuBuilderProvider.Expect(cmbp => cmbp.Get(null, null)).IgnoreArguments().Return(builder);
                mocks.ReplayAll();

                // Call
                using (ContextMenuStrip contextMenu = info.ContextMenuStrip(GetContext(mapDataCollection), null, treeViewControl))
                {
                    // Assert
                    TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuZoomToAllIndex,
                                                                  "&Zoom naar alles",
                                                                  "Zet het zoomniveau van de kaart dusdanig dat alle zichtbare kaartlagen in deze map met kaartlagen precies in het beeld passen.",
                                                                  Resources.ZoomToAllIcon);
                }
            }
        }
        public void ContextMenuStrip_VisibleFeatureBasedMapDataWithoutFeaturesInMapDataCollection_ZoomToAllItemDisabled()
        {
            // Setup
            var featureBasedMapData = new TestFeatureBasedMapData
            {
                IsVisible = true
            };
            var mapDataCollection = new MapDataCollection("test data");

            mapDataCollection.Add(featureBasedMapData);

            using (var treeViewControl = new TreeViewControl())
            {
                var builder = new CustomItemsOnlyContextMenuBuilder();
                contextMenuBuilderProvider.Expect(cmbp => cmbp.Get(null, null)).IgnoreArguments().Return(builder);
                mocks.ReplayAll();

                // Call
                using (ContextMenuStrip contextMenu = info.ContextMenuStrip(GetContext(mapDataCollection), null, treeViewControl))
                {
                    // Assert
                    TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuZoomToAllIndex,
                                                                  "&Zoom naar alles",
                                                                  "Om het zoomniveau aan te passen moet minstens één van de zichtbare kaartlagen in deze map met kaartlagen elementen bevatten.",
                                                                  Resources.ZoomToAllIcon,
                                                                  false);
                }
            }
        }
        public void OnDrop_MapDataCollectionContextMovedToPositionOutsideRange_ThrowsException(int position)
        {
            // Setup
            var observer = mocks.StrictMock <IObserver>();

            mocks.ReplayAll();

            var mapDataCollection1      = new MapDataCollection("Collection 1");
            var mapDataCollection2      = new MapDataCollection("Collection 2");
            var mapDataCollection3      = new MapDataCollection("Collection 3");
            var parentMapDataCollection = new MapDataCollection("test data");

            parentMapDataCollection.Add(mapDataCollection1);
            parentMapDataCollection.Add(mapDataCollection2);
            parentMapDataCollection.Add(mapDataCollection3);

            parentMapDataCollection.Attach(observer);

            MapDataCollectionContext parentContext = GetContext(parentMapDataCollection);
            MapDataCollectionContext context       = GetContext(mapDataCollection1);

            parentMapDataCollection.Attach(observer);

            using (var treeViewControl = new TreeViewControl())
            {
                // Call
                TestDelegate test = () => info.OnDrop(context, parentContext, parentContext, position, treeViewControl);

                // Assert
                Assert.Throws <ArgumentOutOfRangeException>(test);
            }
        }
        public void ContextMenuStrip_Always_CallsBuilder()
        {
            // Setup
            var mapData = new MapDataCollection("test data");
            MapDataCollectionContext context = GetContext(mapData);

            var builder = mocks.StrictMock <IContextMenuBuilder>();

            using (mocks.Ordered())
            {
                builder.Expect(mb => mb.AddImportItem(null, null, null)).IgnoreArguments().Return(builder);
                builder.Expect(mb => mb.AddSeparator()).Return(builder);
                builder.Expect(mb => mb.AddCustomItem(Arg <StrictContextMenuItem> .Is.NotNull)).Return(builder);
                builder.Expect(mb => mb.AddSeparator()).Return(builder);
                builder.Expect(mb => mb.AddPropertiesItem()).Return(builder);
                builder.Expect(mb => mb.Build()).Return(null);
            }

            contextMenuBuilderProvider.Expect(p => p.Get(context, null)).Return(builder);

            mocks.ReplayAll();

            // Call
            info.ContextMenuStrip(context, null, null);

            // Assert
            // Assert expectancies are called in TearDown()
        }
        public void OnNodeChecked_WithContext_NotifyObserversOfParentMapDataCollections()
        {
            // Setup
            var collectionObserver = mocks.StrictMock <IObserver>();

            collectionObserver.Expect(o => o.UpdateObserver());
            var parentCollectionObserver = mocks.StrictMock <IObserver>();

            parentCollectionObserver.Expect(o => o.UpdateObserver());
            mocks.ReplayAll();

            var featureBasedMapData     = new TestFeatureBasedMapData();
            var nestedMapDataCollection = new MapDataCollection("nested");

            nestedMapDataCollection.Add(featureBasedMapData);
            var mapDataCollection = new MapDataCollection("test");

            mapDataCollection.Add(nestedMapDataCollection);

            MapDataCollectionContext rootCollectionContext   = GetContext(mapDataCollection);
            MapDataCollectionContext nestedCollectionContext = GetContext(nestedMapDataCollection, rootCollectionContext);

            nestedMapDataCollection.Attach(collectionObserver);
            mapDataCollection.Attach(parentCollectionObserver);

            // Call
            info.OnNodeChecked(nestedCollectionContext, null);

            // Assert
            mocks.VerifyAll();
        }
        public void OnDrop_MapDataCollectionContextMovedToPositionInsideRange_SetsNewReverseOrder(int position)
        {
            // Setup
            var observer = mocks.StrictMock <IObserver>();

            observer.Expect(o => o.UpdateObserver());
            mocks.ReplayAll();

            var mapDataCollection1      = new MapDataCollection("Collection 1");
            var mapDataCollection2      = new MapDataCollection("Collection 2");
            var mapDataCollection3      = new MapDataCollection("Collection 3");
            var parentMapDataCollection = new MapDataCollection("test data");

            parentMapDataCollection.Add(mapDataCollection1);
            parentMapDataCollection.Add(mapDataCollection2);
            parentMapDataCollection.Add(mapDataCollection3);

            MapDataCollectionContext parentContext = GetContext(parentMapDataCollection);
            MapDataCollectionContext context       = GetContext(mapDataCollection1);

            parentMapDataCollection.Attach(observer);

            using (var treeViewControl = new TreeViewControl())
            {
                // Call
                info.OnDrop(context, parentContext, parentContext, position, treeViewControl);

                // Assert
                int reversedIndex = 2 - position;
                Assert.AreSame(context.WrappedData, parentMapDataCollection.Collection.ElementAt(reversedIndex));
            }
        }
        public void OnNodeChecked_WithContextAndStateMixed_SetMapDataVisibilityAndNotifyObservers()
        {
            // Setup
            var observer1 = mocks.StrictMock <IObserver>();
            var observer2 = mocks.StrictMock <IObserver>();

            observer2.Expect(o => o.UpdateObserver());
            mocks.ReplayAll();

            var featureBasedMapData1 = new TestFeatureBasedMapData();
            var featureBasedMapData2 = new TestFeatureBasedMapData
            {
                IsVisible = false
            };
            var mapDataCollection = new MapDataCollection("test");

            mapDataCollection.Add(featureBasedMapData1);
            mapDataCollection.Add(featureBasedMapData2);

            MapDataCollectionContext context = GetContext(mapDataCollection);

            featureBasedMapData1.Attach(observer1);
            featureBasedMapData2.Attach(observer2);

            // Call
            info.OnNodeChecked(context, null);

            // Assert
            Assert.IsTrue(context.WrappedData.IsVisible);
            Assert.IsTrue(featureBasedMapData1.IsVisible);
            Assert.IsTrue(featureBasedMapData2.IsVisible);
            mocks.VerifyAll();
        }
        public void OnNodeChecked_WithContext_SetMapDataVisibilityAndNotifyObservers(bool initialVisibleState)
        {
            // Setup
            var collectionObserver = mocks.StrictMock <IObserver>();

            collectionObserver.Expect(o => o.UpdateObserver());
            mocks.ReplayAll();

            var featureBasedMapData = new TestFeatureBasedMapData();
            var mapDataCollection   = new MapDataCollection("test");

            mapDataCollection.Add(featureBasedMapData);

            MapDataCollectionContext context = GetContext(mapDataCollection);

            context.WrappedData.IsVisible = initialVisibleState;

            context.WrappedData.Attach(collectionObserver);

            // Call
            info.OnNodeChecked(context, null);

            // Assert
            Assert.AreEqual(!initialVisibleState, context.WrappedData.IsVisible);
            Assert.AreEqual(!initialVisibleState, featureBasedMapData.IsVisible);
            mocks.VerifyAll();
        }
        public void ChildNodeObjects_Always_ReturnsChildrenWithContextAndDataReversed()
        {
            // Setup
            var mapPointData      = new MapPointData("points");
            var mapLineData       = new MapLineData("lines");
            var nestedCollection  = new MapDataCollection("nested");
            var mapPolygonData    = new MapPolygonData("polygons");
            var mapDataCollection = new MapDataCollection("test data");

            mapDataCollection.Add(mapPointData);
            mapDataCollection.Add(mapLineData);
            mapDataCollection.Add(nestedCollection);
            mapDataCollection.Add(mapPolygonData);

            MapDataCollectionContext parentCollectionContext = GetContext(mapDataCollection);

            // Call
            object[] objects = info.ChildNodeObjects(GetContext(mapDataCollection));

            // Assert
            CollectionAssert.AreEqual(new MapDataContext[]
            {
                new MapPolygonDataContext(mapPolygonData, parentCollectionContext),
                GetContext(nestedCollection, parentCollectionContext),
                new MapLineDataContext(mapLineData, parentCollectionContext),
                new MapPointDataContext(mapPointData, parentCollectionContext)
            }, objects);
        }
        public void Constructor_WithReferenceLine_DataUpdatedToCollectionOfFilledMapData()
        {
            // Setup
            var referenceLine = new ReferenceLine();

            referenceLine.SetGeometry(new[]
            {
                new Point2D(1.0, 2.0),
                new Point2D(2.0, 1.0)
            });

            var assessmentSection = new AssessmentSectionStub
            {
                ReferenceLine = referenceLine
            };

            // Call
            AssessmentSectionReferenceLineView view = ShowCalculationsView(assessmentSection);

            // Assert
            Assert.IsInstanceOf <MapDataCollection>(view.Map.Data);
            MapDataCollection mapData = view.Map.Data;

            Assert.IsNotNull(mapData);

            MapData referenceLineMapData = mapData.Collection.ElementAt(referenceLineIndex);

            MapDataTestHelper.AssertReferenceLineMapData(referenceLine, referenceLineMapData);
            Assert.IsTrue(referenceLineMapData.IsVisible);
        }
Ejemplo n.º 16
0
        public void GivenConfiguredWellKnownBackgroundData_WhenTileSourceChangedAndNotified_ThenBackgroundMapDataUpdatedAndNotified()
        {
            // Given
            var mocks    = new MockRepository();
            var observer = mocks.StrictMock <IObserver>();

            observer.Expect(o => o.UpdateObserver());
            mocks.ReplayAll();

            var            mapData           = new WellKnownTileSourceMapData(WellKnownTileSource.BingAerial);
            BackgroundData backgroundData    = BackgroundDataConverter.ConvertTo(mapData);
            var            mapDataCollection = new MapDataCollection("Collection");

            using (new UseCustomSettingsHelper(testSettingsHelper))
                using (new UseCustomTileSourceFactoryConfig(mapData))
                {
                    var riskeerMapControl = new RiskeerMapControl();
                    riskeerMapControl.SetAllData(mapDataCollection, backgroundData);
                    riskeerMapControl.MapControl.BackgroundMapData.Attach(observer);

                    ImageBasedMapData oldBackgroundMapData = riskeerMapControl.MapControl.BackgroundMapData;

                    // When
                    backgroundData.Configuration = new WellKnownBackgroundDataConfiguration(RiskeerWellKnownTileSource.BingRoads);
                    backgroundData.NotifyObservers();

                    // Then
                    Assert.AreSame(oldBackgroundMapData, riskeerMapControl.MapControl.BackgroundMapData);

                    var newWellKnownMapData = (WellKnownTileSourceMapData)riskeerMapControl.MapControl.BackgroundMapData;
                    Assert.AreEqual(WellKnownTileSource.BingRoads, newWellKnownMapData.TileSource);
                    mocks.VerifyAll();
                }
        }
        private void CreateMapData()
        {
            mapDataCollection    = new MapDataCollection(FailureMechanism.Name);
            referenceLineMapData = RiskeerMapDataFactory.CreateReferenceLineMapData();
            hydraulicBoundaryLocationsMapLayer = new HydraulicBoundaryLocationsMapLayer(AssessmentSection);

            MapDataCollection sectionsMapDataCollection = RiskeerMapDataFactory.CreateSectionsMapDataCollection();

            sectionsMapData           = RiskeerMapDataFactory.CreateFailureMechanismSectionsMapData();
            sectionsStartPointMapData = RiskeerMapDataFactory.CreateFailureMechanismSectionsStartPointMapData();
            sectionsEndPointMapData   = RiskeerMapDataFactory.CreateFailureMechanismSectionsEndPointMapData();

            assemblyResultMapLayer = new NonCalculatableFailureMechanismSectionResultsMapLayer <TSectionResult>(
                FailureMechanism, performAssemblyFunc);

            mapDataCollection.Add(referenceLineMapData);

            sectionsMapDataCollection.Add(sectionsMapData);
            sectionsMapDataCollection.Add(sectionsStartPointMapData);
            sectionsMapDataCollection.Add(sectionsEndPointMapData);
            mapDataCollection.Add(sectionsMapDataCollection);

            mapDataCollection.Add(assemblyResultMapLayer.MapData);
            mapDataCollection.Add(hydraulicBoundaryLocationsMapLayer.MapData);
        }
        /// <summary>
        /// Creates a new instance of <see cref="AssemblyResultPerSectionMapView"/>.
        /// </summary>
        /// <param name="assessmentSection">The <see cref="AssessmentSection"/> to create the view for.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="assessmentSection"/>
        /// is <c>null</c>.</exception>
        public AssemblyResultPerSectionMapView(AssessmentSection assessmentSection)
        {
            if (assessmentSection == null)
            {
                throw new ArgumentNullException(nameof(assessmentSection));
            }

            InitializeComponent();

            AssessmentSection = assessmentSection;

            CreateObservers();

            var mapDataCollection = new MapDataCollection(Resources.AssemblyResultPerSectionMapView_DisplayName);

            assemblyResultsMapData             = CombinedSectionAssemblyMapDataFactory.CreateCombinedSectionAssemblyResultMapData();
            referenceLineMapData               = RiskeerMapDataFactory.CreateReferenceLineMapData();
            hydraulicBoundaryLocationsMapLayer = new HydraulicBoundaryLocationsMapLayer(assessmentSection);

            mapDataCollection.Add(referenceLineMapData);
            mapDataCollection.Add(hydraulicBoundaryLocationsMapLayer.MapData);
            mapDataCollection.Add(assemblyResultsMapData);

            SetAllMapDataFeatures();

            riskeerMapControl.SetAllData(mapDataCollection, assessmentSection.BackgroundData);
        }
        public void GetFeatureBasedMapDataRecursively_CollectionWithNestedData_ReturnAllFeatureBasedMapData()
        {
            // Setup
            var line             = new MapLineData("line");
            var polygon          = new MapPolygonData("polygon");
            var nestedCollection = new MapDataCollection("nested");

            nestedCollection.Add(line);
            nestedCollection.Add(polygon);

            var collection = new MapDataCollection("test");
            var point      = new MapPointData("point");

            collection.Add(point);
            collection.Add(nestedCollection);

            // Call
            FeatureBasedMapData[] featureBasedMapDatas = collection.GetFeatureBasedMapDataRecursively().ToArray();

            // Assert
            Assert.AreEqual(3, featureBasedMapDatas.Length);
            Assert.IsInstanceOf <MapPointData>(featureBasedMapDatas[0]);
            Assert.IsInstanceOf <MapLineData>(featureBasedMapDatas[1]);
            Assert.IsInstanceOf <MapPolygonData>(featureBasedMapDatas[2]);
        }
Ejemplo n.º 20
0
        public void GivenMapLegendView_WhenSelectedNodeChanged_SelectionChangedFired()
        {
            // Given
            var mapData           = new MapPointData("test");
            var mapDataCollection = new MapDataCollection("collection");

            mapDataCollection.Add(mapData);

            using (var view = new MapLegendView(contextMenuBuilderProvider)
            {
                Data = mapDataCollection
            })
            {
                var treeViewControl = TypeUtils.GetField <TreeViewControl>(view, "treeViewControl");
                WindowsFormsTestHelper.Show(treeViewControl);

                var selectionChangedCount = 0;
                view.SelectionChanged += (sender, args) => selectionChangedCount++;

                // When
                var context = new MapPointDataContext(mapData, new MapDataCollectionContext(mapDataCollection, null));
                treeViewControl.TrySelectNodeForData(context);

                // Then
                Assert.AreEqual(1, selectionChangedCount);
            }

            WindowsFormsTestHelper.CloseAll();
        }
Ejemplo n.º 21
0
        public void Selection_Always_ReturnsDataContext()
        {
            // Setup
            var mapData           = new TestFeatureBasedMapData();
            var mapDataCollection = new MapDataCollection("collection");

            mapDataCollection.Add(mapData);

            using (var view = new MapLegendView(contextMenuBuilderProvider)
            {
                Data = mapDataCollection
            })
            {
                var treeViewControl = TypeUtils.GetField <TreeViewControl>(view, "treeViewControl");
                WindowsFormsTestHelper.Show(treeViewControl);
                treeViewControl.TrySelectNodeForData(view.Data);

                // Call
                var selection = (MapDataCollectionContext)view.Selection;

                // Assert
                Assert.AreSame(mapDataCollection, selection.WrappedData);
            }

            WindowsFormsTestHelper.CloseAll();
        }
        public void GivenViewWithSpecificFailureMechanismData_WhenFailureMechanismNameUpdatedAndNotified_ThenMapDataUpdatedAndObserversNotified()
        {
            // Given
            var mocks    = new MockRepository();
            var observer = mocks.StrictMock <IObserver>();

            observer.Expect(obs => obs.UpdateObserver());
            mocks.ReplayAll();

            var assessmentSection = new AssessmentSectionStub();
            var failureMechanism  = new SpecificFailureMechanism();

            SpecificFailureMechanismView view    = CreateView(failureMechanism, assessmentSection);
            MapDataCollection            mapData = view.Map.Data;

            mapData.Attach(observer);

            // Precondition
            Assert.AreEqual(failureMechanism.Name, mapData.Name);

            // When
            const string newFailureMechanismName = "New Failure Mechanism Name";

            failureMechanism.Name = newFailureMechanismName;
            failureMechanism.NotifyObservers();

            // Then
            Assert.AreEqual(newFailureMechanismName, mapData.Name);
            mocks.VerifyAll();
        }
        private static void AssertEmptyMapData(MapDataCollection mapDataCollection)
        {
            Assert.AreEqual("Betrouwbaarheid sluiting kunstwerk", mapDataCollection.Name);

            List <MapData> mapDataList = mapDataCollection.Collection.ToList();

            Assert.AreEqual(5, mapDataList.Count);

            var referenceLineMapData              = (MapLineData)mapDataList[referenceLineIndex];
            var foreshoreProfilesMapData          = (MapLineData)mapDataList[foreshoreProfilesIndex];
            var structuresMapData                 = (MapPointData)mapDataList[structuresIndex];
            var hydraulicBoundaryLocationsMapData = (MapPointData)mapDataList[hydraulicBoundaryLocationsIndex];
            var calculationsMapData               = (MapLineData)mapDataList[calculationsIndex];

            CollectionAssert.IsEmpty(referenceLineMapData.Features);
            CollectionAssert.IsEmpty(foreshoreProfilesMapData.Features);
            CollectionAssert.IsEmpty(structuresMapData.Features);
            CollectionAssert.IsEmpty(hydraulicBoundaryLocationsMapData.Features);
            CollectionAssert.IsEmpty(calculationsMapData.Features);

            Assert.AreEqual("Referentielijn", referenceLineMapData.Name);
            Assert.AreEqual("Voorlandprofielen", foreshoreProfilesMapData.Name);
            Assert.AreEqual("Kunstwerken", structuresMapData.Name);
            Assert.AreEqual("Hydraulische belastingen", hydraulicBoundaryLocationsMapData.Name);
            Assert.AreEqual("Berekeningen", calculationsMapData.Name);
        }
Ejemplo n.º 24
0
        protected override void CreateMapData()
        {
            base.CreateMapData();

            assemblyResultMapLayer = new CalculatableFailureMechanismSectionResultsMapLayer <PipingFailureMechanism, AdoptableWithProfileProbabilityFailureMechanismSectionResult, PipingInput>(
                FailureMechanism, sr => PipingFailureMechanismAssemblyFactory.AssembleSection(sr, FailureMechanism, AssessmentSection).AssemblyResult);
            MapDataCollection.Insert(4, assemblyResultMapLayer.MapData);
        }
Ejemplo n.º 25
0
    // 根据名字加载地图
    public void ReloadMapByName(string name)
    {
        var fileName              = Path.Combine(Application.dataPath, "Map", name);
        var MapInformation        = File.ReadAllText(fileName);
        MapDataCollection MapData = JsonMapper.ToObject <MapDataCollection>(MapInformation);

        Map = MapData.MapData;
    }
Ejemplo n.º 26
0
    /// <summary>
    /// 依照3d位置,取得cell的資料
    /// </summary>
    /// <param name="pos"></param>
    /// <returns></returns>
    public CellData GetCell(Vector3 pos)
    {
        int x = 0;
        int z = 0;

        MapUtility.GetCellIndexBy3dPosition(pos, CenterPosition, MapSizeX, MapSizeZ, ref x, ref z);
        return(MapDataCollection.GetCell(x, z));
    }
Ejemplo n.º 27
0
        /// <summary>
        /// Creates the map data.
        /// </summary>
        protected virtual void CreateMapData()
        {
            MapDataCollection            = new MapDataCollection(DuneErosionDataResources.DuneErosionFailureMechanism_DisplayName);
            referenceLineMapData         = RiskeerMapDataFactory.CreateReferenceLineMapData();
            duneErosionLocationsMapLayer = new DuneErosionLocationsMapLayer(FailureMechanism);

            MapDataCollection.Add(referenceLineMapData);
            MapDataCollection.Add(duneErosionLocationsMapLayer.MapData);
        }
Ejemplo n.º 28
0
        public void CreateSectionsMapDataCollection_ReturnsEmptyMapDataCollectionWithExpectedName()
        {
            // Call
            MapDataCollection data = RiskeerMapDataFactory.CreateSectionsMapDataCollection();

            // Assert
            CollectionAssert.IsEmpty(data.Collection);
            Assert.AreEqual("Vakindeling", data.Name);
        }
Ejemplo n.º 29
0
    // 将Json转换成地图信息
    public List <MapData> ReloadMapInfo()
    {
        var fileName              = Path.Combine(Application.dataPath, "Map", MapNameList[ArrayIndex]);
        var MapInformation        = File.ReadAllText(fileName);
        MapDataCollection MapData = JsonMapper.ToObject <MapDataCollection>(MapInformation);

        Map = MapData.MapData;
        return(Map);
    }
Ejemplo n.º 30
0
    // 加载地图
    public void ReloadMap()
    {
        if (StoredMap.Count == 0)
        {
            return;
        }
        else
        {
            var mapName               = StoredMap[MapIndex];
            var fileName              = Path.Combine(Application.dataPath, "Map", mapName);
            var MapInformation        = File.ReadAllText(fileName);
            MapDataCollection MapData = JsonMapper.ToObject <MapDataCollection>(MapInformation);

            // 加载前先清空地图信息
            DestroyMap();
            BuildMapGrids();

            // 将Map信息载入地块
            var MapDatas = MapData.MapData;
            foreach (MapTile data in MapTilesList)
            {
                for (int i = 0; i < MapDatas.Count; i++)
                {
                    if (data.X == MapDatas[i].X && data.Y == MapDatas[i].Y)
                    {
                        // 加载地块信息
                        var mapData = data.MapData;
                        mapData.Type = MapDatas[i].Type;
                        if (mapData.Type != TileType.None)
                        {
                            var material = data.transform.Find("Material").GetComponent <SpriteRenderer>();
                            material.sprite = Resources.Load <Sprite>("UI/MapTile/" + mapData.Type.ToString());
                        }
                        mapData.MaterialSortingOrder = MapDatas[i].MaterialSortingOrder;
                        mapData.RespawnSortingOrder  = MapDatas[i].RespawnSortingOrder;

                        // 加载出生点信息
                        var Mesh = data.transform.Find("RespawnPlace").GetComponent <SpriteRenderer>();
                        mapData.RespawnForChamp = MapDatas[i].RespawnForChamp;
                        if (mapData.RespawnForChamp == true)
                        {
                            Mesh.color = Color.red;
                        }
                        mapData.RespawnForEnemy = MapDatas[i].RespawnForEnemy;
                        if (mapData.RespawnForEnemy == true)
                        {
                            Mesh.color = Color.blue;
                        }
                    }
                }
            }
            ShowRespawnGrid();
            isNewMap = false;
        }
    }