@@ -67,7 +67,7 @@ public bool OneTimeSetup()
6767
6868 [ SkippableTheory ]
6969 [ ClassData ( typeof ( TestCaseFactory ) ) ]
70- public void RunTestDefinition ( IEnumerable < BsonDocument > data , BsonDocument definition , bool async )
70+ public void RunTestDefinition ( BsonDocument definition , BsonDocument test , bool async )
7171 {
7272 BsonValue minServerVersion ;
7373 if ( definition . TryGetValue ( "minServerVersion" , out minServerVersion ) )
@@ -87,9 +87,9 @@ public void RunTestDefinition(IEnumerable<BsonDocument> data, BsonDocument defin
8787 . GetCollection < BsonDocument > ( DriverTestConfiguration . CollectionNamespace . CollectionName ) ;
8888
8989 database . DropCollection ( collection . CollectionNamespace . CollectionName ) ;
90- collection . InsertMany ( data ) ;
90+ collection . InsertMany ( definition [ " data" ] . AsBsonArray . Cast < BsonDocument > ( ) ) ;
9191
92- ExecuteOperation ( database , collection , ( BsonDocument ) definition [ "operation" ] , ( BsonDocument ) definition [ "outcome" ] , async) ;
92+ ExecuteOperation ( database , collection , ( BsonDocument ) test [ "operation" ] , ( BsonDocument ) test [ "outcome" ] , async) ;
9393 }
9494
9595 private void ExecuteOperation ( IMongoDatabase database , IMongoCollection < BsonDocument > collection , BsonDocument operation , BsonDocument outcome , bool async )
@@ -117,25 +117,23 @@ private class TestCaseFactory : IEnumerable<object[]>
117117 public IEnumerator < object [ ] > GetEnumerator ( )
118118 {
119119 const string prefix = "MongoDB.Driver.Tests.Specifications.crud.tests." ;
120- var testDocuments = typeof ( TestCaseFactory ) . GetTypeInfo ( ) . Assembly
120+ var definitions = typeof ( TestCaseFactory ) . GetTypeInfo ( ) . Assembly
121121 . GetManifestResourceNames ( )
122122 . Where ( path => path . StartsWith ( prefix ) && path . EndsWith ( ".json" ) )
123- . Select ( path => ReadDocument ( path ) ) ;
123+ . Select ( path => ReadDefinition ( path ) ) ;
124124
125125 var testCases = new List < object [ ] > ( ) ;
126- foreach ( var testDocument in testDocuments )
126+ foreach ( var definition in definitions )
127127 {
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 )
131129 {
132130 foreach ( var async in new [ ] { false , true } )
133131 {
134- //var testCase = new TestCaseData(data, definition , async);
132+ //var testCase = new TestCaseData(definition, test , async);
135133 //testCase.SetCategory("Specifications");
136134 //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 } ;
139137 testCases . Add ( testCase ) ;
140138 }
141139 }
@@ -149,13 +147,15 @@ IEnumerator IEnumerable.GetEnumerator()
149147 return GetEnumerator ( ) ;
150148 }
151149
152- private static BsonDocument ReadDocument ( string path )
150+ private static BsonDocument ReadDefinition ( string path )
153151 {
154152 using ( var definitionStream = typeof ( TestCaseFactory ) . GetTypeInfo ( ) . Assembly . GetManifestResourceStream ( path ) )
155153 using ( var definitionStringReader = new StreamReader ( definitionStream ) )
156154 {
157155 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 ;
159159 }
160160 }
161161 }
0 commit comments