Skip to content

Commit f44f84b

Browse files
committed
Port more tests to avoid use of non-generic collections.
1 parent 1c500e1 commit f44f84b

File tree

16 files changed

+37
-87
lines changed

16 files changed

+37
-87
lines changed

src/NHibernate.DomainModel/Single.cs

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

44
namespace NHibernate.DomainModel
55
{
@@ -13,7 +13,7 @@ public class Single
1313
private string _prop;
1414
private string _string;
1515
//<bag>
16-
private IList _several = new ArrayList();
16+
private IList<Several> _several = new List<Several>();
1717

1818
public string Id
1919
{
@@ -33,7 +33,7 @@ public string String
3333
set { _string = value; }
3434
}
3535

36-
public IList Several
36+
public IList<Several> Several
3737
{
3838
get { return _several; }
3939
set { _several = value; }

src/NHibernate.Test/ExpressionTest/SubQueries/Classes.cs

Lines changed: 3 additions & 4 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

54
namespace NHibernate.Test.ExpressionTest.SubQueries
@@ -104,7 +103,7 @@ public class Post
104103
private int post_id;
105104
private Blog _blog;
106105
private string post_title;
107-
private IList _comments;
106+
private IList<Comment> _comments;
108107
private ISet<Category> categories = new HashSet<Category>();
109108

110109
public ISet<Category> Categories
@@ -113,7 +112,7 @@ public ISet<Category> Categories
113112
set { categories = value; }
114113
}
115114

116-
public virtual IList Comments
115+
public virtual IList<Comment> Comments
117116
{
118117
get { return _comments; }
119118
set { _comments = value; }
@@ -140,7 +139,7 @@ public virtual Blog Blog
140139

141140
public Post()
142141
{
143-
_comments = new ArrayList();
142+
_comments = new List<Comment>();
144143
}
145144

146145
public Post(string title)

src/NHibernate.Test/Interceptor/StatefulInterceptor.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
using System.Collections;
2+
using System.Collections.Generic;
23
using NHibernate.Type;
34

45
namespace NHibernate.Test.Interceptor
56
{
67
public class StatefulInterceptor : EmptyInterceptor
78
{
89
private ISession session;
9-
private readonly IList list = new ArrayList();
10+
private readonly IList<Log> list = new List<Log>();
1011

1112
public override bool OnSave(object entity, object id, object[] state, string[] propertyNames, IType[] types)
1213
{
@@ -17,19 +18,21 @@ public override bool OnSave(object entity, object id, object[] state, string[] p
1718
return false;
1819
}
1920

20-
public override bool OnFlushDirty(object entity, object id, object[] currentState, object[] previousState, string[] propertyNames, IType[] types)
21+
public override bool OnFlushDirty(object entity, object id, object[] currentState, object[] previousState,
22+
string[] propertyNames, IType[] types)
2123
{
22-
if ( !(entity is Log) ) {
23-
list.Add( new Log( "update", (string) id, entity.GetType().FullName ) );
24-
}
25-
return false;
24+
if (!(entity is Log))
25+
{
26+
list.Add(new Log("update", (string) id, entity.GetType().FullName));
27+
}
28+
return false;
2629
}
2730

2831
public override void PostFlush(ICollection entities)
2932
{
3033
if (list.Count > 0)
3134
{
32-
foreach (object iter in list)
35+
foreach (Log iter in list)
3336
{
3437
session.Persist(iter);
3538
}

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,12 @@ public void Can_discriminate_subclass_on_list_with_lazy_loading_when_used_get()
8585
var personWithSivasKangals = session.Get<PersonWithSivasKangals>(4);
8686

8787
Assert.That(personWithAnimals.AnimalsGeneric,Has.Count.EqualTo(4));
88-
Assert.That(personWithAnimals.AnimalsNonGeneric, Has.Count.EqualTo(4));
8988

9089
Assert.That(personWithCats.CatsGeneric, Has.Count.EqualTo(1));
91-
Assert.That(personWithCats.CatsNonGeneric, Has.Count.EqualTo(1));
9290

9391
Assert.That(personWithDogs.DogsGeneric, Has.Count.EqualTo(2));
94-
Assert.That(personWithDogs.DogsNonGeneric, Has.Count.EqualTo(2));
9592

9693
Assert.That(personWithSivasKangals.SivasKangalsGeneric, Has.Count.EqualTo(1));
97-
Assert.That(personWithSivasKangals.SivasKangalsNonGeneric, Has.Count.EqualTo(1));
9894
}
9995
}
10096
}

src/NHibernate.Test/NHSpecificTest/NH1391/Fixture2.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,9 @@ public void Can_discriminate_subclass_on_list_with_lazy_loading_when_used_and_pe
4848
using (var tran = session.BeginTransaction())
4949
{
5050
var personWithAnimals = session.Get<PersonWithAllTypes>(1);
51-
Assert.That(personWithAnimals.AnimalsNonGeneric, Has.Count.EqualTo(4));
5251
Assert.That(personWithAnimals.AnimalsGeneric, Has.Count.EqualTo(4));
53-
Assert.That(personWithAnimals.CatsNonGeneric, Has.Count.EqualTo(1));
5452
Assert.That(personWithAnimals.CatsGeneric,Has.Count.EqualTo(1));
55-
Assert.That(personWithAnimals.DogsNonGeneric, Has.Count.EqualTo(2));
5653
Assert.That(personWithAnimals.DogsGeneric,Has.Count.EqualTo(2));
57-
Assert.That(personWithAnimals.SivasKangalsNonGeneric, Has.Count.EqualTo(1));
5854
Assert.That(personWithAnimals.SivasKangalsGeneric, Has.Count.EqualTo(1));
5955
}
6056
}

src/NHibernate.Test/NHSpecificTest/NH1391/Mappings.hbm.xml

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@
2525

2626
<discriminator column="PersonType" type="int"/>
2727
<property name="Name"/>
28-
<bag name="AnimalsNonGeneric" lazy="true" inverse="true" cascade="save-update">
29-
<key column="OwnerId" />
30-
<one-to-many class="Animal"/>
31-
</bag>
3228
<bag name="AnimalsGeneric" lazy="true" inverse="true" cascade="save-update">
3329
<key column="OwnerId" />
3430
<one-to-many class="Animal"/>
@@ -41,56 +37,33 @@
4137
<key column="OwnerId" />
4238
<one-to-many class="Cat"/>
4339
</bag>
44-
<bag name="CatsNonGeneric" lazy="true" inverse="true" cascade="save-update">
45-
<key column="OwnerId" />
46-
<one-to-many class="Cat"/>
47-
</bag>
4840
</subclass>
4941
<subclass name="PersonWithDogs" discriminator-value="3">
5042
<bag name="DogsGeneric" lazy="true" inverse="true" cascade="save-update">
5143
<key column="OwnerId" />
5244
<one-to-many class="Dog"/>
5345
</bag>
54-
<bag name="DogsNonGeneric" lazy="true" inverse="true">
55-
<key column="OwnerId" />
56-
<one-to-many class="Dog"/>
57-
</bag>
5846
</subclass>
5947
<subclass name="PersonWithSivasKangals" discriminator-value="4">
6048
<bag name="SivasKangalsGeneric" lazy="true" inverse="true" cascade="save-update">
6149
<key column="OwnerId" />
6250
<one-to-many class="SivasKangal"/>
6351
</bag>
64-
<bag name="SivasKangalsNonGeneric" lazy="true" inverse="true">
65-
<key column="OwnerId" />
66-
<one-to-many class="SivasKangal"/>
67-
</bag>
52+
6853
</subclass>
6954
<subclass name="PersonWithAllTypes" discriminator-value="5">
7055
<bag name="DogsGeneric" lazy="true" inverse="true">
7156
<key column="OwnerId" />
7257
<one-to-many class="Dog"/>
7358
</bag>
74-
<bag name="DogsNonGeneric" lazy="true" inverse="true">
75-
<key column="OwnerId" />
76-
<one-to-many class="Dog"/>
77-
</bag>
7859
<bag name="CatsGeneric" lazy="true" inverse="true">
7960
<key column="OwnerId" />
8061
<one-to-many class="Cat"/>
8162
</bag>
82-
<bag name="CatsNonGeneric" lazy="true" inverse="true">
83-
<key column="OwnerId" />
84-
<one-to-many class="Cat"/>
85-
</bag>
8663
<bag name="SivasKangalsGeneric" lazy="true" inverse="true">
8764
<key column="OwnerId" />
8865
<one-to-many class="SivasKangal"/>
8966
</bag>
90-
<bag name="SivasKangalsNonGeneric" lazy="true" inverse="true">
91-
<key column="OwnerId" />
92-
<one-to-many class="SivasKangal"/>
93-
</bag>
9467
</subclass>
9568
</class>
9669
</hibernate-mapping>
Lines changed: 0 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 System.Text;
54

@@ -10,11 +9,9 @@ public class Person
109
public Person()
1110
{
1211
this.AnimalsGeneric = new List<Animal>();
13-
this.AnimalsNonGeneric = new ArrayList();
1412
}
1513
public virtual int Id { get; set; }
1614
public virtual string Name { get; set; }
1715
public virtual IList<Animal> AnimalsGeneric { get; set; }
18-
public virtual IList AnimalsNonGeneric { get; set; }
1916
}
2017
}

src/NHibernate.Test/NHSpecificTest/NH1391/PersonWithAllTypes.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ namespace NHibernate.Test.NHSpecificTest.NH1391
66
{
77
public class PersonWithAllTypes:Person
88
{
9-
public virtual IList<Dog> DogsNonGeneric { get; set; }
10-
public virtual IList<SivasKangal> SivasKangalsNonGeneric { get; set; }
11-
public virtual IList<Cat> CatsNonGeneric { get; set; }
12-
13-
149
public virtual IList<Dog> DogsGeneric { get; set; }
1510
public virtual IList<SivasKangal> SivasKangalsGeneric { get; set; }
1611
public virtual IList<Cat> CatsGeneric { get; set; }
Lines changed: 0 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 System.Text;
54

@@ -10,9 +9,7 @@ public class PersonWithCats : Person
109
public PersonWithCats()
1110
{
1211
this.CatsGeneric = new List<Cat>();
13-
this.CatsNonGeneric = new ArrayList();
1412
}
15-
public virtual IList CatsNonGeneric { get; set; }
1613
public virtual IList<Cat> CatsGeneric { get; set; }
1714
}
1815
}
Lines changed: 0 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 System.Text;
54

@@ -10,9 +9,7 @@ public class PersonWithDogs : Person
109
public PersonWithDogs()
1110
{
1211
this.DogsGeneric = new List<Dog>();
13-
this.DogsNonGeneric = new ArrayList();
1412
}
15-
public virtual IList DogsNonGeneric { get; set; }
1613
public virtual IList<Dog> DogsGeneric { get; set; }
1714
}
1815
}

0 commit comments

Comments
 (0)