Skip to content

Commit b4e8d5b

Browse files
committed
- Rebase + PR comments
1 parent c27455f commit b4e8d5b

17 files changed

+213
-592
lines changed

evergreen/evergreen.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,7 @@ tasks:
11241124
FRAMEWORK: net10.0
11251125
- func: run-unit-tests
11261126

1127-
- name: unit-tests-net100-v14
1127+
- name: unit-tests-net100-csharp14
11281128
commands:
11291129
- func: configure-framework
11301130
vars:
@@ -2401,7 +2401,7 @@ buildvariants:
24012401
- name: unit-tests-netstandard21
24022402
- name: unit-tests-net60
24032403
- name: unit-tests-net100
2404-
- name: unit-tests-net100-v14
2404+
- name: unit-tests-net100-csharp14
24052405

24062406
- name: unit-tests-ubuntu
24072407
display_name: Unit Tests on Ubuntu
@@ -2412,7 +2412,7 @@ buildvariants:
24122412
- name: unit-tests-netstandard21
24132413
- name: unit-tests-net60
24142414
- name: unit-tests-net100
2415-
- name: unit-tests-net100-v14
2415+
- name: unit-tests-net100-csharp14
24162416

24172417
- name: unit-tests-macos
24182418
display_name: Unit Tests on MacOs
@@ -2423,7 +2423,7 @@ buildvariants:
24232423
- name: unit-tests-netstandard21
24242424
- name: unit-tests-net60
24252425
- name: unit-tests-net100
2426-
- name: unit-tests-net100-v14
2426+
- name: unit-tests-net100-csharp14
24272427

24282428
- name: unit-tests-macos-arm
24292429
display_name: Unit Tests on MacOs Arm
@@ -2433,7 +2433,7 @@ buildvariants:
24332433
tasks:
24342434
- name: unit-tests-net60
24352435
- name: unit-tests-net100
2436-
- name: unit-tests-net100-v14
2436+
- name: unit-tests-net100-csharp14
24372437

24382438
- matrix_name: stable-api-tests
24392439
matrix_spec: { version: ["5.0", "6.0", "7.0", "8.0", "rapid", "latest"], topology: ["standalone", "sharded-cluster"], auth: "auth", ssl: "nossl", os: "windows-64" }

evergreen/execute-tests.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ set -o errexit # Exit the script with error if any of the commands fail
1010
FRAMEWORK=${FRAMEWORK:-}
1111
TEST_CATEGORY=${TEST_CATEGORY:-Integration}
1212
TEST_PROJECT_PATH=${TEST_PROJECT_PATH:-./tests/**/[!AtlasConnectivity]*.Tests.csproj}
13+
CONFIGURATION=${CONFIGURATION:-'Release'}
1314

1415
if [ "$FRAMEWORK" = "netstandard2.1" ]; then
1516
FRAMEWORK="netcoreapp3.1"
@@ -31,5 +32,5 @@ if [[ -n "${FRAMEWORK}" ]]; then
3132
fi
3233

3334
for file in $TEST_PROJECT_PATH; do
34-
dotnet test "${file}" -c Release --no-build ${FILTER_PARAMETER} ${FRAMEWORK_PARAMETER} --results-directory ./build/test-results --logger "junit;verbosity=detailed;LogFileName=TEST-{assembly}.xml;FailureBodyFormat=Verbose" --logger "console;verbosity=detailed"
35+
dotnet test "${file}" -c ${CONFIGURATION} --no-build ${FILTER_PARAMETER} ${FRAMEWORK_PARAMETER} --results-directory ./build/test-results --logger "junit;verbosity=detailed;LogFileName=TEST-{assembly}.xml;FailureBodyFormat=Verbose" --logger "console;verbosity=detailed"
3536
done

evergreen/run-unit-tests.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ set -o errexit # Exit the script with error if any of the commands fail
44
FRAMEWORK=${FRAMEWORK:-net6.0}
55
CONFIGURATION=${CONFIGURATION:-'Release'}
66

7-
./evergreen/compile-sources.sh
8-
TEST_CATEGORY="!Integration" ./evergreen/execute-tests.sh
7+
CONFIGURATION=${CONFIGURATION} ./evergreen/compile-sources.sh
8+
CONFIGURATION=${CONFIGURATION} TEST_CATEGORY="!Integration" ./evergreen/execute-tests.sh

tests/BuildProps/Tests.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</PropertyGroup>
2222

2323
<PropertyGroup>
24-
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
24+
<TargetFrameworks>netcoreapp3.1;net6.0;net10.0</TargetFrameworks>
2525
<TargetFrameworks Condition="'$(IsWindows)'=='true'">$(TargetFrameworks);net472</TargetFrameworks>
2626
<IsPackable>false</IsPackable>
2727
<SignAssembly>true</SignAssembly>

tests/MongoDB.Bson.TestHelpers/Reflector.cs

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
/* Copyright 2018-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-
*/
1+
/* Copyright 2010-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+
*/
1515

1616
using System;
1717
using System.Collections.Generic;
@@ -40,13 +40,19 @@ public static object GetStaticFieldValue(Type type, string name, BindingFlags fl
4040
return fieldInfo.GetValue(null);
4141
}
4242

43+
public static TFieldType GetStaticFieldValue<TObjectType, TFieldType>(string name, BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Static)
44+
{
45+
var fieldInfo = GetDeclaredOrInheritedField(typeof(TObjectType), name, flags);
46+
return (TFieldType)fieldInfo.GetValue(null);
47+
}
48+
4349
public static object Invoke(object obj, string name, BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Instance)
4450
{
4551
try
4652
{
47-
var methodInfo = obj.GetType().GetMethods(flags)
48-
.Where(m => m.Name == name && m.GetParameters().Length == 0)
49-
.Single();
53+
var methodInfo = obj.GetType()
54+
.GetMethods(flags)
55+
.Single(m => m.Name == name && m.GetParameters().Length == 0);
5056
return methodInfo.Invoke(obj, new object[] { });
5157
}
5258
catch (TargetInvocationException exception)
@@ -58,9 +64,9 @@ public static object Invoke(object obj, string name, BindingFlags flags = Bindin
5864
public static object Invoke<T1>(object obj, string name, T1 arg1)
5965
{
6066
var parameterTypes = new[] { typeof(T1) };
61-
var methodInfo = obj.GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Instance)
62-
.Where(m => m.Name == name && m.GetParameters().Select(p => p.ParameterType).SequenceEqual(parameterTypes))
63-
.Single();
67+
var methodInfo = obj.GetType()
68+
.GetMethods(BindingFlags.NonPublic | BindingFlags.Instance)
69+
.Single(m => m.Name == name && m.GetParameters().Select(p => p.ParameterType).SequenceEqual(parameterTypes));
6470
try
6571
{
6672
return methodInfo.Invoke(obj, new object[] { arg1 });

tests/MongoDB.Bson.Tests/IO/BsonChunkPoolTests.cs

Lines changed: 4 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
using System.Threading.Tasks;
2222
using FluentAssertions;
2323
using MongoDB.Bson.IO;
24+
using MongoDB.Bson.TestHelpers;
2425
using MongoDB.TestHelpers.XunitExtensions;
2526
using Xunit;
2627

@@ -46,10 +47,9 @@ public void constructor_should_initialize_subject()
4647

4748
var subject = new BsonChunkPool(maxChunkCount, chunkSize);
4849

49-
var reflector = new Reflector(subject);
5050
subject.MaxChunkCount.Should().Be(maxChunkCount);
5151
subject.ChunkSize.Should().Be(chunkSize);
52-
reflector._disposed.Should().BeFalse();
52+
Reflector.GetFieldValue(subject, "_disposed").Should().Be(false);
5353
}
5454

5555
[Theory]
@@ -122,8 +122,7 @@ public void Dispose_should_dispose_subject()
122122

123123
subject.Dispose();
124124

125-
var reflector = new Reflector(subject);
126-
reflector._disposed.Should().BeTrue();
125+
Reflector.GetFieldValue(subject, "_disposed").Should().Be(true);
127126
}
128127

129128
[Theory]
@@ -175,26 +174,6 @@ public void MaxChunkCount_get_should_return_expected_result()
175174

176175
result.Should().Be(1);
177176
}
178-
179-
// nested types
180-
private class Reflector
181-
{
182-
private readonly BsonChunkPool _instance;
183-
184-
public Reflector(BsonChunkPool instance)
185-
{
186-
_instance = instance;
187-
}
188-
189-
public bool _disposed
190-
{
191-
get
192-
{
193-
var @field = typeof(BsonChunkPool).GetField("_disposed", BindingFlags.NonPublic | BindingFlags.Instance);
194-
return (bool)@field.GetValue(_instance);
195-
}
196-
}
197-
}
198177
}
199178

200179
public class BsonChunkPool_DisposableChunkTests
@@ -242,8 +221,7 @@ public void Dispose_should_dispose_subject()
242221

243222
subject.Dispose();
244223

245-
var reflector = new Reflector(subject);
246-
reflector._disposed.Should().BeTrue();
224+
Reflector.GetFieldValue(subject, "_disposed").Should().Be(true);
247225
}
248226

249227
[Fact]
@@ -316,25 +294,5 @@ public void Fork_should_throw_when_subject_is_disposed()
316294

317295
action.ShouldThrow<ObjectDisposedException>().And.ObjectName.Should().Be("DisposableChunk");
318296
}
319-
320-
// nested types
321-
private class Reflector
322-
{
323-
private readonly IBsonChunk _instance;
324-
325-
public Reflector(IBsonChunk instance)
326-
{
327-
_instance = instance;
328-
}
329-
330-
public bool _disposed
331-
{
332-
get
333-
{
334-
var @field = _instance.GetType().GetField("_disposed", BindingFlags.NonPublic | BindingFlags.Instance);
335-
return (bool)@field.GetValue(_instance);
336-
}
337-
}
338-
}
339297
}
340298
}

0 commit comments

Comments
 (0)