|
| 1 | +require 'cpp_dependency_graph/dependency_graph' |
| 2 | +require 'cpp_dependency_graph/component_link' |
| 3 | + |
| 4 | +RSpec.describe DependencyGraph do |
| 5 | + let(:project) { Project.new('spec/test/example_project') } |
| 6 | + let(:dependency_graph) { DependencyGraph.new(project) } |
| 7 | + |
| 8 | + it 'returns all links for a project' do |
| 9 | + expected_links = {} |
| 10 | + expected_links['UI'] = [ComponentLink.new('UI', 'Framework', false), |
| 11 | + ComponentLink.new('UI', 'Engine', true)] |
| 12 | + expected_links['DataAccess'] = [ComponentLink.new('DataAccess', 'Framework', false)] |
| 13 | + expected_links['main'] = [ComponentLink.new('main', 'UI', false)] |
| 14 | + expected_links['Framework'] = [] |
| 15 | + expected_links['System'] = [] |
| 16 | + expected_links['Engine'] = [ComponentLink.new('Engine', 'Framework', false), |
| 17 | + ComponentLink.new('Engine', 'UI', true), |
| 18 | + ComponentLink.new('Engine', 'DataAccess', false)] |
| 19 | + expect(dependency_graph.all_component_links).to eq(expected_links) |
| 20 | + end |
| 21 | + |
| 22 | + it 'returns links for a specified component of a project' do |
| 23 | + expected_links = {} |
| 24 | + expected_links['UI'] = [ComponentLink.new('UI', 'Engine', false)] # TODO |
| 25 | + expected_links['Engine'] = [ComponentLink.new('Engine', 'Framework', false), |
| 26 | + ComponentLink.new('Engine', 'UI', true), |
| 27 | + ComponentLink.new('Engine', 'DataAccess', false)] |
| 28 | + expect(dependency_graph.component_links('Engine')).to eq(expected_links) |
| 29 | + end |
| 30 | + |
| 31 | + it 'returns all cyclic links of a project' do |
| 32 | + expected_links = {} |
| 33 | + expected_links['Engine'] = [ComponentLink.new('Engine', 'UI', true)] |
| 34 | + expected_links['UI'] = [ComponentLink.new('UI', 'Engine', true)] |
| 35 | + expect(dependency_graph.all_cyclic_links).to eq(expected_links) |
| 36 | + end |
| 37 | +end |
0 commit comments