@@ -67,7 +67,7 @@ public bool OneTimeSetup()
67
67
68
68
[ SkippableTheory ]
69
69
[ ClassData ( typeof ( TestCaseFactory ) ) ]
70
- public void RunTestDefinition ( IEnumerable < BsonDocument > data , BsonDocument definition , bool async )
70
+ public void RunTestDefinition ( BsonDocument definition , BsonDocument test , bool async )
71
71
{
72
72
BsonValue minServerVersion ;
73
73
if ( definition . TryGetValue ( "minServerVersion" , out minServerVersion ) )
@@ -87,9 +87,9 @@ public void RunTestDefinition(IEnumerable<BsonDocument> data, BsonDocument defin
87
87
. GetCollection < BsonDocument > ( DriverTestConfiguration . CollectionNamespace . CollectionName ) ;
88
88
89
89
database . DropCollection ( collection . CollectionNamespace . CollectionName ) ;
90
- collection . InsertMany ( data ) ;
90
+ collection . InsertMany ( definition [ " data" ] . AsBsonArray . Cast < BsonDocument > ( ) ) ;
91
91
92
- ExecuteOperation ( database , collection , ( BsonDocument ) definition [ "operation" ] , ( BsonDocument ) definition [ "outcome" ] , async) ;
92
+ ExecuteOperation ( database , collection , ( BsonDocument ) test [ "operation" ] , ( BsonDocument ) test [ "outcome" ] , async) ;
93
93
}
94
94
95
95
private void ExecuteOperation ( IMongoDatabase database , IMongoCollection < BsonDocument > collection , BsonDocument operation , BsonDocument outcome , bool async )
@@ -117,25 +117,23 @@ private class TestCaseFactory : IEnumerable<object[]>
117
117
public IEnumerator < object [ ] > GetEnumerator ( )
118
118
{
119
119
const string prefix = "MongoDB.Driver.Tests.Specifications.crud.tests." ;
120
- var testDocuments = typeof ( TestCaseFactory ) . GetTypeInfo ( ) . Assembly
120
+ var definitions = typeof ( TestCaseFactory ) . GetTypeInfo ( ) . Assembly
121
121
. GetManifestResourceNames ( )
122
122
. Where ( path => path . StartsWith ( prefix ) && path . EndsWith ( ".json" ) )
123
- . Select ( path => ReadDocument ( path ) ) ;
123
+ . Select ( path => ReadDefinition ( path ) ) ;
124
124
125
125
var testCases = new List < object [ ] > ( ) ;
126
- foreach ( var testDocument in testDocuments )
126
+ foreach ( var definition in definitions )
127
127
{
128
- var data = testDocument [ "data" ] . AsBsonArray . Cast < BsonDocument > ( ) . ToList ( ) ;
129
-
130
- foreach ( BsonDocument definition in testDocument [ "tests" ] . AsBsonArray )
128
+ foreach ( BsonDocument test in definition [ "tests" ] . AsBsonArray )
131
129
{
132
130
foreach ( var async in new [ ] { false , true } )
133
131
{
134
- //var testCase = new TestCaseData(data, definition , async);
132
+ //var testCase = new TestCaseData(definition, test , async);
135
133
//testCase.SetCategory("Specifications");
136
134
//testCase.SetCategory("crud");
137
- //testCase.SetName($"{definition ["description"]}({async})");
138
- var testCase = new object [ ] { data , definition , async } ;
135
+ //testCase.SetName($"{test ["description"]}({async})");
136
+ var testCase = new object [ ] { definition , test , async } ;
139
137
testCases . Add ( testCase ) ;
140
138
}
141
139
}
@@ -149,13 +147,15 @@ IEnumerator IEnumerable.GetEnumerator()
149
147
return GetEnumerator ( ) ;
150
148
}
151
149
152
- private static BsonDocument ReadDocument ( string path )
150
+ private static BsonDocument ReadDefinition ( string path )
153
151
{
154
152
using ( var definitionStream = typeof ( TestCaseFactory ) . GetTypeInfo ( ) . Assembly . GetManifestResourceStream ( path ) )
155
153
using ( var definitionStringReader = new StreamReader ( definitionStream ) )
156
154
{
157
155
var definitionString = definitionStringReader . ReadToEnd ( ) ;
158
- return BsonDocument . Parse ( definitionString ) ;
156
+ var definition = BsonDocument . Parse ( definitionString ) ;
157
+ definition . InsertAt ( 0 , new BsonElement ( "path" , path ) ) ;
158
+ return definition ;
159
159
}
160
160
}
161
161
}
0 commit comments