-
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathEfSnippetTests.cs
More file actions
61 lines (50 loc) · 1.36 KB
/
EfSnippetTests.cs
File metadata and controls
61 lines (50 loc) · 1.36 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#region EfClassicSnippetTests
[TestFixture]
public class EfSnippetTests
{
static SqlInstance<MyDbContext> sqlInstance;
static EfSnippetTests() =>
sqlInstance = new(
connection => new(connection),
storage: Storage.FromSuffix<MyDbContext>("ClassicEfSnippetTests"));
[Test]
public async Task TheTest()
{
#region EfClassicBuildDatabase
using var database = await sqlInstance.Build();
#endregion
#region EfClassicBuildContext
using (var data = database.NewDbContext())
{
#endregion
var entity = new TheEntity
{
Property = "prop"
};
data.TestEntities.Add(entity);
await data.SaveChangesAsync();
}
using (var data = database.NewDbContext())
{
AreEqual(1, data.TestEntities.Count());
}
}
[Test]
public async Task TheTestWithDbName()
{
using var database = await sqlInstance.Build("TheTestWithDbName");
var entity = new TheEntity
{
Property = "prop"
};
await database.AddData(entity);
AreEqual(1, database.Context.TestEntities.Count());
}
#endregion
[OneTimeTearDown]
public void Cleanup()
{
sqlInstance.Cleanup();
sqlInstance.Dispose();
}
}