Exemple #1
0
        public void GivenChartDataContainingCollection_WhenDragDroppingFromRootToRoot_ThenDataPositionChanged(int index)
        {
            // Given
            var mocks = new MockRepository();
            var menuBuilderProvider = mocks.Stub <IContextMenuBuilderProvider>();

            mocks.ReplayAll();

            ChartData chartData      = CreateChartData();
            var       rootCollection = new ChartDataCollection("test data");

            rootCollection.Add(chartData);
            rootCollection.Add(CreateChartData());
            rootCollection.Add(CreateChartData());

            using (var chartLegendView = new ChartLegendView(menuBuilderProvider)
            {
                Data = rootCollection
            })
            {
                var          treeViewControl    = TypeUtils.GetField <TreeViewControl>(chartLegendView, "treeViewControl");
                var          treeNodeInfoLookup = TypeUtils.GetField <Dictionary <Type, TreeNodeInfo> >(treeViewControl, "tagTypeTreeNodeInfoLookup");
                TreeNodeInfo info = treeNodeInfoLookup[typeof(ChartDataCollection)];

                var context = new ChartDataContext(chartData, rootCollection);

                // When
                info.OnDrop(context, rootCollection, rootCollection, index, treeViewControl);

                // Then
                Assert.AreEqual(2 - index, rootCollection.Collection.ToList().IndexOf(chartData));
            }

            mocks.VerifyAll();
        }
Exemple #2
0
        public void GivenChartLegendView_WhenSettingData_SelectionChangedFired()
        {
            // Given
            var mocks = new MockRepository();
            var contextMenuBuilderProvider = mocks.Stub <IContextMenuBuilderProvider>();

            mocks.ReplayAll();

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

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

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

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

            WindowsFormsTestHelper.CloseAll();
            mocks.VerifyAll();
        }
Exemple #3
0
        public void Selection_RootNodeData_ReturnsObjectData()
        {
            // Setup
            var mocks = new MockRepository();
            var contextMenuBuilderProvider = mocks.Stub <IContextMenuBuilderProvider>();

            mocks.ReplayAll();

            ChartData chartData           = CreateChartData();
            var       chartDataCollection = new ChartDataCollection("collection");

            chartDataCollection.Add(chartData);

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

                // Call
                object selection = view.Selection;

                // Assert
                Assert.AreSame(chartDataCollection, selection);
            }

            WindowsFormsTestHelper.CloseAll();

            mocks.VerifyAll();
        }
        public void SetUp()
        {
            mocks = new MockRepository();
            contextMenuBuilderProvider = mocks.StrictMock <IContextMenuBuilderProvider>();
            mocks.ReplayAll();

            chartLegendView = new ChartLegendView(contextMenuBuilderProvider);

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

            info = treeNodeInfoLookup[typeof(ChartDataContext)];
        }
Exemple #5
0
        public void Data_OtherObject_ThrowsInvalidCastException()
        {
            // Setup
            var mocks = new MockRepository();
            var menuBuilderProvider = mocks.Stub <IContextMenuBuilderProvider>();

            mocks.ReplayAll();

            using (var view = new ChartLegendView(menuBuilderProvider))
            {
                // Call
                void Call() => view.Data = new object();

                // Assert
                Assert.Throws <InvalidCastException>(Call);
            }

            mocks.VerifyAll();
        }
Exemple #6
0
        public void Data_ForNull_NullSet()
        {
            // Setup
            var mocks = new MockRepository();
            var menuBuilderProvider = mocks.Stub <IContextMenuBuilderProvider>();

            mocks.ReplayAll();

            using (var view = new ChartLegendView(menuBuilderProvider))
            {
                // Call
                view.Data = null;

                // Assert
                Assert.IsNull(view.Data);
            }

            mocks.VerifyAll();
        }
Exemple #7
0
        public void Constructor_WithBuilderProvider_CreatesUserControl()
        {
            // Setup
            var mocks = new MockRepository();
            var menuBuilderProvider = mocks.Stub <IContextMenuBuilderProvider>();

            mocks.ReplayAll();

            // Call
            using (var view = new ChartLegendView(menuBuilderProvider))
            {
                // Assert
                Assert.IsInstanceOf <UserControl>(view);
                Assert.IsInstanceOf <IView>(view);
                Assert.IsInstanceOf <ISelectionProvider>(view);
                Assert.IsNull(view.Data);
            }

            mocks.VerifyAll();
        }
Exemple #8
0
        public void Data_ChartDataCollection_DataSet()
        {
            // Setup
            var mocks = new MockRepository();
            var menuBuilderProvider = mocks.Stub <IContextMenuBuilderProvider>();

            mocks.ReplayAll();

            using (var view = new ChartLegendView(menuBuilderProvider))
            {
                var chartDataCollection = new ChartDataCollection("test data");

                // Call
                view.Data = chartDataCollection;

                // Assert
                Assert.AreSame(chartDataCollection, view.Data);
            }

            mocks.VerifyAll();
        }