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); }
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); }
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"); }
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"); }
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"); }
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"); }
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"); }
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"); }
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); }