-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathCurrentThreadTest.cs
More file actions
51 lines (41 loc) · 1.62 KB
/
CurrentThreadTest.cs
File metadata and controls
51 lines (41 loc) · 1.62 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
using NUnit.Framework;
using Xtensive.Orm.Localization.Tests.Model;
namespace Xtensive.Orm.Localization.Tests
{
public class CurrentThreadTest : LocalizationBaseTest
{
[Test]
public void MainTest()
{
using (var session = Domain.OpenSession()) {
using (var ts = session.OpenTransaction()) {
var welcomePage = new Page(session);
// Editing localizable properties through CurrentThread.CurrentCulture
Thread.CurrentThread.CurrentCulture = EnglishCulture;
welcomePage.Title = EnglishTitle;
welcomePage.Content = EnglishContent;
// The same entity, the same properties, but another culture
Thread.CurrentThread.CurrentCulture = SpanishCulture;
welcomePage.Title = SpanishTitle;
welcomePage.Content = SpanishContent;
ts.Complete();
}
}
// Checking the presence of localizable & localization entities
using (var session = Domain.OpenSession()) {
using (var ts = session.OpenTransaction()) {
Assert.AreEqual(1, session.Query.All<Page>().Count());
Assert.AreEqual(2, session.Query.All<PageLocalization>().Count());
var page = session.Query.All<Page>().First();
Thread.CurrentThread.CurrentCulture = EnglishCulture;
Assert.AreEqual(EnglishTitle, page.Title);
Assert.AreEqual(EnglishContent, page.Content);
Thread.CurrentThread.CurrentCulture = SpanishCulture;
Assert.AreEqual(SpanishTitle, page.Title);
Assert.AreEqual(SpanishContent, page.Content);
ts.Complete();
}
}
}
}
}