-
Notifications
You must be signed in to change notification settings - Fork 934
Test Unicode string. #1511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test Unicode string. #1511
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ for your own use before compile tests in VisualStudio. | |
Database=nhibernate; | ||
User ID=SYSDBA;Password=masterkey; | ||
MaxPoolSize=200; | ||
charset=utf8; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Default charset for FireBird is "None", theoretically meaning that it is the application business to encode/decode it, Firebird being supposed to stores and gives data back "as is", maybe in some binary sens. In our case, that goes wrong. I have not investigated why, I have just switched that to utf8 instead. This requires to recreate the database, which the TeamCity build does for Firebird. For local tests, adjust your configuration files accordingly and run the TestDatabaseSetup test for fixing this. (Of course this file here is just the default template, the actual fix for TeamCity is the similar change done in teamcity.build file.) |
||
</property> | ||
<property name="show_sql">false</property> | ||
<property name="dialect">NHibernate.Dialect.FirebirdDialect</property> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
using System; | ||
using System.Linq; | ||
using NUnit.Framework; | ||
|
||
namespace NHibernate.Test.TypesTest | ||
{ | ||
/// <summary> | ||
/// Summary description for StringTypeFixture. | ||
/// </summary> | ||
[TestFixture] | ||
public class StringTypeFixture : TypeFixtureBase | ||
{ | ||
|
@@ -14,6 +11,14 @@ protected override string TypeName | |
get { return "String"; } | ||
} | ||
|
||
protected override void OnTearDown() | ||
{ | ||
using (var s = OpenSession()) | ||
{ | ||
s.CreateQuery("delete from StringClass").ExecuteUpdate(); | ||
} | ||
} | ||
|
||
[Test] | ||
public void InsertNullValue() | ||
{ | ||
|
@@ -27,12 +32,27 @@ public void InsertNullValue() | |
|
||
using (ISession s = OpenSession()) | ||
{ | ||
StringClass b = (StringClass) s.CreateCriteria( | ||
typeof(StringClass)).UniqueResult(); | ||
Assert.IsNull(b.StringValue); | ||
s.Delete(b); | ||
StringClass b = (StringClass) s.CreateCriteria(typeof(StringClass)).UniqueResult(); | ||
Assert.That(b.StringValue, Is.Null); | ||
} | ||
} | ||
|
||
[Test] | ||
public void InsertUnicodeValue() | ||
{ | ||
const string unicode = "길동 최고 新闻 地图 ます プル éèêëîïôöõàâäåãçùûü бджзй αβ ខគឃ ضذخ"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is some characters taken from NHCH-43, then some European accentuated letters, some Cyrillic letters, two Greek ones, a bunch of Khmer ones (likely the script supported the latest on windows) and some Arabic ones (which is in my experience one of the worst to support due to right-to-left logic, but that is more a trouble for display than for storage; Khmer was easier to deal with even when not yet officially supported on Windows). |
||
using (var s = OpenSession()) | ||
{ | ||
var b = new StringClass { StringValue = unicode }; | ||
s.Save(b); | ||
s.Flush(); | ||
} | ||
|
||
using (var s = OpenSession()) | ||
{ | ||
var b = s.Query<StringClass>().Single(); | ||
Assert.That(b.StringValue, Is.EqualTo(unicode)); | ||
} | ||
} | ||
} | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TeamCity Nant build logic just does nothing of properties to adjust when they are lacking in this file, thus causing Oracle to not be properly set up for actually using Unicode with
DbType.String
type. On our TeamCity agent, its default charset is an ascii one, and so we must use the "N" prefixed char types for storing Unicode strings.