forked from dotnet/efcore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
React to (and use) aspnet/Microsoft.Data.Sqlite#192
- Loading branch information
Showing
5 changed files
with
86 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
test/EntityFramework.Sqlite.FunctionalTests/SqliteDatabaseCreatorTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using Microsoft.Data.Entity.Infrastructure; | ||
using Microsoft.Data.Entity.Storage; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Xunit; | ||
|
||
namespace Microsoft.Data.Entity.Sqlite.FunctionalTests | ||
{ | ||
public class SqliteDatabaseCreatorTest | ||
{ | ||
[Fact] | ||
public void Exists_returns_false_when_database_doesnt_exist() | ||
{ | ||
var creator = GetDatabaseCreator("Data Source=doesnt-exist.db"); | ||
|
||
Assert.False(creator.Exists()); | ||
} | ||
|
||
[Fact] | ||
public void Exists_returns_true_when_database_exists() | ||
{ | ||
using (var testStore = SqliteTestStore.CreateScratch()) | ||
{ | ||
var creator = GetDatabaseCreator(testStore.Connection.ConnectionString); | ||
|
||
Assert.True(creator.Exists()); | ||
} | ||
} | ||
|
||
private IRelationalDatabaseCreator GetDatabaseCreator(string connectionString) | ||
{ | ||
var services = new ServiceCollection(); | ||
services | ||
.AddEntityFramework() | ||
.AddSqlite(); | ||
|
||
var options = new DbContextOptionsBuilder(); | ||
options.UseSqlite(connectionString); | ||
|
||
return new DbContext(services.BuildServiceProvider(), options.Options) | ||
.GetService<IRelationalDatabaseCreator>(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters