@@ -23,12 +23,6 @@ namespace MongoDB.Bson.Tests.Serialization.Conventions
2323 public class ElementNameConventionsTests
2424 {
2525
26- private class BookWithBsonElementAttribute
27- {
28- [ BsonElement ( "notId" ) ]
29- public ObjectId Id { get ; set ; } // should not be set to _id
30- }
31-
3226 [ Fact ]
3327 public void TestBsonElementAttributeOverridesNamedIdMemberConvention ( )
3428 {
@@ -40,14 +34,6 @@ public void TestBsonElementAttributeOverridesNamedIdMemberConvention()
4034 Assert . Equal ( "notId" , classMap . GetMemberMap ( x => x . Id ) . ElementName ) ;
4135 }
4236
43- private class BookWithBsonIdAttribute
44- {
45- public ObjectId id { get ; set ; }
46-
47- [ BsonId ]
48- public string Title { get ; set ; } // should be set to _id
49- }
50-
5137 [ Fact ]
5238 public void TestBsonIdAttributeOverridesNamedIdMemberConvention ( )
5339 {
@@ -61,15 +47,6 @@ public void TestBsonIdAttributeOverridesNamedIdMemberConvention()
6147 Assert . Equal ( "id" , classMap . GetMemberMap ( x => x . id ) . ElementName ) ;
6248 }
6349
64- private class BookWithBsonElementAndBsonId
65- {
66- [ BsonElement ( "notId" ) ]
67- public ObjectId Id { get ; set ; }
68-
69- [ BsonId ]
70- public string Title { get ; set ; } // should be set to _id
71- }
72-
7350 [ Fact ]
7451 public void TestBsonIdAttributeWinsWhenBsonElementSkipsIdProperty ( )
7552 {
@@ -81,12 +58,6 @@ public void TestBsonIdAttributeWinsWhenBsonElementSkipsIdProperty()
8158 Assert . Equal ( "notId" , classMap . GetMemberMap ( x => x . Id ) . ElementName ) ;
8259 }
8360
84- private class BookWithExplicitBsonElementId
85- {
86- [ BsonElement ( "_id" ) ]
87- public string Id { get ; set ; } // should not be set to _id
88- }
89-
9061 [ Fact ]
9162 public void TestBsonElementWithUnderscoreIdOnIdPropertyAlsoBecomesIdMember ( )
9263 {
@@ -99,12 +70,6 @@ public void TestBsonElementWithUnderscoreIdOnIdPropertyAlsoBecomesIdMember()
9970 Assert . Equal ( "_id" , classMap . GetMemberMap ( x => x . Id ) . ElementName ) ;
10071 }
10172
102- private class BookWithExplicitBsonElementIdButNoIdProperty
103- {
104- [ BsonElement ( "_id" ) ]
105- public string Title { get ; set ; } // should be set to _id
106- }
107-
10873 [ Fact ]
10974 public void TestBsonElementWithUnderscoreIdButNoIdPropertyDoesNotBecomeIdMember ( )
11075 {
@@ -116,13 +81,6 @@ public void TestBsonElementWithUnderscoreIdButNoIdPropertyDoesNotBecomeIdMember(
11681 Assert . Equal ( "_id" , classMap . GetMemberMap ( x => x . Title ) . ElementName ) ;
11782 }
11883
119- private class BookWithBsonElementAndFallthrough
120- {
121- [ BsonElement ( "notId" ) ]
122- public ObjectId Id { get ; set ; }
123- public ObjectId id { get ; set ; } // should be set to _id
124- }
125-
12684 [ Fact ]
12785 public void TestBsonElementOnIdFallsThroughToLowercaseId ( )
12886 {
@@ -135,14 +93,6 @@ public void TestBsonElementOnIdFallsThroughToLowercaseId()
13593 Assert . Equal ( "notId" , classMap . GetMemberMap ( x => x . Id ) . ElementName ) ;
13694 }
13795
138- private class TestClass
139- {
140- public string FirstName { get ; set ; }
141- public int Age { get ; set ; }
142- public string _DumbName { get ; set ; }
143- public string lowerCase { get ; set ; }
144- }
145-
14696 [ Fact ]
14797 public void TestMemberNameElementNameConvention ( )
14898 {
@@ -172,5 +122,55 @@ public void TestCamelCaseElementNameConvention()
172122 Assert . Equal ( "_DumbName" , classMap . GetMemberMap ( x => x . _DumbName ) . ElementName ) ;
173123 Assert . Equal ( "lowerCase" , classMap . GetMemberMap ( x => x . lowerCase ) . ElementName ) ;
174124 }
125+
126+ private class BookWithBsonElementAttribute
127+ {
128+ [ BsonElement ( "notId" ) ]
129+ public ObjectId Id { get ; set ; } // should not be set to _id
130+ }
131+
132+ private class BookWithBsonIdAttribute
133+ {
134+ public ObjectId id { get ; set ; }
135+
136+ [ BsonId ]
137+ public string Title { get ; set ; } // should be set to _id
138+ }
139+
140+ private class BookWithBsonElementAndBsonId
141+ {
142+ [ BsonElement ( "notId" ) ]
143+ public ObjectId Id { get ; set ; }
144+
145+ [ BsonId ]
146+ public string Title { get ; set ; } // should be set to _id
147+ }
148+
149+ private class BookWithExplicitBsonElementId
150+ {
151+ [ BsonElement ( "_id" ) ]
152+ public string Id { get ; set ; } // should not be set to _id
153+ }
154+
155+ private class BookWithExplicitBsonElementIdButNoIdProperty
156+ {
157+ [ BsonElement ( "_id" ) ]
158+ public string Title { get ; set ; } // should be set to _id
159+ }
160+
161+ private class BookWithBsonElementAndFallthrough
162+ {
163+ [ BsonElement ( "notId" ) ]
164+ public ObjectId Id { get ; set ; }
165+ public ObjectId id { get ; set ; } // should be set to _id
166+ }
167+
168+ private class TestClass
169+ {
170+ public string FirstName { get ; set ; }
171+ public int Age { get ; set ; }
172+ public string _DumbName { get ; set ; }
173+ public string lowerCase { get ; set ; }
174+ }
175175 }
176176}
0 commit comments