public void OnDrop_ChartDataMovedToPositionOutsideRange_ThrowsException(int position)
        {
            // Setup
            var observer = mocks.StrictMock <IObserver>();

            mocks.ReplayAll();

            var chartData1          = new ChartLineData("line");
            var chartData2          = new ChartAreaData("area");
            var chartData3          = new ChartPointData("point");
            var chartData4          = new ChartMultipleAreaData("multiple area");
            var chartDataCollection = new ChartDataCollection("test data");

            chartDataCollection.Add(chartData1);
            chartDataCollection.Add(chartData2);
            chartDataCollection.Add(chartData3);
            chartDataCollection.Add(chartData4);

            chartDataCollection.Attach(observer);
            chartLegendView.Data = chartDataCollection;

            ChartDataContext context1 = GetContext(chartData1);

            chartDataCollection.Attach(observer);

            using (var treeViewControl = new TreeViewControl())
            {
                // Call
                void Call() => info.OnDrop(context1, chartDataCollection, chartDataCollection, position, treeViewControl);

                // Assert
                Assert.Throws <ArgumentOutOfRangeException>(Call);
            }
        }
Esempio n. 2
0
        public void Selection_NestedNodeData_ReturnsWrappedObjectData()
        {
            // 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 context = new ChartDataContext(chartData, chartDataCollection);

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

                // Call
                object selection = view.Selection;

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

            WindowsFormsTestHelper.CloseAll();

            mocks.VerifyAll();
        }
Esempio n. 3
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();
        }
        public void OnDrop_ChartDataMovedToPositionInsideRange_SetsNewReverseOrder(int position)
        {
            // Setup
            var observer = mocks.StrictMock <IObserver>();

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

            var chartData1          = new TestChartData();
            var chartData2          = new TestChartData();
            var chartData3          = new TestChartData();
            var chartDataCollection = new ChartDataCollection("test");

            chartDataCollection.Add(chartData1);
            chartDataCollection.Add(chartData2);
            chartDataCollection.Add(chartData3);

            ChartDataContext context1          = GetContext(chartData1);
            ChartDataContext collectionContext = GetContext(chartDataCollection);

            chartDataCollection.Attach(observer);

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

                // Assert
                int reversedIndex         = 2 - position;
                var wrappedCollectionData = (ChartDataCollection)collectionContext.WrappedData;
                Assert.AreSame(context1.WrappedData, wrappedCollectionData.Collection.ElementAt(reversedIndex));
            }
        }
Esempio n. 5
0
        public void GivenChartLegendView_WhenSelectedNodeChanged_SelectionChangedFired()
        {
            // Given
            ChartData chartData           = CreateChartData();
            var       chartDataCollection = new ChartDataCollection("collection");

            chartDataCollection.Add(chartData);

            var mocks = new MockRepository();
            var contextMenuBuilderProvider = mocks.Stub <IContextMenuBuilderProvider>();

            mocks.ReplayAll();

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

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

                // When
                var context = new ChartDataContext(chartData, chartDataCollection);
                treeViewControl.TrySelectNodeForData(context);

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

            WindowsFormsTestHelper.CloseAll();
            mocks.VerifyAll();
        }
        public void ChildNodeObjects_ChartDataCollection_ReturnsItemsFromChartDataCollectionList()
        {
            // Setup
            var chartData1          = new TestChartData();
            var chartData2          = new TestChartData();
            var chartData3          = new TestChartData();
            var chartDataCollection = new ChartDataCollection("test");

            chartDataCollection.Add(chartData1);
            chartDataCollection.Add(chartData2);
            chartDataCollection.Add(chartData3);

            ChartDataContext context = GetContext(chartDataCollection);

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

            // Assert
            var expectedChildren = new[]
            {
                new ChartDataContext(chartData3, new ChartDataCollection("test")),
                new ChartDataContext(chartData2, new ChartDataCollection("test")),
                new ChartDataContext(chartData1, new ChartDataCollection("test"))
            };

            CollectionAssert.AreEqual(expectedChildren, objects);
        }
        internal void UpdateValues(ChartDataContext chartDataContext)
        {
            var item = chartDataContext.ClosestDataPoint.DataPoint.DataItem as ChartModel;

            //this.DateLabel = item.ProcesTime.ToString("hh:mm");

            this.TValue = item.Value;

            this.AvValue = (double)chartDataContext.DataPoints.Where(c => c.Series is IndicatorBase).First().DataPoint.Label;
        }
Esempio n. 8
0
        private void UpdateValues(ChartDataContext chartDataContext)
        {
            var item = chartDataContext.ClosestDataPoint.DataPoint.DataItem as OhlcModel;

            this.DateLabel = item.Date.ToString("dd.MM.yyyy");

            this.MSFTValue = item.Close;

            this.EMAValue = (double)chartDataContext.DataPoints.Where(c => c.Series is IndicatorBase).First().DataPoint.Label;
        }
Esempio n. 9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="chartDataContext"></param>
        /// <returns></returns>
        private Axis CreateContext(ChartDataContext chartDataContext)
        {
            CategoricalDataPoint DataPoint = (CategoricalDataPoint)chartDataContext.ClosestDataPoint.DataPoint;

            return(new Axis()
            {
                X = (DateTime)DataPoint.Category,
                Y = (double)DataPoint.Value
            });
        }
        public void CanCheck_WrappedDataOtherThanChartDataCollection_ReturnsTrue(ChartData chartData)
        {
            // Setup
            ChartDataContext context = GetContext(chartData);

            // Call
            bool canCheck = info.CanCheck(context);

            // Assert
            Assert.IsTrue(canCheck);
        }
        public void CanCheck_WrappedDataChartDataCollection_ReturnsFalse()
        {
            // Setup
            ChartDataContext context = GetContext(new ChartDataCollection("test"));

            // Call
            bool canCheck = info.CanCheck(context);

            // Assert
            Assert.IsFalse(canCheck);
        }
        public void CanDrag_WrappedDataOtherThanChartMultipleAreaData_ReturnsTrue(ChartData chartData)
        {
            // Setup
            ChartDataContext context = GetContext(chartData);

            // Call
            bool canDrag = info.CanDrag(context, null);

            // Assert
            Assert.IsTrue(canDrag);
        }
        public void ChildNodeObjects_OtherThanChartDataCollection_ReturnsEmptyArray(ChartData chartData)
        {
            // Setup
            ChartDataContext context = GetContext(chartData);

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

            // Assert
            CollectionAssert.IsEmpty(objects);
        }
        public void Image_WrappedDataChartPointData_ReturnsExpectedImage(ChartData chartData, Image expectedImage)
        {
            // Setup
            ChartDataContext context = GetContext(chartData);

            // Call
            Image image = info.Image(context);

            // Assert
            TestHelper.AssertImagesAreEqual(expectedImage, image);
        }
        public void Text_Always_ReturnsNameFromWrappedChartData()
        {
            // Setup
            ChartDataContext context = GetContext(new TestChartData());

            // Call
            string text = info.Text(context);

            // Assert
            Assert.AreEqual(context.WrappedData.Name, text);
        }
        public void CanDrag_WrappedDataChartMultipleAreaData_ReturnsFalse()
        {
            // Setup
            var multipleChartAreaData = new ChartMultipleAreaData("test");
            ChartDataContext context  = GetContext(multipleChartAreaData);

            // Call
            bool canDrag = info.CanDrag(context, null);

            // Assert
            Assert.IsFalse(canDrag);
        }
        public void CanDrop_TargetParentIsSameAsSourceParent_ReturnsTrue()
        {
            // Setup
            ChartData chartData           = new TestChartData();
            var       chartDataCollection = new ChartDataCollection("test");

            ChartDataContext context = GetContext(chartData, chartDataCollection);

            // Call
            bool canDrop = info.CanDrop(context, chartDataCollection);

            // Assert
            Assert.IsTrue(canDrop);
        }
        public void CanInsert_TargetParentNotSameAsSourceParent_ReturnsFalse()
        {
            // Setup
            ChartData chartData           = new TestChartData();
            var       chartDataCollection = new ChartDataCollection("test");

            ChartDataContext context = GetContext(chartData, chartDataCollection);

            // Call
            bool canInsert = info.CanInsert(context, GetContext(new ChartDataCollection("test")));

            // Assert
            Assert.IsFalse(canInsert);
        }
        public void CanInsert_TargetParentNotSameAsSourceParent_ReturnsFalse()
        {
            // Setup
            ChartData chartData  = new TestChartData();
            ChartData chartData2 = new TestChartData();

            ChartDataContext context       = GetContext(chartData);
            ChartDataContext targetContext = GetContext(chartData2);

            // Call
            bool canInsert = info.CanInsert(context, targetContext);

            // Assert
            Assert.IsFalse(canInsert);
        }
        public void IsChecked_Always_ReturnsAccordingToVisibleStateOfChartData(ChartData chartData, bool isVisible)
        {
            // Setup
            ChartDataContext context = GetContext(chartData);

            context.WrappedData.IsVisible = isVisible;

            // Call
            TreeNodeCheckedState checkedState = info.CheckedState(context);

            // Assert
            TreeNodeCheckedState expectedCheckedState = isVisible ? TreeNodeCheckedState.Checked : TreeNodeCheckedState.Unchecked;

            Assert.AreEqual(expectedCheckedState, checkedState);
        }
Esempio n. 21
0
        public void Constructor_ExpectedValues()
        {
            // Setup
            ChartData data       = new TestChartData();
            var       collection = new ChartDataCollection("test");

            collection.Add(data);

            // Call
            var context = new ChartDataContext(data, collection);

            // Assert
            Assert.IsInstanceOf <ObservableWrappedObjectContextBase <ChartData> >(context);
            Assert.AreSame(data, context.WrappedData);
            Assert.AreSame(collection, context.ParentChartData);
        }
        public void CanInsert_TargetDataIsCollection_ReturnsFalse()
        {
            // Setup
            ChartData chartData        = new TestChartData();
            var       rootCollection   = new ChartDataCollection("test");
            var       targetCollection = new ChartDataCollection("test");

            ChartDataContext context       = GetContext(chartData, rootCollection);
            ChartDataContext targetContext = GetContext(targetCollection, rootCollection);

            // Call
            bool canDrop = info.CanInsert(context, targetContext);

            // Assert
            Assert.IsFalse(canDrop);
        }
        public void OnNodeChecked_Always_SetsChartDataVisibilityAndNotifiesParentObservers(ChartData chartData, bool initialVisibleState)
        {
            // Setup
            var observer = mocks.StrictMock <IObserver>();

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

            ChartDataContext context = GetContext(chartData);

            context.WrappedData.IsVisible = initialVisibleState;

            context.WrappedData.Attach(observer);

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

            // Assert
            Assert.AreEqual(!initialVisibleState, context.WrappedData.IsVisible);
        }