-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathProjectionToCustomTypesTests.cs
54 lines (51 loc) · 1.75 KB
/
ProjectionToCustomTypesTests.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
52
53
54
// Copyright (C) 2020 Xtensive LLC.
// This code is distributed under MIT license terms.
// See the License.txt file in the project root for more information.
using NUnit.Framework;
using Xtensive.Orm.Localization.Tests.Model;
namespace Xtensive.Orm.Localization.Tests
{
[TestFixture]
public class ProjectionToCustomTypesTests : LocalizationBaseTest
{
protected override void PopulateData()
{
using (var session = Domain.OpenSession())
using (var ts = session.OpenTransaction()) {
// populating database
var m1 = new Country(session) {
Identifier = "HUN",
Name = "Magyarország"
};
var m2 = new Country(session) {
Identifier = "RUS",
Name = "Oroszország"
};
using (new LocalizationScope(EnglishCulture)) {
m2.Name = "Russia";
}
using (new LocalizationScope(SpanishCulture)) {
m2.Name = "Rusia";
}
ts.Complete();
}
}
[Test]
public void EntityHierarchyWithAbstractPropertyTest()
{
Thread.CurrentThread.CurrentCulture = EnglishCulture;
using (var session = Domain.OpenSession())
using (var ts = session.OpenTransaction()) {
var q = session.Query.All<Country>().OrderBy(e => e.Identifier).Select(e => new { e.Name });
var l = q.ToList();
// assertions
Assert.AreEqual(2, l.Count);
var propertyInfos = l.First().GetType().GetProperties();
Assert.AreEqual(propertyInfos.Length, 1);
Assert.AreEqual(propertyInfos.First().Name, nameof(Country.Name));
Assert.AreEqual(l.First().Name, "Magyarország");
Assert.AreEqual(l.Last().Name, "Russia");
}
}
}
}