Using in memory store on mono
This commit is contained in:
parent
bd1e282e58
commit
888ed48249
|
|
@ -188,7 +188,14 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
||||||
{
|
{
|
||||||
services.AddEntityFramework().AddSqlServer();
|
services.AddEntityFramework().AddSqlServer();
|
||||||
var optionsBuilder = new DbContextOptionsBuilder();
|
var optionsBuilder = new DbContextOptionsBuilder();
|
||||||
optionsBuilder.UseSqlServer(database.ConnectionString);
|
if (!PlatformHelper.IsMono)
|
||||||
|
{
|
||||||
|
optionsBuilder.UseSqlServer(database.ConnectionString);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
optionsBuilder.UseInMemoryStore();
|
||||||
|
}
|
||||||
services.AddInstance<DbContextOptions>(optionsBuilder.Options);
|
services.AddInstance<DbContextOptions>(optionsBuilder.Options);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -309,7 +316,14 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
||||||
services.AddScoped<TContext>();
|
services.AddScoped<TContext>();
|
||||||
|
|
||||||
var optionsBuilder = new DbContextOptionsBuilder();
|
var optionsBuilder = new DbContextOptionsBuilder();
|
||||||
optionsBuilder.UseSqlServer(database.ConnectionString);
|
if (!PlatformHelper.IsMono)
|
||||||
|
{
|
||||||
|
optionsBuilder.UseSqlServer(database.ConnectionString);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
optionsBuilder.UseInMemoryStore();
|
||||||
|
}
|
||||||
services.AddInstance(optionsBuilder.Options);
|
services.AddInstance(optionsBuilder.Options);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNet.Diagnostics.Entity.FunctionalTests.Helpers
|
||||||
|
{
|
||||||
|
public class PlatformHelper
|
||||||
|
{
|
||||||
|
public static bool IsMono
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Type.GetType("Mono.Runtime") != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -4,8 +4,8 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using Microsoft.AspNet.Diagnostics.Entity.FunctionalTests.Helpers;
|
||||||
using Microsoft.Data.Entity;
|
using Microsoft.Data.Entity;
|
||||||
using Microsoft.Data.Entity.Infrastructure;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
||||||
{
|
{
|
||||||
|
|
@ -17,7 +17,6 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
||||||
{
|
{
|
||||||
var name = "Microsoft.AspNet.Diagnostics.Entity.FunctionalTests.Scratch_" + Interlocked.Increment(ref _scratchCount);
|
var name = "Microsoft.AspNet.Diagnostics.Entity.FunctionalTests.Scratch_" + Interlocked.Increment(ref _scratchCount);
|
||||||
var db = new SqlServerTestStore(name);
|
var db = new SqlServerTestStore(name);
|
||||||
db.EnsureDeleted();
|
|
||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -31,7 +30,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
||||||
InitialCatalog = name,
|
InitialCatalog = name,
|
||||||
IntegratedSecurity = true,
|
IntegratedSecurity = true,
|
||||||
ConnectTimeout = 30
|
ConnectTimeout = 30
|
||||||
}.ConnectionString; ;
|
}.ConnectionString;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ConnectionString
|
public string ConnectionString
|
||||||
|
|
@ -41,12 +40,15 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
||||||
|
|
||||||
private void EnsureDeleted()
|
private void EnsureDeleted()
|
||||||
{
|
{
|
||||||
var optionsBuilder = new DbContextOptionsBuilder();
|
if (!PlatformHelper.IsMono)
|
||||||
optionsBuilder.UseSqlServer(_connectionString);
|
|
||||||
|
|
||||||
using (var db = new DbContext(optionsBuilder.Options))
|
|
||||||
{
|
{
|
||||||
db.Database.EnsureDeleted();
|
var optionsBuilder = new DbContextOptionsBuilder();
|
||||||
|
optionsBuilder.UseSqlServer(_connectionString);
|
||||||
|
|
||||||
|
using (var db = new DbContext(optionsBuilder.Options))
|
||||||
|
{
|
||||||
|
db.Database.EnsureDeleted();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,5 +13,8 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<SchemaVersion>2.0</SchemaVersion>
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
|
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -13,5 +13,8 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<SchemaVersion>2.0</SchemaVersion>
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
|
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||||
</Project>
|
</Project>
|
||||||
Loading…
Reference in New Issue