Skip to content

Commit 10a0d59

Browse files
Merge pull request nhibernate#629 from fredericDelaporte/NH-4014
NH-4014 - upgrading SQLite test binaries to v1.0.105.1
2 parents fee1f14 + 97f0a64 commit 10a0d59

File tree

4 files changed

+49
-34
lines changed

4 files changed

+49
-34
lines changed
387 KB
Binary file not shown.
377 KB
Binary file not shown.
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="false">
33

4-
<class
4+
<class
55
name="NHibernate.DomainModel.NHSpecific.ClassWithNullColumns, NHibernate.DomainModel"
6-
table="usertype"
7-
>
8-
6+
table="usertype">
7+
98
<id name="Id" column="id">
109
<generator class="assigned" />
1110
</id>
12-
11+
1312
<property
1413
name="FirstInt32"
1514
type="NHibernate.DomainModel.NHSpecific.NullInt32UserType, NHibernate.DomainModel"
1615
column="f_int32"
1716
not-null="false"
1817
/>
19-
18+
2019
<property
2120
name="SecondInt32"
2221
type="NHibernate.DomainModel.NHSpecific.NullInt32UserType, NHibernate.DomainModel"
2322
column="s_int32"
2423
not-null="false"
2524
/>
26-
25+
2726
</class>
2827
</hibernate-mapping>
2928

src/NHibernate.Test/NHSpecificTest/UserTypeFixture.cs

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.Collections;
3-
using System.Data.Common;
43
using NHibernate.Connection;
54
using NHibernate.DomainModel.NHSpecific;
65
using NUnit.Framework;
@@ -14,8 +13,15 @@ namespace NHibernate.Test.NHSpecificTest
1413
public class UserTypeFixture : TestCase
1514
{
1615
protected override IList Mappings
16+
=> new [] {"NHSpecific.ClassWithNullColumns.hbm.xml"};
17+
18+
protected override void OnTearDown()
1719
{
18-
get { return new string[] {"NHSpecific.ClassWithNullColumns.hbm.xml"}; }
20+
using (var s = OpenSession())
21+
{
22+
s.Delete("from ClassWithNullColumns");
23+
s.Flush();
24+
}
1925
}
2026

2127
/// <summary>
@@ -25,40 +31,50 @@ protected override IList Mappings
2531
[Test]
2632
public void InsertNull()
2733
{
28-
using (ISession s = OpenSession())
34+
using (var s = OpenSession())
2935
{
30-
ClassWithNullColumns userTypeClass = new ClassWithNullColumns();
31-
userTypeClass.Id = 5;
32-
userTypeClass.FirstInt32 = 4;
33-
userTypeClass.SecondInt32 = 0; // with the user type should set value to null
36+
var userTypeClass = new ClassWithNullColumns
37+
{
38+
Id = 5,
39+
FirstInt32 = 4,
40+
SecondInt32 = 0
41+
};
42+
// with the user type should set 0 value to null
3443

3544
s.Save(userTypeClass);
3645
s.Flush();
3746
}
3847

3948
// manually read from the db
40-
IConnectionProvider provider = ConnectionProviderFactory.NewConnectionProvider(cfg.Properties);
41-
var conn = provider.GetConnection();
42-
var cmd = conn.CreateCommand();
43-
cmd.Connection = conn;
44-
cmd.CommandText = "select * from usertype";
45-
46-
var reader = cmd.ExecuteReader();
47-
48-
while (reader.Read())
49+
using (var provider = ConnectionProviderFactory.NewConnectionProvider(cfg.Properties))
4950
{
50-
Assert.AreEqual(5, reader[0]);
51-
Assert.AreEqual(4, reader[1]);
52-
Assert.AreEqual(DBNull.Value, reader[2]);
53-
break;
54-
}
55-
56-
conn.Close();
51+
var conn = provider.GetConnection();
52+
try
53+
{
54+
using (var cmd = conn.CreateCommand())
55+
{
56+
cmd.Connection = conn;
57+
cmd.CommandText = "select * from usertype";
5758

58-
using (ISession s = OpenSession())
59-
{
60-
s.Delete("from ClassWithNullColumns");
61-
s.Flush();
59+
using (var reader = cmd.ExecuteReader())
60+
{
61+
var idOrdinal = reader.GetOrdinal("id");
62+
var firstOrdinal = reader.GetOrdinal("f_int32");
63+
var secondOrdinal = reader.GetOrdinal("s_int32");
64+
while (reader.Read())
65+
{
66+
Assert.AreEqual(5, reader[idOrdinal]);
67+
Assert.AreEqual(4, reader[firstOrdinal]);
68+
Assert.AreEqual(DBNull.Value, reader[secondOrdinal]);
69+
break;
70+
}
71+
}
72+
}
73+
}
74+
finally
75+
{
76+
provider.CloseConnection(conn);
77+
}
6278
}
6379
}
6480
}

0 commit comments

Comments
 (0)