Skip to content

Commit

Permalink
Merge pull request #54 from kendaleiv/localdb-v13
Browse files Browse the repository at this point in the history
Use LocalDB v13.0 and System.Data.SqlLocalDb
  • Loading branch information
khalidabuhakmeh authored Apr 19, 2018
2 parents 7a6d701 + e3e1e5d commit 2eb2f95
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
3 changes: 0 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ image: Visual Studio 2017
cache:
- packages -> **\packages.config

before_build:
- ps: sqllocaldb c "v12.0" 12.0 -s

build_script:
- ./build.cmd /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"

Expand Down
7 changes: 3 additions & 4 deletions tests/Filter.Tests/Filter.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,12 @@
<HintPath>..\..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="RimDev.Automation.Sql, Version=0.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\RimDev.Automation.Sql.0.2.0\lib\net45\RimDev.Automation.Sql.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Data.SqlLocalDb, Version=1.15.0.0, Culture=neutral, PublicKeyToken=9a192a7522c9e1a0, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Data.SqlLocalDb.1.15.0\lib\net40\System.Data.SqlLocalDb.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
Expand Down
30 changes: 20 additions & 10 deletions tests/Filter.Tests/Generic/Integration/DatabaseFixture.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
using System;
using System.Threading;
using RimDev.Automation.Sql;
using RimDev.Filter.Tests.Extensions;
using System.Data.Common;
using System.Data.SqlLocalDb;

namespace RimDev.Filter.Tests.Generic.Integration
{
public sealed class DatabaseFixture : IDisposable
public class DatabaseFixture : IDisposable
{
private readonly Lazy<LocalDb> lazyDatabase;
private readonly Lazy<TemporarySqlLocalDbInstance> lazyInstance;

public DatabaseFixture()
{
lazyDatabase = new Lazy<LocalDb>(
() => new LocalDb(version: "v12.0"), LazyThreadSafetyMode.ExecutionAndPublication);
lazyInstance = new Lazy<TemporarySqlLocalDbInstance>(
() => TemporarySqlLocalDbInstance.Create(true));
}

public string ConnectionString => lazyDatabase.Value.ConnectionString;

public DbConnectionStringBuilder CreateConnectionStringBuilder()
{
var instance = lazyInstance.Value;

var builder = lazyInstance.Value.CreateConnectionStringBuilder();
builder.SetInitialCatalogName(Guid.NewGuid().ToString("N"));

return builder;
}

public string ConnectionString => CreateConnectionStringBuilder().ConnectionString;

public void Dispose()
{
lazyDatabase.Dispose();
if (lazyInstance.IsValueCreated)
lazyInstance.Value.Dispose();
}
}
}
2 changes: 1 addition & 1 deletion tests/Filter.Tests/packages.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="6.1.3" targetFramework="net45" />
<package id="RimDev.Automation.Sql" version="0.2.0" targetFramework="net45" />
<package id="System.Data.SqlLocalDb" version="1.15.0" targetFramework="net45" />
<package id="xunit" version="2.0.0" targetFramework="net45" />
<package id="xunit.abstractions" version="2.0.0" targetFramework="net45" />
<package id="xunit.assert" version="2.0.0" targetFramework="net45" />
Expand Down

0 comments on commit 2eb2f95

Please sign in to comment.