Skip to content

Commit 7bdfc54

Browse files
hazzikoskarb
authored andcommitted
Cherry-pick "Merge remote-tracking branch 'remotes/Nicaog/NH-3132'"
1 parent 342b374 commit 7bdfc54

File tree

3 files changed

+97
-104
lines changed

3 files changed

+97
-104
lines changed

src/NHibernate.Test/NHSpecificTest/NH3132/Fixture.cs

Lines changed: 80 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -4,106 +4,99 @@
44

55
namespace NHibernate.Test.NHSpecificTest.NH3132
66
{
7-
[TestFixture]
8-
public class Fixture : TestCase
9-
{
10-
protected override string MappingsAssembly
11-
{
12-
get { return "NHibernate.Test"; }
13-
}
7+
[TestFixture]
8+
public class Fixture : TestCase
9+
{
10+
protected override string MappingsAssembly
11+
{
12+
get { return "NHibernate.Test"; }
13+
}
1414

15-
protected override IList Mappings
16-
{
17-
get
18-
{
19-
return new string[]
15+
protected override IList Mappings
16+
{
17+
get
18+
{
19+
return new string[]
2020
{
2121
"NHSpecificTest.NH3132.Mappings.hbm.xml"
2222
};
23-
}
24-
}
25-
26-
/// <summary>
27-
/// push some data into the database
28-
/// Really functions as a save test also
29-
/// </summary>
30-
protected override void OnSetUp()
31-
{
32-
base.OnSetUp();
23+
}
24+
}
3325

34-
using (var session = OpenSession())
35-
{
36-
using (var tran = session.BeginTransaction())
37-
{
38-
Product product = new Product();
39-
product.Name = "First";
40-
product.Lazy = "Lazy";
41-
42-
session.Save(product);
26+
/// <summary>
27+
/// push some data into the database
28+
/// Really functions as a save test also
29+
/// </summary>
30+
protected override void OnSetUp()
31+
{
32+
base.OnSetUp();
4333

44-
/* Inventory inventory = new Inventory();
45-
inventory.Id = product.Id;
46-
inventory.Quantity = 1;
34+
using (var session = OpenSession())
35+
{
36+
using (var tran = session.BeginTransaction())
37+
{
38+
Product product = new Product();
39+
product.Name = "First";
40+
product.Lazy = "Lazy";
41+
42+
session.Save(product);
4743

48-
session.Save(inventory);*/
44+
tran.Commit();
45+
}
46+
}
47+
}
4948

50-
tran.Commit();
51-
}
52-
}
53-
}
49+
protected override void OnTearDown()
50+
{
51+
base.OnTearDown();
5452

55-
protected override void OnTearDown()
56-
{
57-
base.OnTearDown();
53+
using (var session = OpenSession())
54+
{
55+
using (var tran = session.BeginTransaction())
56+
{
57+
session.Delete("from Product");
58+
tran.Commit();
59+
}
60+
}
61+
}
5862

59-
using (var session = OpenSession())
60-
{
61-
using (var tran = session.BeginTransaction())
62-
{
63-
session.Delete("from Product");
64-
tran.Commit();
65-
}
66-
}
63+
[Test]
64+
public void Query_returns_correct_name()
65+
{
66+
using (var session = OpenSession())
67+
{
68+
Product product = session.CreateCriteria(typeof (Product))
69+
.Add(Restrictions.Eq("Name", "First"))
70+
.UniqueResult<Product>();
6771

68-
}
72+
Assert.IsNotNull(product);
73+
Assert.AreEqual("First", product.Name);
74+
}
75+
}
6976

70-
[Test]
71-
public void Query_returns_correct_name()
72-
{
73-
using (var session = OpenSession())
74-
{
75-
Product product = session.CreateCriteria(typeof (Product))
76-
.Add(Restrictions.Eq("Name", "First"))
77-
.UniqueResult<Product>();
77+
[Test]
78+
public void Correct_value_gets_saved()
79+
{
80+
using (var session = OpenSession())
81+
{
82+
Product product = session.CreateCriteria(typeof(Product))
83+
.Add(Restrictions.Eq("Name", "First"))
84+
.UniqueResult<Product>();
7885

79-
Assert.IsNotNull(product);
80-
Assert.AreEqual("First", product.Name);
81-
}
82-
}
86+
Assert.IsNotNull(product);
87+
product.Name = "Changed";
8388

84-
[Test]
85-
public void Correct_value_gets_saved()
86-
{
87-
using (var session = OpenSession())
88-
{
89-
Product product = session.CreateCriteria(typeof(Product))
90-
.Add(Restrictions.Eq("Name", "First"))
91-
.UniqueResult<Product>();
89+
session.Flush();
90+
91+
session.Clear();
9292

93-
Assert.IsNotNull(product);
94-
product.Name = "Changed";
95-
96-
session.Flush();
97-
98-
session.Clear();
99-
100-
Product product1 = session.CreateCriteria(typeof(Product))
101-
.Add(Restrictions.Eq("Name", "Changed"))
102-
.UniqueResult<Product>();
103-
104-
Assert.IsNotNull(product1);
105-
Assert.AreEqual("Changed", product1.Name);
106-
}
107-
}
108-
}
93+
Product product1 = session.CreateCriteria(typeof(Product))
94+
.Add(Restrictions.Eq("Name", "Changed"))
95+
.UniqueResult<Product>();
96+
97+
Assert.IsNotNull(product1);
98+
Assert.AreEqual("Changed", product1.Name);
99+
}
100+
}
101+
}
109102
}
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
using System;
22

3-
namespace NHibernate.Test.NHSpecificTest.NH3132
4-
{
5-
public class Product
6-
{
7-
public virtual Guid Id { get; set; }
3+
namespace NHibernate.Test.NHSpecificTest.NH3132
4+
{
5+
public class Product
6+
{
7+
public virtual Guid Id { get; set; }
88

9-
private string _name;
10-
public virtual string Name
11-
{
12-
get { return _name; }
13-
set { _name = value; }
14-
}
9+
private string _name;
10+
public virtual string Name
11+
{
12+
get { return _name; }
13+
set { _name = value; }
14+
}
1515

16-
public virtual string Lazy { get; set; }
17-
}
18-
}
16+
public virtual string Lazy { get; set; }
17+
}
18+
}

src/NHibernate/Properties/FieldAccessor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public bool CanAccessThroughReflectionOptimizer
104104

105105
private static FieldInfo GetField(System.Type type, string fieldName, System.Type originalType)
106106
{
107-
if (type == null || type == typeof (object))
107+
if (type == null || type == typeof(object))
108108
{
109109
// the full inheritance chain has been walked and we could
110110
// not find the Field
@@ -306,13 +306,13 @@ public void Set(object target, object value)
306306
// all related to an ISet and IDictionary mixups.
307307
string msg =
308308
String.Format("The type {0} can not be assigned to a field of type {1}", value.GetType().ToString(),
309-
field.FieldType.ToString());
309+
field.FieldType.ToString());
310310
throw new PropertyAccessException(ae, msg, true, clazz, name);
311311
}
312312
else
313313
{
314314
throw new PropertyAccessException(ae, "ArgumentException while setting the field value by reflection", true, clazz,
315-
name);
315+
name);
316316
}
317317
}
318318
catch (Exception e)

0 commit comments

Comments
 (0)