-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 81241ce
Showing
97 changed files
with
35,069 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
bin/ | ||
obj/ | ||
_ReSharper.GraphVizWrapper/ | ||
Thumbs.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
= Project Description | ||
This is a C# wrapper for the GraphViz graph generator. | ||
|
||
Pass in a dot string and an output type and voila, your graph is generated. | ||
|
||
The output file is returned to you as a byte array to do as you please. | ||
|
||
This library acts as a wrapper for the GraphViz command line tools. The graphviz command line tools are included in this project and need to be placed in the graphviz folder relative to the GraphVizWrapper dll upon deployment. | ||
|
||
== Usage | ||
|
||
// These three instances can be injected via the IGetStartProcessQuery, IGetProcessStartInfoQuery and IRegisterLayoutPluginCommand interfaces | ||
|
||
var getStartProcessQuery = new GetStartProcessQuery(); | ||
var getProcessStartInfoQuery = new GetProcessStartInfoQuery(); | ||
var registerLayoutPluginCommand = new RegisterLayoutPluginCommand(); | ||
|
||
// GraphVizWrapper can be injected via the IGraphVizWrapper interface | ||
|
||
var wrapper = new GraphVizWrapper(getStartProcessQuery, getProcessStartInfoQuery, registerLayoutPluginCommand); | ||
|
||
byte[] output = wrapper.GenerateGraph("digraph{a -> b; b -> c; c -> a;}", Enums.GraphReturnType.Png); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2013 Jamie Dixon http://www.jamie-dixon.co.uk | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProductVersion>8.0.30703</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{B561F813-067D-4602-8786-CD680154879A}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>GraphVizWrapper.Tests</RootNamespace> | ||
<AssemblyName>GraphVizWrapper.Tests</AssemblyName> | ||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Moq"> | ||
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath> | ||
</Reference> | ||
<Reference Include="nunit.framework"> | ||
<HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll</HintPath> | ||
</Reference> | ||
<Reference Include="nunit.mocks"> | ||
<HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.mocks.dll</HintPath> | ||
</Reference> | ||
<Reference Include="pnunit.framework"> | ||
<HintPath>..\packages\NUnit.2.5.10.11092\lib\pnunit.framework.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="Tests.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\GraphVizWrapper\GraphVizWrapper.csproj"> | ||
<Project>{CFEC60DC-14E0-47E4-A60E-8919FB5FEF5D}</Project> | ||
<Name>GraphVizWrapper</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("GraphVizWrapper.Tests")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("Microsoft")] | ||
[assembly: AssemblyProduct("GraphVizWrapper.Tests")] | ||
[assembly: AssemblyCopyright("Copyright © Microsoft 2011")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("a49ab49f-f9ff-4dd7-bbc7-16a29f1cd603")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System.Diagnostics; | ||
using GraphVizWrapper.Interfaces; | ||
using GraphVizWrapper.Queries; | ||
using Moq; | ||
using NUnit.Framework; | ||
|
||
namespace GraphVizWrapper.Tests | ||
{ | ||
[TestFixture] | ||
public class Tests | ||
{ | ||
private Mock<IRegisterLayoutPluginCommand> _registerLayoutPluginCommandMock; | ||
private Mock<IGetProcessStartInfoQuery> _getProcessStartInfoQuery; | ||
private IGetStartProcessQuery _getStartProcessQuery; | ||
|
||
[SetUp] | ||
public void Init() | ||
{ | ||
_getProcessStartInfoQuery = new Mock<IGetProcessStartInfoQuery>(); | ||
_registerLayoutPluginCommandMock = new Mock<IRegisterLayoutPluginCommand>(); | ||
_getStartProcessQuery = new GetStartProcessQuery(); | ||
} | ||
|
||
[Test] | ||
public void GenerateGraphReturnsByteArrayWithLengthGreaterOrEqualZero() | ||
{ | ||
// Arrange | ||
_registerLayoutPluginCommandMock.Setup(m => m.Invoke()); | ||
_getProcessStartInfoQuery.Setup(m => m.Invoke(It.IsAny<IProcessStartInfoWrapper>())).Returns( | ||
new ProcessStartInfo | ||
{ | ||
FileName = "cmd", | ||
RedirectStandardInput = true, | ||
RedirectStandardOutput = true, | ||
RedirectStandardError = true, | ||
UseShellExecute = false, | ||
CreateNoWindow = true | ||
}); | ||
|
||
var wrapper = new GraphVizWrapper( | ||
_getStartProcessQuery, | ||
_getProcessStartInfoQuery.Object, | ||
_registerLayoutPluginCommandMock.Object); | ||
|
||
// Act | ||
byte[] output = wrapper.GenerateGraph("digraph{a -> b; b -> c; c -> a;}", Enums.GraphReturnType.Png); | ||
|
||
// Assert | ||
Assert.That(output.Length, Is.GreaterThanOrEqualTo(0)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Moq" version="4.0.10827" /> | ||
<package id="NUnit" version="2.5.10.11092" /> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 11.00 | ||
# Visual Studio 2010 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GraphVizWrapper", "GraphVizWrapper\GraphVizWrapper.csproj", "{CFEC60DC-14E0-47E4-A60E-8919FB5FEF5D}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GraphVizWrapper.Tests", "GraphVizWrapper.Tests\GraphVizWrapper.Tests.csproj", "{B561F813-067D-4602-8786-CD680154879A}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{CFEC60DC-14E0-47E4-A60E-8919FB5FEF5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{CFEC60DC-14E0-47E4-A60E-8919FB5FEF5D}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{CFEC60DC-14E0-47E4-A60E-8919FB5FEF5D}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{CFEC60DC-14E0-47E4-A60E-8919FB5FEF5D}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{B561F813-067D-4602-8786-CD680154879A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{B561F813-067D-4602-8786-CD680154879A}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{B561F813-067D-4602-8786-CD680154879A}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{B561F813-067D-4602-8786-CD680154879A}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:String x:Key="/Default/FilterSettingsManager/CoverageFilterXml/@EntryValue"><data><IncludeFilters /><ExcludeFilters /></data></s:String> | ||
<s:String x:Key="/Default/FilterSettingsManager/AttributeFilterXml/@EntryValue"><data /></s:String></wpf:ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:String x:Key="/Default/Environment/UnitTesting/NUnitProvider/UseAddins/@EntryValue">Never</s:String> | ||
<s:Boolean x:Key="/Default/Housekeeping/SolutionSettingsUpgraded/IsUpgraded/@EntryValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/Housekeeping/UnitTestingMru/UnitTestSessionPersistentData/=B63461FAC62B474CBB7ABA783DF6EA14/@KeyIndexDefined">True</s:Boolean> | ||
<s:String x:Key="/Default/Housekeeping/UnitTestingMru/UnitTestSessionPersistentData/=B63461FAC62B474CBB7ABA783DF6EA14/Name/@EntryValue">Tests</s:String> | ||
<s:String x:Key="/Default/Housekeeping/UnitTestingMru/UnitTestSessionPersistentData/=B63461FAC62B474CBB7ABA783DF6EA14/XmlSerializedElements/@EntryValue"><Session><Elements><UnitTestElement Provider="nUnit" Id="GraphVizWrapper.Tests.Tests" type="NUnitTestFixtureElement" Project="B561F813-067D-4602-8786-CD680154879A" /><UnitTestElement Provider="nUnit" Id="GraphVizWrapper.Tests.Tests.GenerateGraphReturnsByteArrayWithLengthGreaterOrEqualZero" ParentId="GraphVizWrapper.Tests.Tests" type="NUnitTestElement" TypeName="GraphVizWrapper.Tests.Tests" MethodName="GenerateGraphReturnsByteArrayWithLengthGreaterOrEqualZero" Project="B561F813-067D-4602-8786-CD680154879A" /></Elements></Session></s:String></wpf:ResourceDictionary> |
Binary file not shown.
Binary file not shown.
28 changes: 28 additions & 0 deletions
28
src/GraphVizWrapper/Commands/RegisterLayoutPluginCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using GraphVizWrapper.Interfaces; | ||
|
||
namespace GraphVizWrapper.Commands | ||
{ | ||
public class RegisterLayoutPluginCommand : IRegisterLayoutPluginCommand | ||
{ | ||
private readonly IGetProcessStartInfoQuery _getProcessStartInfoQuery; | ||
private readonly IGetStartProcessQuery _getStartProcessQuery; | ||
|
||
public RegisterLayoutPluginCommand(IGetProcessStartInfoQuery getProcessStartInfoQuery, IGetStartProcessQuery getStartProcessQuery) | ||
{ | ||
_getStartProcessQuery = getStartProcessQuery; | ||
_getProcessStartInfoQuery = getProcessStartInfoQuery; | ||
} | ||
|
||
public void Invoke() | ||
{ | ||
var processStartInfo = _getProcessStartInfoQuery.Invoke(new ProcessStartInfoWrapper | ||
{ | ||
UseShellExecute = false, | ||
Arguments = "-c", | ||
CreateNoWindow = false | ||
}); | ||
|
||
using (_getStartProcessQuery.Invoke(processStartInfo)) { } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace GraphVizWrapper | ||
{ | ||
public static class Enums | ||
{ | ||
public enum GraphReturnType | ||
{ | ||
Pdf, | ||
Jpg, | ||
Png | ||
} | ||
|
||
public enum RenderingEngine | ||
{ | ||
Dot, // First item in enum is default rendering engine (E[0]) | ||
Neato, | ||
Fdp | ||
} | ||
} | ||
} |
Oops, something went wrong.