Exemplo n.º 1
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();
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 3
0
        public void Data_OtherObjectType_ThrowsInvalidCastException()
        {
            // Setup
            using (var view = new MapLegendView(contextMenuBuilderProvider))
            {
                // Call
                void Call() => view.Data = new object();

                // Assert
                Assert.Throws <InvalidCastException>(Call);
            }
        }
Exemplo n.º 4
0
        public void Data_Null_NullSet()
        {
            // Setup
            using (var view = new MapLegendView(contextMenuBuilderProvider))
            {
                // Call
                view.Data = null;

                // Assert
                Assert.IsNull(view.Data);
            }
        }
        public void SetUp()
        {
            mocks = new MockRepository();
            contextMenuBuilderProvider = mocks.StrictMock <IContextMenuBuilderProvider>();
            mocks.ReplayAll();

            mapLegendView = new MapLegendView(contextMenuBuilderProvider);

            var treeViewControl    = TypeUtils.GetField <TreeViewControl>(mapLegendView, "treeViewControl");
            var treeNodeInfoLookup = TypeUtils.GetField <Dictionary <Type, TreeNodeInfo> >(treeViewControl, "tagTypeTreeNodeInfoLookup");

            info = treeNodeInfoLookup[typeof(FeatureBasedMapDataContext)];
        }
Exemplo n.º 6
0
        public void MapControl_DataSetAndThenMapControlSetToNull_DataSetToNull()
        {
            // Setup
            using (var view = new MapLegendView(contextMenuBuilderProvider)
            {
                Data = new MapDataCollection("A")
            })
            {
                // Call
                view.MapControl = null;

                // Assert
                Assert.IsNull(view.Data);
            }
        }
Exemplo n.º 7
0
        public void Constructor_ContextMenuBuilderProviderAndWindowNotNull_CreatesUserControlAndTreeViewControl()
        {
            // Call
            using (var view = new MapLegendView(contextMenuBuilderProvider))
            {
                var treeViewControl = TypeUtils.GetField <TreeViewControl>(view, "treeViewControl");

                // Assert
                Assert.IsInstanceOf <UserControl>(view);
                Assert.IsInstanceOf <IView>(view);
                Assert.IsInstanceOf <ISelectionProvider>(view);
                Assert.IsNull(view.Data);
                Assert.IsNotNull(treeViewControl);
                Assert.IsInstanceOf <TreeViewControl>(treeViewControl);
            }
        }
Exemplo n.º 8
0
        public void Data_MapDataCollection_DataSet()
        {
            // Setup
            using (var view = new MapLegendView(contextMenuBuilderProvider))
            {
                var mapData = new MapDataCollection("test data");

                // Call
                view.Data = mapData;

                // Assert
                Assert.IsInstanceOf <MapDataCollectionContext>(view.Data);
                var viewData = (MapDataCollectionContext)view.Data;
                Assert.AreSame(mapData, viewData.WrappedData);
                Assert.IsNull(viewData.ParentMapData);
            }
        }
Exemplo n.º 9
0
        public void GivenMapLegendView_WhenSettingData_SelectionChangedFired()
        {
            // Given
            using (var view = new MapLegendView(contextMenuBuilderProvider))
            {
                var selectionChangedCount = 0;
                view.SelectionChanged += (sender, args) => selectionChangedCount++;

                var treeViewControl = TypeUtils.GetField <TreeViewControl>(view, "treeViewControl");
                WindowsFormsTestHelper.Show(treeViewControl);

                // When
                view.Data = new MapDataCollection("collection");

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

            WindowsFormsTestHelper.CloseAll();
        }
Exemplo n.º 10
0
        public void MapControl_MapControlHasMapWithData_DataReturnsWrappedMapDataOfMap()
        {
            // Setup
            var mapData        = new MapDataCollection("A");
            var mockRepository = new MockRepository();
            var mapControl     = mockRepository.Stub <IMapControl>();

            mapControl.Expect(mc => mc.Data).Return(mapData);
            mockRepository.ReplayAll();

            using (var view = new MapLegendView(contextMenuBuilderProvider)
            {
                Data = new MapDataCollection("A")
            })
            {
                // Call
                view.MapControl = mapControl;

                // Assert
                Assert.AreSame(mapData, ((MapDataCollectionContext)view.Data).WrappedData);
            }

            mockRepository.VerifyAll();
        }