Esempio n. 1
0
        public void ArrowGraphCompiler_GivenCyclomaticComplexityWithNoNodes_ThenFindsZero()
        {
            var graphCompiler = new ArrowGraphCompiler <int, int, IDependentActivity <int, int> >();

            graphCompiler.Compile();
            graphCompiler.CyclomaticComplexity.Should().Be(0);
        }
Esempio n. 2
0
        public void ArrowGraphCompiler_GivenCyclomaticComplexityInOneNetwork_ThenAsExpected()
        {
            int activityId1   = 1;
            int activityId2   = activityId1 + 1;
            int activityId3   = activityId2 + 1;
            int activityId4   = activityId3 + 1;
            int activityId5   = activityId4 + 1;
            int activityId6   = activityId5 + 1;
            int activityId7   = activityId6 + 1;
            int activityId8   = activityId7 + 1;
            int activityId9   = activityId8 + 1;
            var graphCompiler = new ArrowGraphCompiler <int, int, IDependentActivity <int, int> >();

            graphCompiler.AddActivity(new DependentActivity <int, int>(activityId1, 6));
            graphCompiler.AddActivity(new DependentActivity <int, int>(activityId2, 7));
            graphCompiler.AddActivity(new DependentActivity <int, int>(activityId3, 8));
            graphCompiler.AddActivity(new DependentActivity <int, int>(activityId4, 11, new HashSet <int>(new[] { 2 })));
            graphCompiler.AddActivity(new DependentActivity <int, int>(activityId5, 8, new HashSet <int>(new[] { 1, 2, 3 })));
            graphCompiler.AddActivity(new DependentActivity <int, int>(activityId6, 7, new HashSet <int>(new[] { 3 })));
            graphCompiler.AddActivity(new DependentActivity <int, int>(activityId7, 4, new HashSet <int>(new[] { 4 })));
            graphCompiler.AddActivity(new DependentActivity <int, int>(activityId8, 4, new HashSet <int>(new[] { 4, 6 })));
            graphCompiler.AddActivity(new DependentActivity <int, int>(activityId9, 10, new HashSet <int>(new[] { 5 })));

            graphCompiler.Compile();

            graphCompiler.CyclomaticComplexity.Should().Be(6);
        }
Esempio n. 3
0
        private void GenerateArrowGraphFromGraphCompilation()
        {
            lock (m_Lock)
            {
                ArrowGraph = null;
                IList <IDependentActivity <int, int> > dependentActivities =
                    GraphCompilation.DependentActivities
                    .Select(x => (IDependentActivity <int, int>)x.CloneObject())
                    .ToList();

                if (!HasCompilationErrors &&
                    dependentActivities.Any())
                {
                    var arrowGraphCompiler = new ArrowGraphCompiler <int, int, IDependentActivity <int, int> >();
                    foreach (IDependentActivity <int, int> dependentActivity in dependentActivities)
                    {
                        dependentActivity.Dependencies.UnionWith(dependentActivity.ResourceDependencies);
                        dependentActivity.ResourceDependencies.Clear();
                        arrowGraphCompiler.AddActivity(dependentActivity);
                    }

                    arrowGraphCompiler.Compile();
                    Graph <int, IDependentActivity <int, int>, IEvent <int> > arrowGraph = arrowGraphCompiler.ToGraph();

                    if (arrowGraph == null)
                    {
                        throw new InvalidOperationException("Cannot construct arrow graph");
                    }
                    ArrowGraph = m_Mapper.Map <Graph <int, IDependentActivity <int, int>, IEvent <int> >, ArrowGraphModel>(arrowGraph);
                }
                GenerateArrowGraphDataFrom();
            }
        }
Esempio n. 4
0
        public void ArrowGraphCompiler_GivenCyclomaticComplexityWithTwoLoneNodes_ThenAsExpected()
        {
            int activityId1   = 1;
            int activityId2   = activityId1 + 1;
            int activityId3   = activityId2 + 1;
            int activityId4   = activityId3 + 1;
            var graphCompiler = new ArrowGraphCompiler <int, int, IDependentActivity <int, int> >();

            graphCompiler.AddActivity(new DependentActivity <int, int>(activityId1, 6));
            graphCompiler.AddActivity(new DependentActivity <int, int>(activityId2, 7));
            graphCompiler.AddActivity(new DependentActivity <int, int>(activityId3, 8));
            graphCompiler.AddActivity(new DependentActivity <int, int>(activityId4, 11, new HashSet <int>(new[] { 1 })));

            graphCompiler.Compile();

            graphCompiler.CyclomaticComplexity.Should().Be(3);
        }
Esempio n. 5
0
        public void ArrowGraphCompiler_GivenCyclomaticComplexityInThreeNetworks_ThenAsExpected()
        {
            int activityId1   = 1;
            int activityId2   = activityId1 + 1;
            int activityId3   = activityId2 + 1;
            int activityId4   = activityId3 + 1;
            int activityId5   = activityId4 + 1;
            int activityId6   = activityId5 + 1;
            var graphCompiler = new ArrowGraphCompiler <int, int, IDependentActivity <int, int> >();

            graphCompiler.AddActivity(new DependentActivity <int, int>(activityId1, 6));
            graphCompiler.AddActivity(new DependentActivity <int, int>(activityId2, 7));
            graphCompiler.AddActivity(new DependentActivity <int, int>(activityId3, 8));
            graphCompiler.AddActivity(new DependentActivity <int, int>(activityId4, 11, new HashSet <int>(new[] { 1 })));
            graphCompiler.AddActivity(new DependentActivity <int, int>(activityId5, 8, new HashSet <int>(new[] { 2 })));
            graphCompiler.AddActivity(new DependentActivity <int, int>(activityId6, 7, new HashSet <int>(new[] { 3 })));

            graphCompiler.Compile();

            graphCompiler.CyclomaticComplexity.Should().Be(3);
        }