From 888ed4824941c4175211fe5ccc5f9eafb14f4b91 Mon Sep 17 00:00:00 2001 From: Praburaj Date: Mon, 6 Apr 2015 11:06:27 -0700 Subject: [PATCH] Using in memory store on mono --- .../DatabaseErrorPageMiddlewareTest.cs | 18 ++++++++++++++++-- .../Helpers/PlatformHelper.cs | 18 ++++++++++++++++++ .../SqlServerTestStore.cs | 18 ++++++++++-------- ...osoft.AspNet.Diagnostics.Entity.Tests.xproj | 3 +++ .../Microsoft.AspNet.Diagnostics.Tests.xproj | 3 +++ 5 files changed, 50 insertions(+), 10 deletions(-) create mode 100644 test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/Helpers/PlatformHelper.cs diff --git a/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/DatabaseErrorPageMiddlewareTest.cs b/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/DatabaseErrorPageMiddlewareTest.cs index 07531a2e9c..d1de7bbecb 100644 --- a/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/DatabaseErrorPageMiddlewareTest.cs +++ b/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/DatabaseErrorPageMiddlewareTest.cs @@ -188,7 +188,14 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests { services.AddEntityFramework().AddSqlServer(); var optionsBuilder = new DbContextOptionsBuilder(); - optionsBuilder.UseSqlServer(database.ConnectionString); + if (!PlatformHelper.IsMono) + { + optionsBuilder.UseSqlServer(database.ConnectionString); + } + else + { + optionsBuilder.UseInMemoryStore(); + } services.AddInstance(optionsBuilder.Options); }); @@ -309,7 +316,14 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests services.AddScoped(); var optionsBuilder = new DbContextOptionsBuilder(); - optionsBuilder.UseSqlServer(database.ConnectionString); + if (!PlatformHelper.IsMono) + { + optionsBuilder.UseSqlServer(database.ConnectionString); + } + else + { + optionsBuilder.UseInMemoryStore(); + } services.AddInstance(optionsBuilder.Options); }); } diff --git a/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/Helpers/PlatformHelper.cs b/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/Helpers/PlatformHelper.cs new file mode 100644 index 0000000000..79bc412bd7 --- /dev/null +++ b/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/Helpers/PlatformHelper.cs @@ -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; + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/SqlServerTestStore.cs b/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/SqlServerTestStore.cs index bda76c1c4a..20c13812c1 100644 --- a/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/SqlServerTestStore.cs +++ b/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/SqlServerTestStore.cs @@ -4,8 +4,8 @@ using System; using System.Data.SqlClient; using System.Threading; +using Microsoft.AspNet.Diagnostics.Entity.FunctionalTests.Helpers; using Microsoft.Data.Entity; -using Microsoft.Data.Entity.Infrastructure; 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 db = new SqlServerTestStore(name); - db.EnsureDeleted(); return db; } @@ -31,7 +30,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests InitialCatalog = name, IntegratedSecurity = true, ConnectTimeout = 30 - }.ConnectionString; ; + }.ConnectionString; } public string ConnectionString @@ -41,12 +40,15 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests private void EnsureDeleted() { - var optionsBuilder = new DbContextOptionsBuilder(); - optionsBuilder.UseSqlServer(_connectionString); - - using (var db = new DbContext(optionsBuilder.Options)) + if (!PlatformHelper.IsMono) { - db.Database.EnsureDeleted(); + var optionsBuilder = new DbContextOptionsBuilder(); + optionsBuilder.UseSqlServer(_connectionString); + + using (var db = new DbContext(optionsBuilder.Options)) + { + db.Database.EnsureDeleted(); + } } } diff --git a/test/Microsoft.AspNet.Diagnostics.Entity.Tests/Microsoft.AspNet.Diagnostics.Entity.Tests.xproj b/test/Microsoft.AspNet.Diagnostics.Entity.Tests/Microsoft.AspNet.Diagnostics.Entity.Tests.xproj index abd9dc3af9..25a1b9f9dd 100644 --- a/test/Microsoft.AspNet.Diagnostics.Entity.Tests/Microsoft.AspNet.Diagnostics.Entity.Tests.xproj +++ b/test/Microsoft.AspNet.Diagnostics.Entity.Tests/Microsoft.AspNet.Diagnostics.Entity.Tests.xproj @@ -13,5 +13,8 @@ 2.0 + + + \ No newline at end of file diff --git a/test/Microsoft.AspNet.Diagnostics.Tests/Microsoft.AspNet.Diagnostics.Tests.xproj b/test/Microsoft.AspNet.Diagnostics.Tests/Microsoft.AspNet.Diagnostics.Tests.xproj index 9a73bd16d7..84f389affd 100644 --- a/test/Microsoft.AspNet.Diagnostics.Tests/Microsoft.AspNet.Diagnostics.Tests.xproj +++ b/test/Microsoft.AspNet.Diagnostics.Tests/Microsoft.AspNet.Diagnostics.Tests.xproj @@ -13,5 +13,8 @@ 2.0 + + + \ No newline at end of file