Skip to content

Commit 8e046fe

Browse files
Test Unicode string.
1 parent d372ee3 commit 8e046fe

File tree

2 files changed

+59
-18
lines changed

2 files changed

+59
-18
lines changed

src/NHibernate.Test/Async/TypesTest/StringTypeFixture.cs

+30-9
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@
88
//------------------------------------------------------------------------------
99

1010

11-
using System;
11+
using System.Linq;
1212
using NUnit.Framework;
13+
using NHibernate.Linq;
1314

1415
namespace NHibernate.Test.TypesTest
1516
{
1617
using System.Threading.Tasks;
17-
/// <summary>
18-
/// Summary description for StringTypeFixture.
19-
/// </summary>
2018
[TestFixture]
2119
public class StringTypeFixtureAsync : TypeFixtureBase
2220
{
@@ -25,6 +23,14 @@ protected override string TypeName
2523
get { return "String"; }
2624
}
2725

26+
protected override void OnTearDown()
27+
{
28+
using (var s = OpenSession())
29+
{
30+
s.CreateQuery("delete from StringClass").ExecuteUpdate();
31+
}
32+
}
33+
2834
[Test]
2935
public async Task InsertNullValueAsync()
3036
{
@@ -38,12 +44,27 @@ public async Task InsertNullValueAsync()
3844

3945
using (ISession s = OpenSession())
4046
{
41-
StringClass b = (StringClass) await (s.CreateCriteria(
42-
typeof(StringClass)).UniqueResultAsync());
43-
Assert.IsNull(b.StringValue);
44-
await (s.DeleteAsync(b));
47+
StringClass b = (StringClass) await (s.CreateCriteria(typeof(StringClass)).UniqueResultAsync());
48+
Assert.That(b.StringValue, Is.Null);
49+
}
50+
}
51+
52+
[Test]
53+
public async Task InsertUnicodeValueAsync()
54+
{
55+
const string unicode = "길동 최고 新闻 地图 ます プル éèêëîïôöõàâäåãçùûü бджзй αβ ខគឃ ضذخ";
56+
using (var s = OpenSession())
57+
{
58+
var b = new StringClass { StringValue = unicode };
59+
await (s.SaveAsync(b));
4560
await (s.FlushAsync());
4661
}
62+
63+
using (var s = OpenSession())
64+
{
65+
var b = await (s.Query<StringClass>().SingleAsync());
66+
Assert.That(b.StringValue, Is.EqualTo(unicode));
67+
}
4768
}
4869
}
49-
}
70+
}
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
using System;
1+
using System.Linq;
22
using NUnit.Framework;
33

44
namespace NHibernate.Test.TypesTest
55
{
6-
/// <summary>
7-
/// Summary description for StringTypeFixture.
8-
/// </summary>
96
[TestFixture]
107
public class StringTypeFixture : TypeFixtureBase
118
{
@@ -14,6 +11,14 @@ protected override string TypeName
1411
get { return "String"; }
1512
}
1613

14+
protected override void OnTearDown()
15+
{
16+
using (var s = OpenSession())
17+
{
18+
s.CreateQuery("delete from StringClass").ExecuteUpdate();
19+
}
20+
}
21+
1722
[Test]
1823
public void InsertNullValue()
1924
{
@@ -27,12 +32,27 @@ public void InsertNullValue()
2732

2833
using (ISession s = OpenSession())
2934
{
30-
StringClass b = (StringClass) s.CreateCriteria(
31-
typeof(StringClass)).UniqueResult();
32-
Assert.IsNull(b.StringValue);
33-
s.Delete(b);
35+
StringClass b = (StringClass) s.CreateCriteria(typeof(StringClass)).UniqueResult();
36+
Assert.That(b.StringValue, Is.Null);
37+
}
38+
}
39+
40+
[Test]
41+
public void InsertUnicodeValue()
42+
{
43+
const string unicode = "길동 최고 新闻 地图 ます プル éèêëîïôöõàâäåãçùûü бджзй αβ ខគឃ ضذخ";
44+
using (var s = OpenSession())
45+
{
46+
var b = new StringClass { StringValue = unicode };
47+
s.Save(b);
3448
s.Flush();
3549
}
50+
51+
using (var s = OpenSession())
52+
{
53+
var b = s.Query<StringClass>().Single();
54+
Assert.That(b.StringValue, Is.EqualTo(unicode));
55+
}
3656
}
3757
}
38-
}
58+
}

0 commit comments

Comments
 (0)