예제 #1
0
        public void TestSetPlotsShouldRenderPlots()
        {
            var plot  = new CanvasCircle();
            var plots = new List <CanvasItem> {
                plot
            };
            var backgroundVisual = new FakeVisual();
            var plotVisual       = new FakeVisual();
            var plotVisuals      = new List <Visual> {
                plotVisual
            };
            var visuals = new List <Visual> {
                backgroundVisual, plotVisual
            };
            var callback  = CanvasControl.ItemsProperty.GetMetadata(_control).PropertyChangedCallback;
            var callback2 = new Action(() => callback.Invoke(_control, new DependencyPropertyChangedEventArgs()));

            _mockPropertyService.Setup(p => p.SetValue(CanvasControl.ItemsProperty, It.IsAny <object>())).Callback(callback2);
            _mockPropertyService.Setup(p => p.GetValue(CanvasControl.ItemsProperty)).Returns(plots);
            _mockPropertyService.Setup(p => p.GetValue(CanvasControl.SelectedItemsProperty)).Returns(new List <CanvasItem>());
            _mockRenderer.Setup(p => p.DrawBackground(0d, 0d)).Returns(backgroundVisual);
            _mockRenderer.Setup(p => p.DrawItems(plots)).Returns(plotVisuals);
            _control.Items = plots;
            _mockVisualService.Verify(p => p.Clear(), Times.Once());
            _mockVisualService.Verify(p => p.Add(visuals));
        }
예제 #2
0
        public void TestGetVisualChildShouldReturnVisualFromVisualService()
        {
            var visual = new FakeVisual();

            _mockVisualService.Setup(p => p.GetVisual(1)).Returns(visual);
            var result = _control.GetVisualChild(1);

            Assert.That(result, Is.EqualTo(visual));
        }