コード例 #1
0
        public void TestLoad3()
        {
            var chart = new NetworkView();
            var node  = new Mock <INode>().Object;

            chart.Nodes = new[] { node };
            chart.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent));
            chart.Children.Count.Should().Be(1);

            new Action(() => chart.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent))).ShouldNotThrow();
            chart.Children.Count.Should().Be(1);
        }
コード例 #2
0
        public void TestLoad2()
        {
            var chart = new NetworkView();
            var edge  = new Mock <IEdge>();

            chart.Edges = new[] { edge.Object };
            chart.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent));
            chart.Children.Count.Should().Be(1);

            chart.RaiseEvent(new RoutedEventArgs(FrameworkElement.UnloadedEvent));

            chart.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent));
            chart.Children.Count.Should().Be(1);
        }
コード例 #3
0
        public void TestMeasure1()
        {
            var chart = new NetworkView();

            chart.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent));
            new Action(() => chart.Measure(new System.Windows.Size(double.MaxValue, double.MaxValue))).ShouldNotThrow();
            chart.DesiredSize.Should().Be(new System.Windows.Size(), "because the chart doesn't have anything to display and thus consumes no area");
        }
コード例 #4
0
        public void TestNodes5()
        {
            var chart = new NetworkView();
            var node  = new Mock <INode>().Object;

            chart.Nodes = new[] { node };
            chart.Children.Should().BeEmpty("because children should only be created and added when the control is loaded");

            chart.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent));
            chart.Children.Count.Should().Be(1, "because children should have been created since the control is loaded now");
        }
コード例 #5
0
        public void TestEdges4()
        {
            var chart = new NetworkView();

            chart.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent));

            var edge = new Mock <IEdge>().Object;

            chart.Edges = new[] { edge };
            chart.Children.Count.Should().Be(1, "because children should have been created since the control is loaded now");
        }
コード例 #6
0
        public void TestNodes7()
        {
            var chart = new NetworkView();

            chart.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent));

            var node = new Mock <INode>().Object;

            chart.Nodes = new[] { node };
            var item = chart.Children.Cast <NetworkViewNodeItem>().FirstOrDefault();

            item.Should().NotBeNull();
            item.Content.Should().BeSameAs(node, "because the item should actually represent this node");
        }
コード例 #7
0
        public void TestEdges7()
        {
            var chart = new NetworkView();

            chart.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent));

            var edge = new Mock <IEdge>().Object;

            chart.Edges = new[] { edge };
            var item = chart.Children.Cast <FrameworkElement>().FirstOrDefault();

            item.Should().NotBeNull();
            item.DataContext.Should().BeSameAs(edge, "because the item should actually represent this edge");
        }
コード例 #8
0
        public void TestRemoveNodes1()
        {
            var chart = new NetworkView();

            chart.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent));

            var node  = new Mock <INode>().Object;
            var nodes = new ObservableCollection <INode> {
                node
            };

            chart.Nodes = nodes;
            chart.Children.Count.Should().Be(1, "because the view should've reacted to the addition of a node");

            nodes.Remove(node);
            chart.Children.Should().BeEmpty("because we've removed the only node and thus its representing item also should've been removed");
        }
コード例 #9
0
        public void TestAddNodes1()
        {
            var chart = new NetworkView();

            chart.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent));

            var nodes = new ObservableCollection <INode>();

            chart.Nodes = nodes;

            var node = new Mock <INode>().Object;

            nodes.Add(node);
            chart.Children.Count.Should().Be(1, "because the view should've reacted to the addition of a node");
            var item = chart.Children.Cast <NetworkViewNodeItem>().First();

            item.Should().NotBeNull();
            item.Content.Should().BeSameAs(node);
        }