Skip to content

Commit 62348a0

Browse files
committed
Code style cleanup.
1 parent 19eb0d2 commit 62348a0

File tree

3 files changed

+71
-74
lines changed

3 files changed

+71
-74
lines changed
Lines changed: 53 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,67 @@
1-
using System;
21
using System.Collections.Generic;
32
using System.Linq;
43
using NHibernate.Cfg.MappingSchema;
54
using NHibernate.Mapping.ByCode;
6-
using NHibernate.Mapping.ByCode.Conformist;
75
using NHibernate.Linq;
86
using NUnit.Framework;
9-
using SharpTestsEx;
107

118
namespace NHibernate.Test.Stateless.FetchingLazyCollections
129
{
13-
public class TreeFetchTests : TestCaseMappingByCode
14-
{
15-
protected override HbmMapping GetMappings()
16-
{
17-
var mapper = new ModelMapper();
18-
mapper.BeforeMapClass += (mi, t, cm) => cm.Id(im => im.Generator(Generators.HighLow));
19-
mapper.Class<TreeNode>(
20-
mc =>
21-
{
22-
mc.Id(x => x.Id);
23-
mc.Property(x => x.Content);
24-
mc.Set(x => x.Children, cam =>
25-
{
26-
cam.Key(km => km.Column("parentId"));
27-
cam.Cascade(Mapping.ByCode.Cascade.All);
28-
}, rel => rel.OneToMany());
29-
});
30-
var mappings = mapper.CompileMappingForAllExplicitlyAddedEntities();
31-
return mappings;
32-
}
10+
public class TreeFetchTests : TestCaseMappingByCode
11+
{
12+
protected override HbmMapping GetMappings()
13+
{
14+
var mapper = new ModelMapper();
15+
mapper.BeforeMapClass += (mi, t, cm) => cm.Id(im => im.Generator(Generators.HighLow));
16+
mapper.Class<TreeNode>(
17+
mc =>
18+
{
19+
mc.Id(x => x.Id);
20+
mc.Property(x => x.Content);
21+
mc.Set(x => x.Children, cam =>
22+
{
23+
cam.Key(km => km.Column("parentId"));
24+
cam.Cascade(Mapping.ByCode.Cascade.All);
25+
}, rel => rel.OneToMany());
26+
});
27+
var mappings = mapper.CompileMappingForAllExplicitlyAddedEntities();
28+
return mappings;
29+
}
3330

34-
[Test]
35-
public void FetchMultipleHierarchies()
36-
{
37-
using (ISession s = sessions.OpenSession())
38-
using (ITransaction tx = s.BeginTransaction())
39-
{
40-
var root = new TreeNode { Content = "Root" };
41-
var child1 = new TreeNode { Content = "Child1" };
42-
root.Children.Add(child1);
43-
root.Children.Add(new TreeNode { Content = "Child2" });
44-
child1.Children.Add(new TreeNode { Content = "Child1Child1" });
45-
child1.Children.Add(new TreeNode { Content = "Child1Child2" });
46-
s.Save(root);
47-
tx.Commit();
48-
}
31+
[Test]
32+
public void FetchMultipleHierarchies()
33+
{
34+
using (ISession s = sessions.OpenSession())
35+
using (ITransaction tx = s.BeginTransaction())
36+
{
37+
var root = new TreeNode {Content = "Root"};
38+
var child1 = new TreeNode {Content = "Child1"};
39+
root.Children.Add(child1);
40+
root.Children.Add(new TreeNode {Content = "Child2"});
41+
child1.Children.Add(new TreeNode {Content = "Child1Child1"});
42+
child1.Children.Add(new TreeNode {Content = "Child1Child2"});
43+
s.Save(root);
44+
tx.Commit();
45+
}
4946

50-
using (IStatelessSession s = sessions.OpenStatelessSession())
51-
using (ITransaction tx = s.BeginTransaction())
52-
{
53-
IList<TreeNode> rootNodes = s.Query<TreeNode>().Where(t => t.Content == "Root")
54-
.FetchMany(f => f.Children)
55-
.ThenFetchMany(f => f.Children).ToList();
56-
Assert.That(rootNodes.Count, Is.EqualTo(1));
57-
Assert.That(rootNodes.First().Children.Count, Is.EqualTo(2));
47+
using (IStatelessSession s = sessions.OpenStatelessSession())
48+
using (ITransaction tx = s.BeginTransaction())
49+
{
50+
IList<TreeNode> rootNodes = s.Query<TreeNode>().Where(t => t.Content == "Root")
51+
.FetchMany(f => f.Children)
52+
.ThenFetchMany(f => f.Children).ToList();
53+
Assert.That(rootNodes.Count, Is.EqualTo(1));
54+
Assert.That(rootNodes.First().Children.Count, Is.EqualTo(2));
5855

59-
tx.Commit();
60-
}
56+
tx.Commit();
57+
}
6158

62-
using (ISession s = sessions.OpenSession())
63-
using (ITransaction tx = s.BeginTransaction())
64-
{
65-
s.Delete("from TreeNode");
66-
tx.Commit();
67-
}
68-
}
69-
}
59+
using (ISession s = sessions.OpenSession())
60+
using (ITransaction tx = s.BeginTransaction())
61+
{
62+
s.Delete("from TreeNode");
63+
tx.Commit();
64+
}
65+
}
66+
}
7067
}

src/NHibernate.Test/Stateless/TreeNode.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33

44
namespace NHibernate.Test.Stateless
55
{
6-
public class TreeNode
7-
{
8-
private ISet<TreeNode> children = new HashSet<TreeNode>();
6+
public class TreeNode
7+
{
8+
private ISet<TreeNode> _children = new HashSet<TreeNode>();
99

10-
public virtual int Id { get; protected set; }
10+
public virtual int Id { get; protected set; }
1111

12-
public virtual string Content { get; set; }
12+
public virtual string Content { get; set; }
1313

14-
public virtual ISet<TreeNode> Children
15-
{
16-
get { return children; }
17-
protected set { children = value; }
18-
}
19-
}
14+
public virtual ISet<TreeNode> Children
15+
{
16+
get { return _children; }
17+
protected set { _children = value; }
18+
}
19+
}
2020
}

src/NHibernate/Impl/StatelessSessionImpl.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -316,13 +316,13 @@ public override bool IsEventSource
316316
public override object GetEntityUsingInterceptor(EntityKey key)
317317
{
318318
CheckAndUpdateSessionStatus();
319-
// while a pending Query we should use existing temporary entities so a join fetch does not create multiple instances
320-
// of the same parent item
321-
object obj;
322-
if (temporaryPersistenceContext.EntitiesByKey.TryGetValue(key, out obj))
323-
return obj;
324-
else
325-
return null;
319+
// while a pending Query we should use existing temporary entities so a join fetch does not create multiple instances
320+
// of the same parent item
321+
object obj;
322+
if (temporaryPersistenceContext.EntitiesByKey.TryGetValue(key, out obj))
323+
return obj;
324+
325+
return null;
326326
}
327327

328328
public override IPersistenceContext PersistenceContext

0 commit comments

Comments
 (0)