-
Notifications
You must be signed in to change notification settings - Fork 90
Expand file tree
/
Copy pathSqlLiteBaseRepository.cs
More file actions
38 lines (34 loc) · 1.01 KB
/
SqlLiteBaseRepository.cs
File metadata and controls
38 lines (34 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System.Data.SQLite;
using System.IO;
using Utilities;
namespace EddiDataProviderService
{
public class SqLiteBaseRepository
{
protected static bool unitTesting
{
get => _unitTesting;
set
{
if ( _unitTesting != value )
{
ResetTestDatabase();
_unitTesting = value;
}
}
}
private static bool _unitTesting;
private static void ResetTestDatabase ()
{
var testDatabase = new FileInfo( Constants.DATA_DIR + @"\EDDI_TEST.sqlite" );
if ( testDatabase.Exists ) { testDatabase.Delete(); }
}
protected static string DbFile => unitTesting
? Constants.DATA_DIR + @"\EDDI_TEST.sqlite"
: Constants.DATA_DIR + @"\EDDI.sqlite";
public static SQLiteConnection SimpleDbConnection()
{
return new SQLiteConnection("Data Source=" + DbFile);
}
}
}