Permalink
Browse files

Adds support for MS Access databases

  • Loading branch information...
pleb committed Jan 30, 2016
1 parent 1e16960 commit d57cd9155610d534ce08d3857d2b4976966c75e8
Showing with 627 additions and 12 deletions.
  1. +39 −0 PetaPoco.Tests.Integration.x86/Databases/MSAccess/MsAccessDBTestProvider.cs
  2. +25 −0 PetaPoco.Tests.Integration.x86/Databases/MSAccess/MsAccessDatabaseTests.cs
  3. +20 −0 PetaPoco.Tests.Integration.x86/Databases/MSAccess/MsAccessDeleteTests.cs
  4. +20 −0 PetaPoco.Tests.Integration.x86/Databases/MSAccess/MsAccessExecuteTests.cs
  5. +20 −0 PetaPoco.Tests.Integration.x86/Databases/MSAccess/MsAccessInsertTests.cs
  6. +20 −0 PetaPoco.Tests.Integration.x86/Databases/MSAccess/MsAccessQueryLinqTests.cs
  7. +32 −0 PetaPoco.Tests.Integration.x86/Databases/MSAccess/MsAccessQueryTests.cs
  8. +14 −0 PetaPoco.Tests.Integration.x86/Databases/MSAccess/MsAccessUpdateTests.cs
  9. BIN PetaPoco.Tests.Integration.x86/Databases/MSAccess/petapoco.accdb
  10. +114 −0 PetaPoco.Tests.Integration.x86/PetaPoco.Tests.Integration.x86.csproj
  11. +70 −0 PetaPoco.Tests.Integration.x86/PetaPoco.Tests.Integration.x86.ruleset
  12. +36 −0 PetaPoco.Tests.Integration.x86/Properties/AssemblyInfo.cs
  13. +67 −0 PetaPoco.Tests.Integration.x86/Scripts/MSAccessBuildDatabase.sql
  14. +10 −0 PetaPoco.Tests.Integration.x86/app.config
  15. +12 −0 PetaPoco.Tests.Integration.x86/packages.config
  16. +1 −1 PetaPoco.Tests.Integration/Databases/BaseDatabaseTests.cs
  17. +62 −0 PetaPoco.Tests.Integration/Databases/BaseQueryTests.cs
  18. +6 −0 PetaPoco.sln
  19. +1 −0 PetaPoco.sln.DotSettings
  20. +16 −4 PetaPoco/Core/DatabaseProvider.cs
  21. +6 −6 PetaPoco/Database.cs
  22. +1 −0 PetaPoco/PetaPoco.csproj
  23. +34 −0 PetaPoco/Providers/MsAccessDbDatabaseProvider.cs
  24. +1 −1 README.markdown
@@ -0,0 +1,39 @@
// <copyright company="PetaPoco - CollaboratingPlatypus">
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/29</date>
using System.Linq;
using PetaPoco.Tests.Integration.Databases;
namespace PetaPoco.Tests.Integration.x86.Databases.MSAccess
{
public class MsAccessDBTestProvider : DBTestProvider
{
protected override IDatabase Database => DatabaseConfiguration.Build().UsingConnectionStringName("msaccess").Create();
protected override string ScriptResourceName => "PetaPoco.Tests.Integration.x86.Scripts.MSAccessBuildDatabase.sql";
public override void ExecuteBuildScript(IDatabase database, string script)
{
script.Split(';').Select(s => s.Trim()).Where(s => !string.IsNullOrWhiteSpace(s)).ToList().ForEach(s =>
{
if (s.StartsWith("DROP"))
{
try
{
base.ExecuteBuildScript(database, s);
}
catch
{
}
}
else
{
base.ExecuteBuildScript(database, s);
}
});
}
}
}
@@ -0,0 +1,25 @@
// <copyright company="PetaPoco - CollaboratingPlatypus">
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/29</date>
using PetaPoco.Tests.Integration.Databases;
using Xunit;
namespace PetaPoco.Tests.Integration.x86.Databases.MSAccess
{
[Collection("MSAccessTests")]
public class MsAccessDatabaseTests : BaseDatabaseTests
{
public MsAccessDatabaseTests()
: base(new MsAccessDBTestProvider())
{
}
public override void BeginTransaction_WhenIsolationLevelIsSet_ShouldBeOfIsolationLevel()
{
// Not supported by provider.
}
}
}
@@ -0,0 +1,20 @@
// <copyright company="PetaPoco - CollaboratingPlatypus">
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/29</date>
using PetaPoco.Tests.Integration.Databases;
using Xunit;
namespace PetaPoco.Tests.Integration.x86.Databases.MSAccess
{
[Collection("MSAccessTests")]
public class MsAccessDeleteTests : BaseDeleteTests
{
public MsAccessDeleteTests()
: base(new MsAccessDBTestProvider())
{
}
}
}
@@ -0,0 +1,20 @@
// <copyright company="PetaPoco - CollaboratingPlatypus">
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/29</date>
using PetaPoco.Tests.Integration.Databases;
using Xunit;
namespace PetaPoco.Tests.Integration.x86.Databases.MSAccess
{
[Collection("MSAccessTests")]
public class MsAccessExecuteTests : BaseExecuteTests
{
public MsAccessExecuteTests()
: base(new MsAccessDBTestProvider())
{
}
}
}
@@ -0,0 +1,20 @@
// <copyright company="PetaPoco - CollaboratingPlatypus">
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/29</date>
using PetaPoco.Tests.Integration.Databases;
using Xunit;
namespace PetaPoco.Tests.Integration.x86.Databases.MSAccess
{
[Collection("MSAccessTests")]
public class MsAccessInsertTests : BaseInsertTests
{
public MsAccessInsertTests()
: base(new MsAccessDBTestProvider())
{
}
}
}
@@ -0,0 +1,20 @@
// <copyright company="PetaPoco - CollaboratingPlatypus">
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/29</date>
using PetaPoco.Tests.Integration.Databases;
using Xunit;
namespace PetaPoco.Tests.Integration.x86.Databases.MSAccess
{
[Collection("MSAccessTests")]
public class MsAccessQueryLinqTests : BaseQueryLinqTests
{
public MsAccessQueryLinqTests()
: base(new MsAccessDBTestProvider())
{
}
}
}
@@ -0,0 +1,32 @@
// <copyright company="PetaPoco - CollaboratingPlatypus">
// Apache License, Version 2.0 https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt
// </copyright>
// <author>PetaPoco - CollaboratingPlatypus</author>
// <date>2016/01/29</date>
using System;
using PetaPoco.Tests.Integration.Databases;
using Shouldly;
using Xunit;
namespace PetaPoco.Tests.Integration.x86.Databases.MSAccess
{
[Collection("MSAccessTests")]
public class MsAccessQueryTests : BaseQueryTests
{
public MsAccessQueryTests()
: base(new MsAccessDBTestProvider())
{
}
public override void Page_ForPocoGivenSqlWithoutOrderByParameterPageItemAndPerPage_ShouldReturnValidPocoCollection()
{
Should.Throw<NotSupportedException>(() => base.Page_ForPocoGivenSqlWithoutOrderByParameterPageItemAndPerPage_ShouldReturnValidPocoCollection());
}
public override void Page_ForPocoSqlWithOrderByParameterPageItemAndPerPage_ShouldReturnValidPocoCollection()
{
Should.Throw<NotSupportedException>(() => base.Page_ForPocoGivenSqlWithoutOrderByParameterPageItemAndPerPage_ShouldReturnValidPocoCollection());
}
}
}
@@ -0,0 +1,14 @@
using PetaPoco.Tests.Integration.Databases;
using Xunit;
namespace PetaPoco.Tests.Integration.x86.Databases.MSAccess
{
[Collection("MSAccessTests")]
public class MsAccessUpdateTests : BaseUpdateTests
{
public MsAccessUpdateTests()
: base(new MsAccessDBTestProvider())
{
}
}
}
@@ -0,0 +1,114 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{9AAEF733-6F2A-4297-A0E2-D065212940A3}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>PetaPoco.Tests.Integration.x86</RootNamespace>
<AssemblyName>PetaPoco.Tests.Integration.x86</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</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>
<CodeAnalysisRuleSet>PetaPoco.Tests.Integration.x86.ruleset</CodeAnalysisRuleSet>
<PlatformTarget>x86</PlatformTarget>
</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>
<CodeAnalysisRuleSet>PetaPoco.Tests.Integration.x86.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Moq, Version=4.2.1510.2205, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Shouldly, Version=2.6.0.0, Culture=neutral, PublicKeyToken=6042cbcb05cbc941, processorArchitecture=MSIL">
<HintPath>..\packages\Shouldly.2.6.0\lib\net40\Shouldly.dll</HintPath>
<Private>True</Private>
</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.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.assert, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.assert.2.1.0\lib\dotnet\xunit.assert.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.core, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.extensibility.core.2.1.0\lib\dotnet\xunit.core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.execution.desktop, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Databases\MSAccess\MsAccessDatabaseTests.cs" />
<Compile Include="Databases\MSAccess\MsAccessDBTestProvider.cs" />
<Compile Include="Databases\MSAccess\MsAccessDeleteTests.cs" />
<Compile Include="Databases\MSAccess\MsAccessExecuteTests.cs" />
<Compile Include="Databases\MSAccess\MsAccessInsertTests.cs" />
<Compile Include="Databases\MSAccess\MsAccessQueryLinqTests.cs" />
<Compile Include="Databases\MSAccess\MsAccessQueryTests.cs" />
<Compile Include="Databases\MSAccess\MsAccessUpdateTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="PetaPoco.Tests.Integration.x86.ruleset">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="Databases\MSAccess\petapoco.accdb">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<EmbeddedResource Include="Scripts\MSAccessBuildDatabase.sql">
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PetaPoco.Tests.Integration\PetaPoco.Tests.Integration.csproj">
<Project>{560cd8e5-d810-4a57-a5fe-4e39d97662cc}</Project>
<Name>PetaPoco.Tests.Integration</Name>
</ProjectReference>
<ProjectReference Include="..\PetaPoco\PetaPoco.csproj">
<Project>{33699753-151d-4100-8f12-9ae1aeb5c5bd}</Project>
<Name>PetaPoco</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>
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="Rules for PetaPoco.Tests.Integration.x86" Description="Code analysis rules for PetaPoco.Tests.Integration.x86.csproj." ToolsVersion="14.0">
<Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
<Rule Id="CA1001" Action="Warning" />
<Rule Id="CA1009" Action="Warning" />
<Rule Id="CA1016" Action="Warning" />
<Rule Id="CA1033" Action="Warning" />
<Rule Id="CA1049" Action="Warning" />
<Rule Id="CA1060" Action="Warning" />
<Rule Id="CA1061" Action="Warning" />
<Rule Id="CA1063" Action="Warning" />
<Rule Id="CA1065" Action="Warning" />
<Rule Id="CA1301" Action="Warning" />
<Rule Id="CA1400" Action="Warning" />
<Rule Id="CA1401" Action="Warning" />
<Rule Id="CA1403" Action="Warning" />
<Rule Id="CA1404" Action="Warning" />
<Rule Id="CA1405" Action="Warning" />
<Rule Id="CA1410" Action="Warning" />
<Rule Id="CA1415" Action="Warning" />
<Rule Id="CA1821" Action="Warning" />
<Rule Id="CA1900" Action="Warning" />
<Rule Id="CA1901" Action="Warning" />
<Rule Id="CA2002" Action="Warning" />
<Rule Id="CA2100" Action="Warning" />
<Rule Id="CA2101" Action="Warning" />
<Rule Id="CA2108" Action="Warning" />
<Rule Id="CA2111" Action="Warning" />
<Rule Id="CA2112" Action="Warning" />
<Rule Id="CA2114" Action="Warning" />
<Rule Id="CA2116" Action="Warning" />
<Rule Id="CA2117" Action="Warning" />
<Rule Id="CA2122" Action="Warning" />
<Rule Id="CA2123" Action="Warning" />
<Rule Id="CA2124" Action="Warning" />
<Rule Id="CA2126" Action="Warning" />
<Rule Id="CA2131" Action="Warning" />
<Rule Id="CA2132" Action="Warning" />
<Rule Id="CA2133" Action="Warning" />
<Rule Id="CA2134" Action="Warning" />
<Rule Id="CA2137" Action="Warning" />
<Rule Id="CA2138" Action="Warning" />
<Rule Id="CA2140" Action="Warning" />
<Rule Id="CA2141" Action="Warning" />
<Rule Id="CA2146" Action="Warning" />
<Rule Id="CA2147" Action="Warning" />
<Rule Id="CA2149" Action="Warning" />
<Rule Id="CA2200" Action="Warning" />
<Rule Id="CA2202" Action="Warning" />
<Rule Id="CA2207" Action="Warning" />
<Rule Id="CA2212" Action="Warning" />
<Rule Id="CA2213" Action="Warning" />
<Rule Id="CA2214" Action="Warning" />
<Rule Id="CA2216" Action="Warning" />
<Rule Id="CA2220" Action="Warning" />
<Rule Id="CA2229" Action="Warning" />
<Rule Id="CA2231" Action="Warning" />
<Rule Id="CA2232" Action="Warning" />
<Rule Id="CA2235" Action="Warning" />
<Rule Id="CA2236" Action="Warning" />
<Rule Id="CA2237" Action="Warning" />
<Rule Id="CA2238" Action="Warning" />
<Rule Id="CA2240" Action="Warning" />
<Rule Id="CA2241" Action="Warning" />
<Rule Id="CA2242" Action="Warning" />
</Rules>
<Rules AnalyzerId="RefactoringEssentials" RuleNamespace="RefactoringEssentials">
<Rule Id="RECS0145" Action="None" />
</Rules>
</RuleSet>
Oops, something went wrong.

1 comment on commit d57cd91

@pleb

This comment has been minimized.

Show comment
Hide comment
@pleb
Member

pleb commented on d57cd91 Jan 30, 2016

Please sign in to comment.