Skip to content

Commit 578061b

Browse files
committed
Remove more use of non-generic collections from tests.
1 parent 88c3673 commit 578061b

File tree

21 files changed

+78
-107
lines changed

21 files changed

+78
-107
lines changed

src/NHibernate.DomainModel/Assignable.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
2-
using System.Collections;
3-
2+
using System.Collections.Generic;
3+
44
namespace NHibernate.DomainModel
55
{
66
/// <summary>
@@ -9,15 +9,15 @@ namespace NHibernate.DomainModel
99
public class Assignable
1010
{
1111
private string _id;
12-
private IList _categories;
12+
private IList<Category> _categories;
1313

1414
public string Id
1515
{
1616
get { return _id; }
1717
set { _id = value; }
1818
}
1919

20-
public IList Categories
20+
public IList<Category> Categories
2121
{
2222
get { return _categories; }
2323
set { _categories = value; }

src/NHibernate.DomainModel/NHSpecific/Team.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
2-
using System.Collections;
3-
2+
using System.Collections.Generic;
3+
44
namespace NHibernate.DomainModel.NHSpecific
55
{
66
/// <summary>
@@ -10,7 +10,7 @@ public class Team
1010
{
1111
private int _id;
1212
private string _name;
13-
private IList _players;
13+
private IList<Child> _players;
1414

1515
public Team()
1616
{
@@ -28,7 +28,7 @@ public string Name
2828
set { _name = value; }
2929
}
3030

31-
public IList Players
31+
public IList<Child> Players
3232
{
3333
get { return _players; }
3434
set { _players = value; }

src/NHibernate.DomainModel/Qux.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Collections;
32
using System.Collections.Generic;
43
using NHibernate.Classic;
54

@@ -18,7 +17,7 @@ public class Qux : ILifecycle
1817
private bool _stored;
1918
private string _stuff;
2019
private ISet<Fum> _fums;
21-
private IList _moreFums;
20+
private IList<Fum> _moreFums;
2221
private Qux _child;
2322
private long _childKey;
2423
private Holder _holder;
@@ -162,7 +161,7 @@ public virtual ISet<Fum> Fums
162161
/// <summary>
163162
/// Gets or sets the _moreFums
164163
/// </summary>
165-
public virtual IList MoreFums
164+
public virtual IList<Fum> MoreFums
166165
{
167166
get { return _moreFums; }
168167
set { _moreFums = value; }

src/NHibernate.Test/CollectionTest/A.cs

Lines changed: 3 additions & 3 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.CollectionTest
55
{
66
public class A
77
{
88
private int? _id;
99
private string _name;
10-
private IList _items;
10+
private IList<string> _items;
1111

1212
public A() { }
1313

@@ -23,7 +23,7 @@ public string Name
2323
set { _name = value; }
2424
}
2525

26-
public IList Items
26+
public IList<string> Items
2727
{
2828
get { return _items; }
2929
set { _items = value; }

src/NHibernate.Test/CollectionTest/IdBagFixture.cs

Lines changed: 2 additions & 2 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.CollectionTest
@@ -32,7 +32,7 @@ public void Simple()
3232
{
3333
A a = new A();
3434
a.Name = "first generic type";
35-
a.Items = new ArrayList();
35+
a.Items = new List<string>();
3636
a.Items.Add( "first string" );
3737
a.Items.Add( "second string" );
3838

src/NHibernate.Test/Events/Collections/AbstractCollectionEventFixture.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -886,11 +886,11 @@ protected void CheckResult(CollectionListeners listeners, CollectionListeners.IL
886886
IEntity ownerExpected, object collExpected, int index)
887887
{
888888
Assert.That(listeners.ListenersCalled[index], Is.SameAs(listenerExpected));
889-
Assert.That(((AbstractCollectionEvent) listeners.Events[index]).AffectedOwnerOrNull, Is.SameAs(ownerExpected));
890-
Assert.That(((AbstractCollectionEvent) listeners.Events[index]).AffectedOwnerIdOrNull, Is.EqualTo(ownerExpected.Id));
891-
Assert.That(((AbstractCollectionEvent) listeners.Events[index]).GetAffectedOwnerEntityName(),
889+
Assert.That(listeners.Events[index].AffectedOwnerOrNull, Is.SameAs(ownerExpected));
890+
Assert.That(listeners.Events[index].AffectedOwnerIdOrNull, Is.EqualTo(ownerExpected.Id));
891+
Assert.That(listeners.Events[index].GetAffectedOwnerEntityName(),
892892
Is.EqualTo(ownerExpected.GetType().FullName));
893-
Assert.That(((AbstractCollectionEvent) listeners.Events[index]).Collection, Is.SameAs(collExpected));
893+
Assert.That(listeners.Events[index].Collection, Is.SameAs(collExpected));
894894
}
895895

896896
protected void CheckNumberOfResults(CollectionListeners listeners, int nEventsExpected)

src/NHibernate.Test/Events/Collections/CollectionListeners.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace NHibernate.Test.Events.Collections
88
{
99
public class CollectionListeners
1010
{
11-
private readonly IList events = new ArrayList();
11+
private readonly IList<AbstractCollectionEvent> events = new List<AbstractCollectionEvent>();
1212

1313
private readonly InitializeCollectionListener initializeCollectionListener;
1414
private readonly List<IListener> listenersCalled = new List<IListener>();
@@ -51,7 +51,7 @@ public IList ListenersCalled
5151
get { return listenersCalled; }
5252
}
5353

54-
public IList Events
54+
public IList<AbstractCollectionEvent> Events
5555
{
5656
get { return events; }
5757
}

src/NHibernate.Test/Legacy/FumTest.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -438,10 +438,8 @@ public void CompositeIDCollections()
438438
s.Save(fum2);
439439
Qux q = new Qux();
440440
s.Save(q);
441-
IList list = new ArrayList();
442-
list.Add(fum1);
443441
q.Fums = new HashSet<Fum> {fum1, fum2};
444-
q.MoreFums = list;
442+
q.MoreFums = new List<Fum> {fum1};
445443
fum1.QuxArray = new Qux[] {q};
446444
s.Flush();
447445
s.Close();
@@ -469,13 +467,10 @@ public void DeleteOwner()
469467
s.Save(q);
470468
Fum f1 = new Fum(FumKey("f1"));
471469
Fum f2 = new Fum(FumKey("f2"));
472-
IList list = new ArrayList();
473-
list.Add(f1);
474-
list.Add(f2);
475470
f1.FumString = "f1";
476471
f2.FumString = "f2";
477472
q.Fums = new HashSet<Fum> {f1, f2};
478-
q.MoreFums = list;
473+
q.MoreFums = new List<Fum> {f1, f2};
479474
s.Save(f1);
480475
s.Save(f2);
481476
s.Flush();
@@ -491,7 +486,7 @@ public void DeleteOwner()
491486

492487
s = OpenSession();
493488
t = s.BeginTransaction();
494-
list = s.CreateQuery("from fum in class NHibernate.DomainModel.Fum where not fum.FumString='FRIEND'").List();
489+
var list = s.CreateQuery("from fum in class NHibernate.DomainModel.Fum where not fum.FumString='FRIEND'").List();
495490
Assert.AreEqual(2, list.Count, "deleted owner");
496491
s.Lock(list[0], LockMode.Upgrade);
497492
s.Lock(list[1], LockMode.Upgrade);

src/NHibernate.Test/Legacy/MasterDetailTest.cs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -491,10 +491,7 @@ public void MasterDetail()
491491
Assert.AreEqual(0, q.List().Count);
492492

493493
q = s.CreateFilter(master.Details, "where this.id in (:ids)");
494-
list = new ArrayList();
495-
list.Add(did);
496-
list.Add((long) -1);
497-
q.SetParameterList("ids", list);
494+
q.SetParameterList("ids", new[] {did, (long) -1});
498495

499496
Assert.AreEqual(1, q.List().Count);
500497
Assert.IsTrue(q.Enumerable().GetEnumerator().MoveNext());
@@ -537,12 +534,7 @@ public void MasterDetail()
537534
Assert.AreEqual(0, enumer.Current);
538535

539536
f = s.CreateFilter(master.Details, "select max(this.I) where this.I not in (:list)");
540-
IList coll = new ArrayList();
541-
coll.Add(-666);
542-
coll.Add(22);
543-
coll.Add(0);
544-
545-
f.SetParameterList("list", coll);
537+
f.SetParameterList("list", new List<int> {-666, 22, 0});
546538
enumer = f.Enumerable().GetEnumerator();
547539
Assert.IsTrue(enumer.MoveNext());
548540
Assert.AreEqual(12, enumer.Current);
@@ -830,9 +822,7 @@ public void MixNativeAssigned()
830822
c.Name = "NAME";
831823
Assignable assn = new Assignable();
832824
assn.Id = "i.d.";
833-
IList l = new ArrayList();
834-
l.Add(c);
835-
assn.Categories = l;
825+
assn.Categories = new List<Category> {c};
836826
c.Assignable = assn;
837827
s.Save(assn);
838828
s.Flush();
@@ -1199,7 +1189,7 @@ public void QueuedBagAdds()
11991189
ISession s = OpenSession();
12001190
Assignable a = new Assignable();
12011191
a.Id = "foo";
1202-
a.Categories = new ArrayList();
1192+
a.Categories = new List<Category>();
12031193
Category c = new Category();
12041194
c.Assignable = a;
12051195
a.Categories.Add(c);

src/NHibernate.Test/Legacy/SQLLoaderTest.cs

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
2-
using System.Collections;
2+
using System.Collections;
3+
using System.Collections.Generic;
34
using NHibernate.Dialect;
45
using NHibernate.DomainModel;
56
using NUnit.Framework;
@@ -147,10 +148,8 @@ public void FindBySQLAssociatedObject()
147148
Category c = new Category();
148149
c.Name = "NAME";
149150
Assignable assn = new Assignable();
150-
assn.Id = "i.d.";
151-
IList l = new ArrayList();
152-
l.Add(c);
153-
assn.Categories = l;
151+
assn.Id = "i.d.";
152+
assn.Categories = new List<Category> {c};
154153
c.Assignable = assn;
155154
s.Save(assn);
156155
s.Flush();
@@ -175,10 +174,8 @@ public void FindBySQLMultipleObject()
175174
Category c = new Category();
176175
c.Name = "NAME";
177176
Assignable assn = new Assignable();
178-
assn.Id = "i.d.";
179-
IList l = new ArrayList();
180-
l.Add(c);
181-
assn.Categories = l;
177+
assn.Id = "i.d.";
178+
assn.Categories = new List<Category> {c};
182179
c.Assignable = assn;
183180
s.Save(assn);
184181
s.Flush();
@@ -187,9 +184,7 @@ public void FindBySQLMultipleObject()
187184
c.Name = "NAME2";
188185
assn = new Assignable();
189186
assn.Id = "i.d.2";
190-
l = new ArrayList();
191-
l.Add(c);
192-
assn.Categories = l;
187+
assn.Categories = new List<Category> { c };
193188
c.Assignable = assn;
194189
s.Save(assn);
195190
s.Flush();
@@ -227,29 +222,23 @@ public void FindBySQLParameters()
227222
c.Name = "Good";
228223
Assignable assn = new Assignable();
229224
assn.Id = "i.d.";
230-
IList l = new ArrayList();
231-
l.Add(c);
232-
assn.Categories = l;
225+
assn.Categories = new List<Category> { c };
233226
c.Assignable = assn;
234227
s.Save(assn);
235228
s.Flush();
236229
c = new Category();
237230
c.Name = "Best";
238231
assn = new Assignable();
239232
assn.Id = "i.d.2";
240-
l = new ArrayList();
241-
l.Add(c);
242-
assn.Categories = l;
233+
assn.Categories = new List<Category> {c};
243234
c.Assignable = assn;
244235
s.Save(assn);
245236
s.Flush();
246237
c = new Category();
247238
c.Name = "Better";
248239
assn = new Assignable();
249240
assn.Id = "i.d.7";
250-
l = new ArrayList();
251-
l.Add(c);
252-
assn.Categories = l;
241+
assn.Categories = new List<Category> {c};
253242
c.Assignable = assn;
254243
s.Save(assn);
255244
s.Flush();
@@ -635,9 +624,7 @@ public void NamedSQLQuery()
635624
c.Name = "NAME";
636625
Assignable assn = new Assignable();
637626
assn.Id = "i.d.";
638-
IList l = new ArrayList();
639-
l.Add(c);
640-
assn.Categories = l;
627+
assn.Categories = new List<Category> {c};
641628
c.Assignable = assn;
642629
s.Save(assn);
643630
s.Flush();

0 commit comments

Comments
 (0)