|
| 1 | +/* Copyright 2021-present MongoDB Inc. |
| 2 | +* |
| 3 | +* Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +* you may not use this file except in compliance with the License. |
| 5 | +* You may obtain a copy of the License at |
| 6 | +* |
| 7 | +* http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +* |
| 9 | +* Unless required by applicable law or agreed to in writing, software |
| 10 | +* distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +* See the License for the specific language governing permissions and |
| 13 | +* limitations under the License. |
| 14 | +*/ |
| 15 | + |
| 16 | +using System.Collections.Generic; |
| 17 | +using MongoDB.Bson; |
| 18 | +using MongoDB.Bson.TestHelpers.JsonDrivenTests; |
| 19 | +using MongoDB.Driver.Tests.Specifications.unified_test_format; |
| 20 | +using Xunit; |
| 21 | + |
| 22 | +namespace MongoDB.Driver.Tests.Specifications.crud.Unified |
| 23 | +{ |
| 24 | + public sealed class ChangeStreamUnifiedTestRunner |
| 25 | + { |
| 26 | + [SkippableTheory] |
| 27 | + [ClassData(typeof(TestCaseFactory))] |
| 28 | + public void Run(JsonDrivenTestCase testCase) |
| 29 | + { |
| 30 | + using (var runner = new UnifiedTestFormatTestRunner()) |
| 31 | + { |
| 32 | + runner.Run(testCase); |
| 33 | + } |
| 34 | + } |
| 35 | + |
| 36 | + // nested types |
| 37 | + public class TestCaseFactory : JsonDrivenTestCaseFactory |
| 38 | + { |
| 39 | + // protected properties |
| 40 | + protected override string PathPrefix => "MongoDB.Driver.Tests.Specifications.change_streams.tests.unified."; |
| 41 | + |
| 42 | + // protected methods |
| 43 | + protected override IEnumerable<JsonDrivenTestCase> CreateTestCases(BsonDocument document) |
| 44 | + { |
| 45 | + foreach (var testCase in base.CreateTestCases(document)) |
| 46 | + { |
| 47 | + foreach (var async in new[] { false, true }) |
| 48 | + { |
| 49 | + var name = $"{testCase.Name}:async={async}"; |
| 50 | + var test = testCase.Test.DeepClone().AsBsonDocument.Add("async", async); |
| 51 | + yield return new JsonDrivenTestCase(name, testCase.Shared, test); |
| 52 | + } |
| 53 | + } |
| 54 | + } |
| 55 | + } |
| 56 | + } |
| 57 | +} |
0 commit comments