Skip to content

Commit 2bce8b9

Browse files
committed
BasicLoader: Fix warning regarding fetching multiple bags to also apply for generic bags.
MultipleCollectionFetchTest: Port to use generic collections.
1 parent a3857ad commit 2bce8b9

File tree

6 files changed

+24
-27
lines changed

6 files changed

+24
-27
lines changed

src/NHibernate.Test/MultipleCollectionFetchTest/AbstractMultipleCollectionFetchFixture.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
22
using System.Collections;
3-
3+
using System.Collections.Generic;
44
using NUnit.Framework;
55

66
namespace NHibernate.Test.MultipleCollectionFetchTest
@@ -12,9 +12,9 @@ protected override string MappingsAssembly
1212
get { return "NHibernate.Test"; }
1313
}
1414

15-
protected abstract void AddToCollection(ICollection collection, Person person);
15+
protected abstract void AddToCollection(ICollection<Person> collection, Person person);
1616

17-
protected abstract ICollection CreateCollection();
17+
protected abstract ICollection<Person> CreateCollection();
1818

1919
protected override void OnTearDown()
2020
{

src/NHibernate.Test/MultipleCollectionFetchTest/MultipleBagFetchFixture.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
22
using System.Collections;
3-
3+
using System.Collections.Generic;
44
using NUnit.Framework;
55

66
namespace NHibernate.Test.MultipleCollectionFetchTest
@@ -13,14 +13,14 @@ protected override IList Mappings
1313
get { return new string[] {"MultipleCollectionFetchTest.PersonBag.hbm.xml"}; }
1414
}
1515

16-
protected override void AddToCollection(ICollection collection, Person person)
16+
protected override void AddToCollection(ICollection<Person> collection, Person person)
1717
{
18-
((ArrayList) collection).Add(person);
18+
((List<Person>) collection).Add(person);
1919
}
2020

21-
protected override ICollection CreateCollection()
21+
protected override ICollection<Person> CreateCollection()
2222
{
23-
return new ArrayList();
23+
return new List<Person>();
2424
}
2525

2626
protected override void RunLinearJoinFetchTest(Person parent)
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
22
using System.Collections;
3-
3+
using System.Collections.Generic;
44
using NUnit.Framework;
55

66
namespace NHibernate.Test.MultipleCollectionFetchTest
@@ -13,14 +13,14 @@ protected override IList Mappings
1313
get { return new string[] { "MultipleCollectionFetchTest.PersonList.hbm.xml" }; }
1414
}
1515

16-
protected override void AddToCollection(ICollection collection, Person person)
16+
protected override void AddToCollection(ICollection<Person> persons, Person person)
1717
{
18-
((ArrayList) collection).Add(person);
18+
((List<Person>) persons).Add(person);
1919
}
2020

21-
protected override ICollection CreateCollection()
21+
protected override ICollection<Person> CreateCollection()
2222
{
23-
return new ArrayList();
23+
return new List<Person>();
2424
}
2525
}
2626
}
Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
11
using System;
22
using System.Collections;
3-
using System.Net.NetworkInformation;
3+
using System.Collections.Generic;
44
using NUnit.Framework;
55

66
namespace NHibernate.Test.MultipleCollectionFetchTest
77
{
88
[TestFixture]
9-
[Ignore("Support for non-generic sets removed. To test generic set instead, need to duplicate or port the sister test fixtures too.")]
109
public class MultipleSetFetchFixture : AbstractMultipleCollectionFetchFixture
1110
{
1211
protected override IList Mappings
1312
{
1413
get { return new string[] {"MultipleCollectionFetchTest.PersonSet.hbm.xml"}; }
1514
}
1615

17-
protected override void AddToCollection(ICollection collection, Person person)
16+
protected override void AddToCollection(ICollection<Person> persons, Person person)
1817
{
19-
//((ISet) collection).Add(person);
20-
throw new NotImplementedException();
18+
((ISet<Person>) persons).Add(person);
2119
}
2220

23-
protected override ICollection CreateCollection()
21+
protected override ICollection<Person> CreateCollection()
2422
{
25-
throw new NotImplementedException();
26-
//return new HashSet();
23+
return new HashSet<Person>();
2724
}
2825
}
2926
}

src/NHibernate.Test/MultipleCollectionFetchTest/Person.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
using System;
2-
using System.Collections;
2+
using System.Collections.Generic;
33

44
namespace NHibernate.Test.MultipleCollectionFetchTest
55
{
66
public class Person
77
{
88
private int id;
9-
private ICollection children;
10-
private ICollection friends;
9+
private ICollection<Person> children;
10+
private ICollection<Person> friends;
1111
private Person parent;
1212

1313
public virtual int Id
@@ -16,13 +16,13 @@ public virtual int Id
1616
set { id = value; }
1717
}
1818

19-
public virtual ICollection Children
19+
public virtual ICollection<Person> Children
2020
{
2121
get { return children; }
2222
set { children = value; }
2323
}
2424

25-
public virtual ICollection Friends
25+
public virtual ICollection<Person> Friends
2626
{
2727
get { return friends; }
2828
set { friends = value; }

src/NHibernate/Loader/BasicLoader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ protected override void PostInstantiate()
6868

6969
private static bool IsBag(ICollectionPersister collectionPersister)
7070
{
71-
return collectionPersister.CollectionType.GetType().IsAssignableFrom(typeof (BagType));
71+
return collectionPersister.CollectionType is BagType;
7272
}
7373

7474
/// <summary>

0 commit comments

Comments
 (0)