Commits

roundcrisis  committed 02af482

adding test for transformation from collection of shapes to graph
adding failing test to mark the fact there is no protected internal method work to do
as well as implementation of the analyzer for proeprties

  • Participants
  • Parent commits e1ca9dd

Comments (0)

Files changed (22)

File src/CodeShapes/ClassAnalyzer.cs

 using System.Reflection.Emit;
 using CodeShapes.Disassembler;
 using CodeShapes.Shapes;
+using QuickGraph;
 
 namespace CodeShapes
 {
+	public class AnalizedClass
+	{
+		private IEnumerable<ICodeShape> _classShapes;
+
+		public AnalizedClass(IEnumerable<ICodeShape> classShapes)
+		{
+			_classShapes = classShapes;
+		}
+
+		public bool RenderToImage(string path)
+		{
+			throw new NotImplementedException();
+		}
+		
+		public bool RenderToTextFile(string path)
+		{
+			throw new NotImplementedException();
+		}
+	}
+
 	public class ClassAnalyzer
 	{
-		public IEnumerable<IClassShape> Analyze<T>()
+		public IEnumerable<ICodeShape> Analyze<T>()
 		{
 			var shapes = FindAllPrivateMethods(typeof(T))
 				.Concat(FindAllPublicMethods(typeof(T)))
 				.Concat(FindFields(typeof(T))).ToArray();
 
-			var methods = shapes.Where(s => s is MethodShape).Cast<MethodShape>();
+			var methods = shapes.Where(s => s is MethodCodeShape).Cast<MethodCodeShape>();
 			foreach (var methodShape in methods)
 			{
 				foreach (var buildAdjacencyList in BuildAdjacencyLists(methodShape.MethodBase.GetInstructions(), shapes))
 			return shapes;
 		}
 
-		private IDictionary<int, IClassShape> BuildAdjacencyLists(IList<Instruction> instructions, IEnumerable<IClassShape> shapes)
+		public AdjacencyGraph<string, SEdge<string>> TransformToGraph(IEnumerable<ICodeShape> shapes)
 		{
-			var result = new Dictionary<int, IClassShape>();
+			throw new NotImplementedException();	
+		}
+	
+		private IDictionary<int, ICodeShape> BuildAdjacencyLists(IList<Instruction> instructions, IEnumerable<ICodeShape> shapes)
+		{
+			var result = new Dictionary<int, ICodeShape>();
 			foreach (var instruction in instructions)
 			{
 				if(instruction.OpCode.OperandType == OperandType.InlineMethod)
 				{
 					var methods = shapes
-						.Where(s => s is MethodShape)
-						.Cast<MethodShape>();
+						.Where(s => s is MethodCodeShape)
+						.Cast<MethodCodeShape>();
 					var dependency = methods.FirstOrDefault(m => m.MethodBase == (MethodBase)instruction.Operand);
 
 					int dependencyKey = ((MethodBase)instruction.Operand).MetadataToken;
 					}
 				}
 
+				//TODO: properties and protected and internal methods
+				
 				if(instruction.OpCode.OperandType == OperandType.InlineField)
 				{
 					var dependency = shapes
-						.Where(s => s is FieldShape).Cast<FieldShape>()
+						.Where(s => s is FieldCodeShape).Cast<FieldCodeShape>()
 						.FirstOrDefault(f => f.Name == ((FieldInfo)instruction.Operand).Name);
 
 					int dependencyKey = ((FieldInfo)instruction.Operand).MetadataToken;
 			return result;
 		}
 
-		public IEnumerable<FieldShape> FindFields(Type type)
+		public IEnumerable<FieldCodeShape> FindFields(Type type)
 		{
 			var fieldInfos = type.GetFields(BindingFlags.Public| BindingFlags.NonPublic| BindingFlags.Static| BindingFlags.Instance);
-			return fieldInfos.Select(fieldInfo => new FieldShape(fieldInfo.Name));
+			return fieldInfos.Select(fieldInfo => new FieldCodeShape(fieldInfo.Name));
 		}
 
-		private IEnumerable<IClassShape> FindAllPrivateMethods(Type type)
+		private IEnumerable<ICodeShape> FindAllPrivateMethods(Type type)
 		{
 			var methodInfos = type.GetMethods( BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);
-			return methodInfos.Select(methodInfo => new PrivateMethodShape(methodInfo, methodInfo.Name));
+			return methodInfos.Select(methodInfo => new PrivateMethodCodeShape(methodInfo, methodInfo.Name));
 		}
 
-		private IEnumerable<IClassShape> FindAllPublicMethods(Type type)
+		private IEnumerable<ICodeShape> FindAllPublicMethods(Type type)
 		{
-			return type.GetMethods().Select(methodInfo => new PublicMethodShape(methodInfo, methodInfo.Name)).ToList();
+			return type.GetMethods().Select(methodInfo => new PublicMethodCodeShape(methodInfo, methodInfo.Name)).ToList();
 		}
 	}
 }

File src/CodeShapes/CodeShapes.csproj

   </PropertyGroup>
   <ItemGroup>
     <Reference Include="QuickGraph">
-      <HintPath>..\..\..\libs\quickgraph.v3.5.net35\QuickGraph.dll</HintPath>
+      <HintPath>..\packages\QuickGraph.3.3.51106.0\lib\net35\QuickGraph.dll</HintPath>
+    </Reference>
+    <Reference Include="QuickGraph.Data">
+      <HintPath>..\packages\QuickGraph.3.3.51106.0\lib\net35\QuickGraph.Data.dll</HintPath>
+    </Reference>
+    <Reference Include="QuickGraph.Graphviz">
+      <HintPath>..\packages\QuickGraph.3.3.51106.0\lib\net35\QuickGraph.Graphviz.dll</HintPath>
+    </Reference>
+    <Reference Include="QuickGraph.Graphviz.Contracts">
+      <HintPath>..\packages\QuickGraph.3.3.51106.0\lib\net35\CodeContracts\QuickGraph.Graphviz.Contracts.dll</HintPath>
     </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />
     <Compile Include="Disassembler\Instruction.cs" />
     <Compile Include="Disassembler\MethodBodyReader.cs" />
     <Compile Include="Disassembler\MethodBaseRocks.cs" />
-    <Compile Include="Shapes\ClassShape.cs" />
-    <Compile Include="Shapes\FieldShape.cs" />
-    <Compile Include="Shapes\IClassShape.cs" />
+    <Compile Include="Shapes\CodeShape.cs" />
+    <Compile Include="Shapes\FieldCodeShape.cs" />
+    <Compile Include="Shapes\ICodeShape.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
-    <Compile Include="Shapes\MethodShape.cs" />
-    <Compile Include="Shapes\PrivateMethodShape.cs" />
-    <Compile Include="Shapes\PublicMethodShape.cs" />
+    <Compile Include="Shapes\MethodCodeShape.cs" />
+    <Compile Include="Shapes\PrivateMethodCodeShape.cs" />
+    <Compile Include="Shapes\PublicMethodCodeShape.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="packages.config" />
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 

File src/CodeShapes/Shapes/ClassShape.cs

-using System.Collections.Generic;
-
-namespace CodeShapes.Shapes
-{
-	public abstract class ClassShape : IClassShape
-	{
-		protected ClassShape(string methodName)
-		{
-			Name = methodName;
-			AdjacencyList = new Dictionary<int, IClassShape>();
-		}
-		public string Name { get; set; }
-
-		public IDictionary<int, IClassShape> AdjacencyList { get; private set; }
-	}
-}

File src/CodeShapes/Shapes/CodeShape.cs

+using System.Collections.Generic;
+
+namespace CodeShapes.Shapes
+{
+	public abstract class CodeShape : ICodeShape
+	{
+		protected CodeShape(string methodName)
+		{
+			Name = methodName;
+			AdjacencyList = new Dictionary<int, ICodeShape>();
+		}
+		public string Name { get; set; }
+
+		public IDictionary<int, ICodeShape> AdjacencyList { get; private set; }
+	}
+
+	public enum ShapeType
+	{
+		Method,
+		Property
+	}
+}

File src/CodeShapes/Shapes/FieldCodeShape.cs

+namespace CodeShapes.Shapes
+{
+	public class FieldCodeShape : CodeShape
+	{
+		public FieldCodeShape(string fieldName) : base(fieldName)
+		{
+		}
+	}
+}

File src/CodeShapes/Shapes/FieldShape.cs

-namespace CodeShapes.Shapes
-{
-	public class FieldShape : ClassShape
-	{
-		public FieldShape(string fieldName) : base(fieldName)
-		{
-		}
-	}
-}

File src/CodeShapes/Shapes/IClassShape.cs

-using System.Collections.Generic;
-
-namespace CodeShapes.Shapes
-{
-	public interface IClassShape
-	{
-		string Name { get; set; }
-		IDictionary<int, IClassShape> AdjacencyList { get;  }
-	}
-}

File src/CodeShapes/Shapes/ICodeShape.cs

+using System.Collections.Generic;
+
+namespace CodeShapes.Shapes
+{
+	public interface ICodeShape
+	{
+		string Name { get; set; }
+		IDictionary<int, ICodeShape> AdjacencyList { get;  }
+	}
+}

File src/CodeShapes/Shapes/MethodCodeShape.cs

+using System.Reflection;
+
+namespace CodeShapes.Shapes
+{
+	public class MethodCodeShape : CodeShape
+	{
+		public MethodCodeShape(MethodBase methodBase, string methodName)
+			: base(methodName)
+		{
+			MethodBase = methodBase;
+		}
+
+		public MethodCodeShape(string methodName)
+			: base(methodName)
+		{}
+
+		public MethodBase MethodBase { get; set; }
+	}
+}

File src/CodeShapes/Shapes/MethodShape.cs

-using System.Reflection;
-
-namespace CodeShapes.Shapes
-{
-	public class MethodShape : ClassShape
-	{
-		public MethodShape(MethodBase methodBase, string methodName)
-			: base(methodName)
-		{
-			MethodBase = methodBase;
-		}
-
-		public MethodShape(string methodName)
-			: base(methodName)
-		{}
-
-		public MethodBase MethodBase { get; set; }
-	}
-}

File src/CodeShapes/Shapes/PrivateMethodCodeShape.cs

+using System.Reflection;
+
+namespace CodeShapes.Shapes
+{
+	public class PrivateMethodCodeShape : MethodCodeShape
+	{
+		public PrivateMethodCodeShape(MethodBase methodBase, string methodName)
+			: base(methodBase, methodName)
+		{
+		}
+	}
+}

File src/CodeShapes/Shapes/PrivateMethodShape.cs

-using System.Reflection;
-
-namespace CodeShapes.Shapes
-{
-	public class PrivateMethodShape : MethodShape
-	{
-		public PrivateMethodShape(MethodBase methodBase, string methodName)
-			: base(methodBase, methodName)
-		{
-		}
-	}
-}

File src/CodeShapes/Shapes/PublicMethodCodeShape.cs

+using System.Reflection;
+
+namespace CodeShapes.Shapes
+{
+	public class PublicMethodCodeShape : MethodCodeShape
+	{
+		public PublicMethodCodeShape(MethodBase methodBase, string methodName)
+			: base(methodBase, methodName)
+		{
+		}
+	}
+}

File src/CodeShapes/Shapes/PublicMethodShape.cs

-using System.Reflection;
-
-namespace CodeShapes.Shapes
-{
-	public class PublicMethodShape : MethodShape
-	{
-		public PublicMethodShape(MethodBase methodBase, string fieldName)
-			: base(methodBase, fieldName)
-		{
-		}
-	}
-}

File src/CodeShapes/packages.config

+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="QuickGraph" version="3.3.51106.0" />
+</packages>

File src/CodeShapesTests/ClassAnalizerTests.cs

-using System.Collections.Generic;
-using System.Linq;
-using CodeShapes;
-using CodeShapes.Shapes;
-using Xunit;
-
-namespace CodeShapesTests
-{
-	public class ClassAnalizerTests
-	{
-		private readonly ClassAnalyzer _classAnalyzer;
-
-		public ClassAnalizerTests()
-		{
-			_classAnalyzer = new ClassAnalyzer();
-		}
-
-		[Fact]
-		public void When_class_exists_then_it_doesnt_throw()
-		{
-			Assert.DoesNotThrow(() => _classAnalyzer.Analyze<SampleClass>());
-		}
-
-
-		[Fact]
-		public void When_there_is_fields_present_then_return()
-		{
-			var classShapes = _classAnalyzer.Analyze<SampleClass>();
-
-			IEnumerable<IClassShape> fields = classShapes.Where(x => x.GetType().Equals(typeof(FieldShape)));
-
-			Assert.Contains(typeof(SampleClass).GetFields().First().Name, fields.Select(x=>x.Name));
-		}
-
-
-		[Fact]
-		public void When_field_is_readonly_then_its_counted_anyway()
-		{
-			var classShapes = _classAnalyzer.Analyze<SampleClass>();
-
-			var fields = classShapes.Where(x => x.GetType().Equals(typeof(FieldShape)));
-			Assert.Equal(2, fields.Count());
-			
-		}
-
-		[Fact]
-		public void When_there_is_a_public_method_on_the_class_Then_finds_it()
-		{
-			var classShapes = _classAnalyzer.Analyze<SampleClass>();
-
-			var collection = classShapes.Where(x => x.GetType().Name == "PublicMethodShape");
-			Assert.Equal("CodeShapesMethod", collection.First().Name);
-		}
-
-		[Fact]
-		public void When_there_is_a_public_method_present_the_must_return_publicMethodShape()
-		{
-			var classShapes = _classAnalyzer.Analyze<SampleClass>();
-
-			Assert.True(classShapes.Any(x => x.GetType().Equals(typeof(PublicMethodShape))));
-		}
-
-		[Fact]
-		public void When_there_is_a_private_method_present_the_must_return_privateMethodShape()
-		{
-			var classShapes = _classAnalyzer.Analyze<SampleClass>();
-
-			Assert.True(classShapes.Any(x => x.GetType().Equals(typeof(PublicMethodShape))));
-		}
-
-		[Fact]
-		public void When_there_is_a_recursive_method_the_adjacency_list_contains_itself_as_a_dependency()
-		{
-			var shapes = _classAnalyzer.Analyze<ClassWithRecursiveMethod>();
-
-			var methodShape = shapes.SingleOrDefault(s => s.Name == "ICallMyself");
-
-			Assert.NotNull(methodShape);
-
-			Assert.True(methodShape.AdjacencyList.Count == 1);
-			Assert.Same(methodShape, methodShape.AdjacencyList.Values.First());
-		}
-
-		[Fact]
-		public void Can_find_adjacency_from_private_to_public()
-		{
-			var shapes = _classAnalyzer.Analyze<ClassWithBiDirectionalDependency>();
-
-			IClassShape methodTwoShape = shapes.SingleOrDefault(s => s.Name == "MethodTwo");
-
-			Assert.NotEmpty(methodTwoShape.AdjacencyList.Values);
-			var methodTwoAdjacency = methodTwoShape.AdjacencyList.Values;
-
-
-			Assert.Equal("MethodOne", methodTwoAdjacency.First().Name);
-		}
-
-
-		[Fact]
-		public void When_there_is_a_bidirectional_dependency_between_methods_both_methods_adjacency_lists_contain_the_other()
-		{
-			var shapes = _classAnalyzer.Analyze<ClassWithBiDirectionalDependency>();
-
-			IClassShape methodOneShape = shapes.SingleOrDefault(s => s.Name == "MethodOne");
-			IClassShape methodTwoShape = shapes.SingleOrDefault(s => s.Name == "MethodTwo");
-
-			var methodOneAdjacency = methodOneShape.AdjacencyList.Values;
-			var methodTwoAdjacency = methodTwoShape.AdjacencyList.Values;
-
-			Assert.Equal(1, methodOneAdjacency.Count);
-			Assert.Same(methodOneAdjacency.First().Name, methodTwoShape.Name);
-			Assert.Same(methodTwoAdjacency.First().Name, methodOneShape.Name);
-		}
-
-		private class ClassWithBiDirectionalDependency
-		{
-			public void MethodOne()
-			{
-				MethodTwo();
-			}
-
-			private void MethodTwo()
-			{
-				MethodOne();
-			}
-		}
-
-		private class ClassWithRecursiveMethod
-		{
-			public void ICallMyself()
-			{
-				ICallMyself();
-			}
-		}
-	}
-}

File src/CodeShapesTests/ClassAnalyzerTests.cs

+using System;
+using System.Collections.Generic;
+using System.Linq;
+using CodeShapes;
+using CodeShapes.Shapes;
+using Xunit;
+
+namespace CodeShapesTests
+{
+	public class ClassAnalyzerTests
+	{
+		private readonly ClassAnalyzer _classAnalyzer;
+
+		public ClassAnalyzerTests()
+		{
+			_classAnalyzer = new ClassAnalyzer();
+		}
+
+		[Fact]
+		public void When_class_exists_then_it_doesnt_throw()
+		{
+			Assert.DoesNotThrow(() => _classAnalyzer.Analyze<SampleClass>());
+		}
+
+
+		[Fact]
+		public void When_there_is_fields_present_then_return()
+		{
+			var classShapes = _classAnalyzer.Analyze<SampleClass>();
+
+			IEnumerable<ICodeShape> fields = classShapes.Where(x => x.GetType().Equals(typeof(FieldCodeShape)));
+
+			Assert.Contains(typeof(SampleClass).GetFields().First().Name, fields.Select(x=>x.Name));
+		}
+
+		[Fact]
+		public void When_protected_method_then_return()
+		{
+			throw new NotImplementedException();
+		}
+
+		[Fact]
+		public void When_internal_method_then_return()
+		{
+			throw new NotImplementedException();
+		}
+
+
+		[Fact]
+		public void When_there_is_property_present_then_return()
+		{
+			var classShapes = _classAnalyzer.Analyze<SampleClassWithProperty>();
+
+			IEnumerable<ICodeShape> fields = classShapes.Where(x => x.GetType().Equals(typeof(FieldCodeShape)));
+
+			Assert.Contains(typeof(SampleClassWithProperty).GetFields().First().Name, fields.Select(x => x.Name));
+		}
+
+
+		[Fact]
+		public void When_field_is_readonly_then_its_counted_anyway()
+		{
+			var classShapes = _classAnalyzer.Analyze<SampleClass>();
+
+			var fields = classShapes.Where(x => x.GetType().Equals(typeof(FieldCodeShape)));
+			Assert.Equal(2, fields.Count());
+			
+		}
+
+		[Fact]
+		public void When_there_is_a_public_method_on_the_class_Then_finds_it()
+		{
+			var classShapes = _classAnalyzer.Analyze<SampleClass>();
+
+			var collection = classShapes.Where(x => x.GetType().Name == "PublicMethodCodeShape");
+			Assert.Equal("SampleMethod", collection.First().Name);
+		}
+
+		[Fact]
+		public void When_there_is_a_public_method_present_the_must_return_publicMethodShape()
+		{
+			var classShapes = _classAnalyzer.Analyze<SampleClass>();
+
+			Assert.True(classShapes.Any(x => x.GetType().Equals(typeof(PublicMethodCodeShape))));
+		}
+
+		[Fact]
+		public void When_there_is_a_private_method_present_the_must_return_privateMethodShape()
+		{
+			var classShapes = _classAnalyzer.Analyze<SampleClass>();
+
+			Assert.True(classShapes.Any(x => x.GetType().Equals(typeof(PublicMethodCodeShape))));
+		}
+
+		[Fact]
+		public void When_there_is_a_recursive_method_the_adjacency_list_contains_itself_as_a_dependency()
+		{
+			var shapes = _classAnalyzer.Analyze<ClassWithRecursiveMethod>();
+
+			var methodShape = shapes.SingleOrDefault(s => s.Name == "ICallMyself");
+
+			Assert.NotNull(methodShape);
+
+			Assert.True(methodShape.AdjacencyList.Count == 1);
+			Assert.Same(methodShape, methodShape.AdjacencyList.Values.First());
+		}
+
+		[Fact]
+		public void Can_find_adjacency_from_private_to_public()
+		{
+			var shapes = _classAnalyzer.Analyze<ClassWithBiDirectionalDependency>();
+
+			ICodeShape methodTwoCodeShape = shapes.SingleOrDefault(s => s.Name == "MethodTwo");
+
+			Assert.NotEmpty(methodTwoCodeShape.AdjacencyList.Values);
+			var methodTwoAdjacency = methodTwoCodeShape.AdjacencyList.Values;
+
+
+			Assert.Equal("MethodOne", methodTwoAdjacency.First().Name);
+		}
+
+
+		[Fact]
+		public void When_there_is_a_bidirectional_dependency_between_methods_both_methods_adjacency_lists_contain_the_other()
+		{
+			var shapes = _classAnalyzer.Analyze<ClassWithBiDirectionalDependency>();
+
+			ICodeShape methodOneCodeShape = shapes.SingleOrDefault(s => s.Name == "MethodOne");
+			ICodeShape methodTwoCodeShape = shapes.SingleOrDefault(s => s.Name == "MethodTwo");
+
+			var methodOneAdjacency = methodOneCodeShape.AdjacencyList.Values;
+			var methodTwoAdjacency = methodTwoCodeShape.AdjacencyList.Values;
+
+			Assert.Equal(1, methodOneAdjacency.Count);
+			Assert.Same(methodOneAdjacency.First().Name, methodTwoCodeShape.Name);
+			Assert.Same(methodTwoAdjacency.First().Name, methodOneCodeShape.Name);
+		}
+
+		private class ClassWithBiDirectionalDependency
+		{
+			public void MethodOne()
+			{
+				MethodTwo();
+			}
+
+			private void MethodTwo()
+			{
+				MethodOne();
+			}
+		}
+
+		private class ClassWithRecursiveMethod
+		{
+			public void ICallMyself()
+			{
+				ICallMyself();
+			}
+		}
+	}
+
+	public class SampleClassWithProperty
+	{
+		public string SampleProperty { get; set; }
+
+		public void SampleMethod()
+		{
+			SampleProperty = "Blah";
+		}
+	}
+}

File src/CodeShapesTests/CodeShapeAcceptanceTests.cs

+using System;
+using StoryQ;
+using Xunit;
+
+namespace CodeShapesTests
+{
+	public class CodeShapeAcceptanceTests
+	{
+		private Feature _feature;
+
+		public CodeShapeAcceptanceTests()
+		{
+			 var story = new Story("");
+			_feature = story.InOrderTo("Create a graph")
+				.AsA("developer")
+				.IWant("to enter a class collection and get a collection of images"); 
+			
+		}
+
+		[Fact]
+		public void When_something_then_something()
+		{
+			_feature.WithScenario("submitting a class type returns one graph")
+				.Given(AClass)
+				.When(IRunTheAnalizeMethod)
+				.Then(AnImageRepresentationOfTheClassIsCreated)
+				.And(AStringRepresentationAvailableToo)
+				.ExecuteWithReport();
+		}
+
+		[Fact]
+		public void When_something_then_something2()
+		{
+		}
+		
+		private void AStringRepresentationAvailableToo()
+		{
+			throw new NotImplementedException();
+		}
+
+		private void AnImageRepresentationOfTheClassIsCreated()
+		{
+			throw new NotImplementedException();
+		}
+
+		private void IRunTheAnalizeMethod()
+		{
+			throw new NotImplementedException();
+		}
+
+		private void AClass()
+		{
+			throw new NotImplementedException();
+		}
+	}
+}

File src/CodeShapesTests/CodeShapesTests.csproj

     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="QuickGraph">
+      <HintPath>..\packages\QuickGraph.3.3.51106.0\lib\net35\QuickGraph.dll</HintPath>
+    </Reference>
+    <Reference Include="QuickGraph.Data">
+      <HintPath>..\packages\QuickGraph.3.3.51106.0\lib\net35\QuickGraph.Data.dll</HintPath>
+    </Reference>
+    <Reference Include="QuickGraph.Graphviz">
+      <HintPath>..\packages\QuickGraph.3.3.51106.0\lib\net35\QuickGraph.Graphviz.dll</HintPath>
+    </Reference>
+    <Reference Include="StoryQ">
+      <HintPath>..\packages\StoryQ.2.0.5\lib\StoryQ.dll</HintPath>
+    </Reference>
+    <Reference Include="StoryQ.pt-BR">
+      <HintPath>..\packages\StoryQ.2.0.5\lib\StoryQ.pt-BR.dll</HintPath>
+    </Reference>
+    <Reference Include="StoryQ.sr-SP">
+      <HintPath>..\packages\StoryQ.2.0.5\lib\StoryQ.sr-SP.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />
     <Reference Include="System.Xml.Linq" />
     </Reference>
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="CodeShapeAcceptanceTests.cs" />
     <Compile Include="InstructionTests.cs" />
-    <Compile Include="ClassAnalizerTests.cs" />
+    <Compile Include="ClassAnalyzerTests.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="SampleClass.cs" />
   </ItemGroup>

File src/CodeShapesTests/InstructionTests.cs

-using Xunit;
+using System;
+using System.Collections.Generic;
+using CodeShapes.Shapes;
+using QuickGraph;
+using QuickGraph.Graphviz;
+using Xunit;
 
 namespace CodeShapesTests
 {
+	public class Given_a_collection_Shapes
+	{
+		[Fact]
+		public void When_transforming_to_graph_It_does_not_throw()
+		{
+			IEnumerable<ICodeShape> shapes = new List<ICodeShape>();
+			var transformToGraph = new TransformToGraph(shapes);
+			Assert.DoesNotThrow(() =>  transformToGraph.Transform());
+		}
+
+		[Fact]
+		public void when_shape_collection_contains_a_method_referencing_a_property_Then_result()
+		{
+			var name = "SampleMethod";
+			IEnumerable<ICodeShape> shapes = CreateShapes(name);
+			var transformToGraph = new TransformToGraph(shapes);
+			var adjacencyGraph = transformToGraph.Transform();
+
+			var generate = new GraphvizAlgorithm<ICodeShape, SEdge<ICodeShape>>(adjacencyGraph).Generate();
+		}
+
+		private IEnumerable<ICodeShape> CreateShapes(string name)
+		{
+			var methodInfo = typeof (SampleClass).GetMethod(name);
+			var fieldCodeShape = new FieldCodeShape("PublicField");
+			var publicMethodCodeShape = new PublicMethodCodeShape(methodInfo, name);
+			publicMethodCodeShape.AdjacencyList.Add(1, fieldCodeShape);
+			return new List<ICodeShape>()
+			       	{
+			       		publicMethodCodeShape,
+			       		fieldCodeShape
+			       	};
+		}
+	}
+
+	public class TransformToGraph
+	{
+		private readonly IEnumerable<ICodeShape> _codeShapes;
+
+		public TransformToGraph(IEnumerable<ICodeShape> codeShapes)
+		{
+			_codeShapes = codeShapes;
+		}
+
+		public AdjacencyGraph<ICodeShape, SEdge<ICodeShape>> Transform()
+		{
+			var adjacencyGraph = new AdjacencyGraph<ICodeShape, SEdge<ICodeShape>>();
+			foreach (var shape in _codeShapes)
+			{
+				adjacencyGraph.AddVertex(shape);
+			}
+			foreach (var codeShape in _codeShapes)
+			{
+				foreach (var shape in codeShape.AdjacencyList)
+				{
+					adjacencyGraph.AddEdge(new SEdge<ICodeShape>(codeShape, shape.Value));
+				}
+			}
+			return adjacencyGraph;
+		}
+	}
+
 	public class InstructionTests
 	{
 //		private AssemblyAnalizer _assemblyAnalizer;

File src/CodeShapesTests/SampleClass.cs

 		private string _privateField;
 		public string PublicField;
 
-		public string CodeShapesMethod()
+		public string SampleMethod()
 		{
 			_privateField = "Bla";
 			PublicField = "Blah";

File src/CodeShapesTests/packages.config

 <?xml version="1.0" encoding="utf-8"?>
 <packages>
   <package id="xunit" version="1.8.0.1545" />
+  <package id="StoryQ" version="2.0.5" />
+  <package id="QuickGraph" version="3.3.51106.0" />
 </packages>