Пример #1
0
        public void ProgressChanged_Simple()
        {
            var graph      = new AdjacencyGraph <TestVertex, Edge <TestVertex> >();
            var algorithm  = new TestSimpleParameterizedLayoutAlgorithm(graph);
            var progresses = new Stack <double>(new[] { 100.0, 50.0, 0.0 });

            algorithm.ProgressChanged += (sender, percent) => Assert.AreEqual(progresses.Pop(), percent);

            algorithm.Compute();

            CollectionAssert.IsEmpty(progresses);
        }
Пример #2
0
        public void IterationEnded_Simple()
        {
            var vertex1 = new TestVertex("1");
            var vertex2 = new TestVertex("2");

            var verticesPositions = new Dictionary <TestVertex, Point>
            {
                [vertex1] = new Point(12, 5),
                [vertex2] = new Point(5, 42)
            };

            var graph = new AdjacencyGraph <TestVertex, Edge <TestVertex> >();

            graph.AddVertexRange(new[] { vertex1, vertex2 });

            var algorithm = new TestSimpleParameterizedLayoutAlgorithm(graph, verticesPositions, null);

            var iteration1 = new EventArgsContentChecker(1, 50, "Test", verticesPositions);
            var normalizedVerticesPositions = new Dictionary <TestVertex, Point>(verticesPositions);

            LayoutUtils.NormalizePositions(normalizedVerticesPositions);
            var iteration2 = new EventArgsContentChecker(2, 60, "Test2", normalizedVerticesPositions);
            var iterations = new Stack <EventArgsContentChecker>(new[] { iteration2, iteration1 });

            algorithm.IterationEnded += (sender, args) =>
            {
                EventArgsContentChecker contentChecker = iterations.Pop();
                Assert.AreEqual(contentChecker.Iteration, args.Iteration);
                Assert.AreEqual(contentChecker.Percent, args.StatusInPercent);
                Assert.AreEqual(contentChecker.Message, args.Message);
                Assert.AreEqual(contentChecker.Positions, args.VerticesPositions);
            };

            algorithm.Compute();

            Assert.AreEqual(ComputationState.Finished, algorithm.State);
            CollectionAssert.IsEmpty(iterations);
        }