示例#1
0
        public void Constructor1()
        {
            var verticesPositions = new Dictionary <int, Point>();

            var args = new LayoutIterationEventArgs <int, Edge <int> >();

            CheckArgs(args, 0, false, 0, string.Empty, null);

            args.Abort = true;
            CheckArgs(args, 0, true, 0, string.Empty, null);

            args = new LayoutIterationEventArgs <int, Edge <int> >(12, 55.4);
            CheckArgs(args, 55.4, false, 12, string.Empty, null);

            args = new LayoutIterationEventArgs <int, Edge <int> >(42, 15.6, "Test message");
            CheckArgs(args, 15.6, false, 42, "Test message", null);

            args = new LayoutIterationEventArgs <int, Edge <int> >(1, 1.6, verticesPositions);
            CheckArgs(args, 1.6, false, 1, string.Empty, verticesPositions);

            args = new LayoutIterationEventArgs <int, Edge <int> >(1, 1.6, (IDictionary <int, Point>)null);
            CheckArgs(args, 1.6, false, 1, string.Empty, null);

            args = new LayoutIterationEventArgs <int, Edge <int> >(1, 1.6, "Test iteration", null);
            CheckArgs(args, 1.6, false, 1, "Test iteration", null);

            args = new LayoutIterationEventArgs <int, Edge <int> >(1, 1.6, "Test iteration", verticesPositions);
            CheckArgs(args, 1.6, false, 1, "Test iteration", verticesPositions);
        }
示例#2
0
        public void GetEdgeInfo2_Throws()
        {
            var args = new LayoutIterationEventArgs <TestVertex, Edge <TestVertex>, int, double>();

            // ReSharper disable once ReturnValueOfPureMethodIsNotUsed
            // ReSharper disable once AssignNullToNotNullAttribute
            Assert.Throws <ArgumentNullException>(() => args.GetEdgeInfo(null));
        }
示例#3
0
        public void GetVertexInfo2()
        {
            var args = new LayoutIterationEventArgs <int, Edge <int>, int, double>();

            Assert.IsNull(args.GetVertexInfo(1));

            var verticesInfos = new Dictionary <int, int>
            {
                [2] = 12
            };

            args = new LayoutIterationEventArgs <int, Edge <int>, int, double>(1, 1.0, string.Empty, null, verticesInfos, null);
            Assert.IsNull(args.GetVertexInfo(1));
            Assert.AreEqual(12, args.GetVertexInfo(2));
        }
        public void IterationEnded_Simple()
        {
            var graph     = new AdjacencyGraph <TestVertex, Edge <TestVertex> >();
            var algorithm = new TestSimpleLayoutAlgorithm(graph);
            var arguments = new LayoutIterationEventArgs <TestVertex, Edge <TestVertex> >(1, 100.0);

            algorithm.Args = arguments;

            var iterations = new Stack <ILayoutIterationEventArgs <TestVertex> >(new[] { arguments });

            algorithm.IterationEnded += (sender, args) => Assert.AreSame(iterations.Pop(), args);

            algorithm.Compute();

            Assert.AreEqual(ComputationState.Finished, algorithm.State);
            CollectionAssert.IsEmpty(iterations);
        }
示例#5
0
        public void GetEdgeInfo2()
        {
            var edge12 = new Edge <int>(1, 2);
            var edge21 = new Edge <int>(2, 1);

            var args = new LayoutIterationEventArgs <int, Edge <int>, int, double>();

            Assert.IsNull(args.GetEdgeInfo(edge12));

            var edgeInfos = new Dictionary <Edge <int>, double>
            {
                [edge21] = 42.2
            };

            args = new LayoutIterationEventArgs <int, Edge <int>, int, double>(1, 1.0, string.Empty, null, null, edgeInfos);
            Assert.IsNull(args.GetEdgeInfo(edge12));
            Assert.AreEqual(42.2, args.GetEdgeInfo(edge21));
        }
        public void IterationEndedAbort_Complex()
        {
            var graph     = new AdjacencyGraph <TestVertex, Edge <TestVertex> >();
            var algorithm = new TestComplexLayoutAlgorithm(graph);
            var arguments = new LayoutIterationEventArgs <TestVertex, Edge <TestVertex>, int, double>(1, 100.0)
            {
                Abort = true
            };

            algorithm.Args = arguments;

            var iterations     = new Stack <ILayoutIterationEventArgs <TestVertex> >(new[] { arguments });
            var infoIterations = new Stack <ILayoutIterationEventArgs <TestVertex> >(new[] { arguments });

            algorithm.IterationEnded     += (sender, args) => Assert.AreSame(iterations.Pop(), args);
            algorithm.InfoIterationEnded += (sender, args) => Assert.AreSame(infoIterations.Pop(), args);

            algorithm.Compute();

            Assert.AreEqual(ComputationState.Aborted, algorithm.State);
            CollectionAssert.IsEmpty(iterations);
            CollectionAssert.IsEmpty(infoIterations);
        }
示例#7
0
        public void GetEdgeInfo1()
        {
            var args = new LayoutIterationEventArgs <int, Edge <int> >();

            Assert.IsNull(args.GetEdgeInfo(new Edge <int>(1, 2)));
        }
示例#8
0
        public void GetVertexInfo1()
        {
            var args = new LayoutIterationEventArgs <int, Edge <int> >();

            Assert.IsNull(args.GetVertexInfo(1));
        }