-
Notifications
You must be signed in to change notification settings - Fork 0
/
EfCoreQueryBug.cs
51 lines (41 loc) · 1.52 KB
/
EfCoreQueryBug.cs
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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AlbumViewerBusiness;
using Microsoft.EntityFrameworkCore;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace EFCoreQueryBug
{
[TestClass]
public class EfCoreQueryBug
{
[TestMethod]
public void EfCoreQueryWithSqLiteDataBug()
{
var Context = new AlbumViewerContext() {useSqLite = true};
IQueryable<Album> albums = Context.Albums
.Include(ctx => ctx.Tracks)
.Include(ctx => ctx.Artist)
.OrderBy(alb => alb.Artist);
var list = albums.ToList();
var listUninitialized = list.Where(a => a.Artist.Id == 0).ToList();
Assert.IsTrue(list.Count > 80, $"Total number of records should be greater than 80 but is {list.Count}");
Assert.IsTrue(listUninitialized.Count == 0,
$"There are {listUninitialized.Count} uninitialized Artist records");
}
[TestMethod]
public void ImportAlbumData()
{
File.Delete("AlbumViewerData.sqlite");
var Context = new AlbumViewerContext()
{
useSqLite = true,
ConnectionString = "server=.;database=AlbumViewer2;integrated security=true;MultipleActiveResultSets=true;App=AlbumViewer"
};
AlbumViewerDataImporter.EnsureAlbumData(Context, Path.GetFullPath("./albums.js"));
}
}
}