Skip to content

Commit

Permalink
Added ApiApprover
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeGinnivan committed Aug 23, 2015
1 parent 928818c commit e984fe1
Show file tree
Hide file tree
Showing 30 changed files with 1,856 additions and 214 deletions.
19 changes: 19 additions & 0 deletions src/DbUp.Console/DbUp.Console.v2.ncrunchproject
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<ProjectConfiguration>
<CopyReferencedAssembliesToWorkspace>false</CopyReferencedAssembliesToWorkspace>
<ConsiderInconclusiveTestsAsPassing>false</ConsiderInconclusiveTestsAsPassing>
<PreloadReferencedAssemblies>false</PreloadReferencedAssemblies>
<AllowDynamicCodeContractChecking>true</AllowDynamicCodeContractChecking>
<AllowStaticCodeContractChecking>false</AllowStaticCodeContractChecking>
<IgnoreThisComponentCompletely>false</IgnoreThisComponentCompletely>
<RunPreBuildEvents>false</RunPreBuildEvents>
<RunPostBuildEvents>false</RunPostBuildEvents>
<PreviouslyBuiltSuccessfully>true</PreviouslyBuiltSuccessfully>
<InstrumentAssembly>true</InstrumentAssembly>
<PreventSigningOfAssembly>false</PreventSigningOfAssembly>
<AnalyseExecutionTimes>true</AnalyseExecutionTimes>
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
<DefaultTestTimeout>60000</DefaultTestTimeout>
<UseBuildConfiguration />
<ProxyProcessPath />
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
</ProjectConfiguration>
Binary file added src/DbUp.Firebird/DbUp.Firebird.v2.ncrunchproject
Binary file not shown.
7 changes: 7 additions & 0 deletions src/DbUp.MySql/DbUp.MySql.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\DbUp.MySql.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>dbup.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="MySql.Data">
<HintPath>..\..\lib\MySql.Data.6.9.3\lib\net20\MySql.Data.dll</HintPath>
Expand All @@ -57,6 +63,7 @@
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="dbup.snk" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
Binary file added src/DbUp.MySql/DbUp.MySql.v2.ncrunchproject
Binary file not shown.
Binary file added src/DbUp.MySql/dbup.snk
Binary file not shown.
Binary file not shown.
22 changes: 22 additions & 0 deletions src/DbUp.SQLite/DbUp.SQLite.v2.ncrunchproject
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<ProjectConfiguration>
<CopyReferencedAssembliesToWorkspace>false</CopyReferencedAssembliesToWorkspace>
<ConsiderInconclusiveTestsAsPassing>false</ConsiderInconclusiveTestsAsPassing>
<PreloadReferencedAssemblies>false</PreloadReferencedAssemblies>
<AllowDynamicCodeContractChecking>true</AllowDynamicCodeContractChecking>
<AllowStaticCodeContractChecking>false</AllowStaticCodeContractChecking>
<IgnoreThisComponentCompletely>false</IgnoreThisComponentCompletely>
<RunPreBuildEvents>false</RunPreBuildEvents>
<RunPostBuildEvents>false</RunPostBuildEvents>
<PreviouslyBuiltSuccessfully>true</PreviouslyBuiltSuccessfully>
<InstrumentAssembly>true</InstrumentAssembly>
<PreventSigningOfAssembly>false</PreventSigningOfAssembly>
<AnalyseExecutionTimes>true</AnalyseExecutionTimes>
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
<DefaultTestTimeout>60000</DefaultTestTimeout>
<UseBuildConfiguration />
<UseBuildPlatform />
<ProxyProcessPath />
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
<MSTestThreadApartmentState>STA</MSTestThreadApartmentState>
<BuildProcessArchitecture>x86</BuildProcessArchitecture>
</ProjectConfiguration>
19 changes: 19 additions & 0 deletions src/DbUp.SqlCe/DbUp.SqlCe.v2.ncrunchproject
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<ProjectConfiguration>
<CopyReferencedAssembliesToWorkspace>false</CopyReferencedAssembliesToWorkspace>
<ConsiderInconclusiveTestsAsPassing>false</ConsiderInconclusiveTestsAsPassing>
<PreloadReferencedAssemblies>false</PreloadReferencedAssemblies>
<AllowDynamicCodeContractChecking>true</AllowDynamicCodeContractChecking>
<AllowStaticCodeContractChecking>false</AllowStaticCodeContractChecking>
<IgnoreThisComponentCompletely>false</IgnoreThisComponentCompletely>
<RunPreBuildEvents>false</RunPreBuildEvents>
<RunPostBuildEvents>false</RunPostBuildEvents>
<PreviouslyBuiltSuccessfully>true</PreviouslyBuiltSuccessfully>
<InstrumentAssembly>true</InstrumentAssembly>
<PreventSigningOfAssembly>false</PreventSigningOfAssembly>
<AnalyseExecutionTimes>true</AnalyseExecutionTimes>
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
<DefaultTestTimeout>60000</DefaultTestTimeout>
<UseBuildConfiguration />
<ProxyProcessPath />
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
</ProjectConfiguration>
48 changes: 48 additions & 0 deletions src/DbUp.Tests/ApiTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using ApiApprover;
using ApprovalTests.Reporters;
using DbUp.Builder;
using NUnit.Framework;

namespace DbUp.Tests
{
[TestFixture]
[UseReporter(typeof(DiffReporter))]
public class ApiTests
{
[Test]
public void dbup_has_no_public_api_changes()
{
PublicApiApprover.ApprovePublicApi(typeof(SupportedDatabases).Assembly.Location);
}

[Test]
public void dbup_firebird_has_no_public_api_changes()
{
PublicApiApprover.ApprovePublicApi(typeof(FirebirdExtensions).Assembly.Location);
}

[Test]
public void dbup_mysql_has_no_public_api_changes()
{
PublicApiApprover.ApprovePublicApi(typeof(MySqlExtensions).Assembly.Location);
}

[Test]
public void dbup_postgres_has_no_public_api_changes()
{
PublicApiApprover.ApprovePublicApi(typeof(PostgresqlExtensions).Assembly.Location);
}

[Test]
public void dbup_sqlce_has_no_public_api_changes()
{
PublicApiApprover.ApprovePublicApi(typeof(SqlCeExtensions).Assembly.Location);
}

[Test]
public void dbup_sqlite_has_no_public_api_changes()
{
PublicApiApprover.ApprovePublicApi(typeof(SQLiteExtensions).Assembly.Location);
}
}
}
43 changes: 43 additions & 0 deletions src/DbUp.Tests/App_Packages/ApiApprover.3.0.1/PublicApiApprover.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System.IO;
using ApprovalTests;
using ApprovalTests.Namers;
using Mono.Cecil;

namespace ApiApprover
{
public static class PublicApiApprover
{
public static void ApprovePublicApi(string assemblyPath)
{
var assemblyResolver = new DefaultAssemblyResolver();
assemblyResolver.AddSearchDirectory(Path.GetDirectoryName(assemblyPath));

var readSymbols = File.Exists(Path.ChangeExtension(assemblyPath, ".pdb"));
var asm = AssemblyDefinition.ReadAssembly(assemblyPath, new ReaderParameters(ReadingMode.Deferred)
{
ReadSymbols = readSymbols,
AssemblyResolver = assemblyResolver,
});

var publicApi = PublicApiGenerator.CreatePublicApiForAssembly(asm);
var writer = new ApprovalTextWriter(publicApi, "cs");
var approvalNamer = new AssemblyPathNamer(assemblyPath);
ApprovalTests.Approvals.Verify(writer, approvalNamer, ApprovalTests.Approvals.GetReporter());
}

private class AssemblyPathNamer : UnitTestFrameworkNamer
{
private readonly string name;

public AssemblyPathNamer(string assemblyPath)
{
name = Path.GetFileNameWithoutExtension(assemblyPath);
}

public override string Name
{
get { return name; }
}
}
}
}
Loading

0 comments on commit e984fe1

Please sign in to comment.