Skip to content

Commit c801226

Browse files
author
Mike Doerfler
committed
added an older test case back in.
SVN: trunk@517
1 parent 2fa697d commit c801226

File tree

1 file changed

+15
-30
lines changed

1 file changed

+15
-30
lines changed

src/NHibernate.Test/SimpleTest.cs

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public void SetUp()
2222
ExportSchema( new string[] { "Simple.hbm.xml"} );
2323
}
2424

25+
[Test]
2526
public void TestCRUD()
2627
{
2728
long key = 10;
@@ -107,56 +108,40 @@ public void TestCRUD()
107108
}
108109

109110

110-
private void OldTestCase()
111+
[Test]
112+
public void SetPropertiesOnQuery()
111113
{
112114
DateTime now = DateTime.Now;
113115

114116
ISession s = sessions.OpenSession();
115117
ITransaction t = s.BeginTransaction();
116118

117119
// create a new
120+
long key = 10;
118121
Simple simple = new Simple();
119122
simple.Name = "Simple 1";
120123
simple.Address = "Street 12";
121124
simple.Date = now;
122125
simple.Count = 99;
123126

124-
s.Save(simple, 10);
127+
s.Save(simple, key);
125128

126129
t.Commit();
127-
s.Close();
128-
129130

130-
// BUG: It looks like the problem is coming here because we now have the sample Entity loaded
131-
// twice in the entries field for this Session. I don't understand why that would happen
132-
// because a Dictionary should not allow a key to be in there twice...
131+
t = s.BeginTransaction();
132+
133133
IQuery q = s.CreateQuery("from s in class Simple where s.Name=:Name and s.Count=:Count");
134134
q.SetProperties(simple);
135135

136136
Simple loadedSimple = (Simple)q.List()[0];
137-
// Check if save failed
138-
Assertion.AssertEquals("Save failed", 99, simple.Count);
139-
Assertion.AssertEquals("Save failed", "Simple 1", simple.Name);
140-
Assertion.AssertEquals("Save failed", "Street 12", simple.Address);
141-
Assertion.AssertEquals("Save failed", now.ToString(), simple.Date.ToString());
142-
// Check if load failed
143-
Assertion.AssertNotNull("Unable to load object", loadedSimple);
144-
Assertion.AssertEquals("Load failed", simple.Count, loadedSimple.Count);
145-
Assertion.AssertEquals("Load failed", simple.Name, loadedSimple.Name);
146-
Assertion.AssertEquals("Load failed", simple.Address, loadedSimple.Address);
147-
Assertion.AssertEquals("Load failed", simple.Date.ToString(), loadedSimple.Date.ToString());
148-
149-
// The INSERT, UPDATE amd SELECT are performed due to some hacks,
150-
// see Impl\SessionImpl.cs class AdoHack
151-
// Btw: when something goes wrong, the transaction remains opened ;-)
152-
153-
// When you set a breakpoint at this line, you'll see the record in the database
154-
((Transaction.Transaction)t).AdoTransaction.Commit();
155-
156-
//s.Delete(simple);
157-
//
158-
// note: this line fails!!!!
159-
//
137+
Assert.AreEqual(key, loadedSimple.Key);
138+
Assert.AreEqual(99, loadedSimple.Count);
139+
Assert.AreEqual("Simple 1", loadedSimple.Name);
140+
Assert.AreEqual("Street 12", loadedSimple.Address);
141+
Assert.AreEqual(now.ToString(), loadedSimple.Date.ToString());
142+
143+
s.Delete(simple);
144+
160145
t.Commit();
161146
s.Close();
162147

0 commit comments

Comments
 (0)