Skip to content

Commit b344289

Browse files
authored
Fix FluentAssertions after major update (#1442)
2 parents 72a1207 + 135f9a7 commit b344289

8 files changed

+25
-25
lines changed

Directory.Packages.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
4040
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.1" />
4141
<PackageVersion Include="xunit" Version="2.9.3" />
42-
<PackageVersion Include="FluentAssertions" Version="7.1.0" />
42+
<PackageVersion Include="FluentAssertions" Version="8.0.1" />
4343
<PackageVersion Include="Verify.Xunit" Version="28.0.0" />
4444
<PackageVersion Include="Verify.SourceGenerators" Version="2.4.3" />
4545
<PackageVersion Include="NSubstitute" Version="5.3.0" />

test/Dap.Tests/FoundationTests.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -249,15 +249,15 @@ public void HandlersShouldHaveExpectedExtensionMethodsBasedOnDirection(
249249
extensionClass.GetMethods(BindingFlags.Static | BindingFlags.Public)
250250
.Where(z => z.Name == onMethodName)
251251
.Where(z => item.matcher(z.GetParameters()[0]))
252-
.Should().HaveCountGreaterOrEqualTo(1, $"{descriptor.HandlerType.FullName} is missing a registry implementation for {item.type}");
252+
.Should().HaveCountGreaterThanOrEqualTo(1, $"{descriptor.HandlerType.FullName} is missing a registry implementation for {item.type}");
253253
}
254254

255255
foreach (var item in expectedRequestHandlers)
256256
{
257257
extensionClass.GetMethods(BindingFlags.Static | BindingFlags.Public)
258258
.Where(z => z.Name == sendMethodName)
259259
.Where(z => item.matcher(z.GetParameters()[0]))
260-
.Should().HaveCountGreaterOrEqualTo(1, $"{descriptor.HandlerType.FullName} is missing a request implementation for {item.type}");
260+
.Should().HaveCountGreaterThanOrEqualTo(1, $"{descriptor.HandlerType.FullName} is missing a request implementation for {item.type}");
261261
}
262262

263263
{
@@ -268,7 +268,7 @@ Func<MethodInfo, bool> ForParameter(int index, Func<ParameterInfo, bool> m)
268268
return info => m(info.GetParameters()[index]);
269269
}
270270

271-
var containsCancellationToken = ForParameter(1, info => info.ParameterType.GetGenericArguments().Reverse().Take(2).Any(x => x == typeof(CancellationToken)));
271+
var containsCancellationToken = ForParameter(1, info => info.ParameterType.GetGenericArguments().AsEnumerable().Reverse().Take(2).Any(x => x == typeof(CancellationToken)));
272272
var returnType = descriptor.HasResponseType ? typeof(Task<>).MakeGenericType(descriptor.ResponseType!) : typeof(Task);
273273
var returns = ForParameter(1, info => info.ParameterType.GetGenericArguments().LastOrDefault() == returnType);
274274
var isAction = ForParameter(1, info => info.ParameterType.Name.StartsWith(nameof(Action)));
@@ -291,7 +291,7 @@ Func<MethodInfo, bool> ForParameter(int index, Func<ParameterInfo, bool> m)
291291
}
292292
{
293293
var matcher = new MethodMatcher(sendMethodRegistries, descriptor, extensionClass, sendMethodName);
294-
Func<MethodInfo, bool> containsCancellationToken = info => info.GetParameters().Reverse().Take(2).Any(x => x.ParameterType == typeof(CancellationToken));
294+
Func<MethodInfo, bool> containsCancellationToken = info => info.GetParameters().AsEnumerable().Reverse().Take(2).Any(x => x.ParameterType == typeof(CancellationToken));
295295
var returnType = descriptor.HasResponseType ? typeof(Task<>).MakeGenericType(descriptor.ResponseType!) : typeof(Task);
296296
Func<MethodInfo, bool> returns = info => info.ReturnType == returnType;
297297
Func<MethodInfo, bool> isAction = info => info.ReturnType.Name == "Void";

test/Lsp.Integration.Tests/FluentAssertionsExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Lsp.Integration.Tests
99
{
1010
public static class FluentAssertionsExtensions
1111
{
12-
public static EquivalencyAssertionOptions<T> ConfigureForSupports<T>(this EquivalencyAssertionOptions<T> options, ILogger? logger = null)
12+
public static EquivalencyOptions<T> ConfigureForSupports<T>(this EquivalencyOptions<T> options, ILogger? logger = null)
1313
{
1414
return options
1515
.WithTracing(new TraceWriter(logger ?? NullLogger.Instance))

test/Lsp.Tests/FluentAssertionsExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Lsp.Tests
99
{
1010
public static class FluentAssertionsExtensions
1111
{
12-
public static EquivalencyAssertionOptions<T> ConfigureForSupports<T>(this EquivalencyAssertionOptions<T> options, ILogger? logger = null)
12+
public static EquivalencyOptions<T> ConfigureForSupports<T>(this EquivalencyOptions<T> options, ILogger? logger = null)
1313
{
1414
return options
1515
.WithTracing(new TraceWriter(logger ?? NullLogger.Instance))

test/Lsp.Tests/FoundationTests.cs

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Diagnostics;
44
using System.IO.Pipelines;
@@ -262,13 +262,13 @@ public void HandlersShouldExtensionMethodClassWithMethods(
262262
{
263263
registries
264264
.Where(z => typeof(ILanguageClientProxy).IsAssignableFrom(z) || typeof(ILanguageServerRegistry).IsAssignableFrom(z))
265-
.Should().HaveCountGreaterOrEqualTo(
265+
.Should().HaveCountGreaterThanOrEqualTo(
266266
1,
267267
$"{descriptor.HandlerType.FullName} there should be methods for both handing the event and sending the event"
268268
);
269269
registries
270270
.Where(z => typeof(ILanguageServerProxy).IsAssignableFrom(z) || typeof(ILanguageClientRegistry).IsAssignableFrom(z))
271-
.Should().HaveCountGreaterOrEqualTo(
271+
.Should().HaveCountGreaterThanOrEqualTo(
272272
1,
273273
$"{descriptor.HandlerType.FullName} there should be methods for both handing the event and sending the event"
274274
);
@@ -277,7 +277,7 @@ public void HandlersShouldExtensionMethodClassWithMethods(
277277
{
278278
registries
279279
.Where(z => typeof(ILanguageServerProxy).IsAssignableFrom(z) || typeof(ILanguageClientRegistry).IsAssignableFrom(z))
280-
.Should().HaveCountGreaterOrEqualTo(
280+
.Should().HaveCountGreaterThanOrEqualTo(
281281
1,
282282
$"{descriptor.HandlerType.FullName} there should be methods for both handing the event and sending the event"
283283
);
@@ -289,7 +289,7 @@ public void HandlersShouldExtensionMethodClassWithMethods(
289289
{
290290
registries
291291
.Where(z => typeof(ILanguageClientProxy).IsAssignableFrom(z) || typeof(ILanguageServerRegistry).IsAssignableFrom(z))
292-
.Should().HaveCountGreaterOrEqualTo(
292+
.Should().HaveCountGreaterThanOrEqualTo(
293293
1,
294294
$"{descriptor.HandlerType.FullName} there should be methods for both handing the event and sending the event"
295295
);
@@ -341,15 +341,15 @@ public void HandlersShouldHaveExpectedExtensionMethodsBasedOnDirection(
341341
extensionClass.GetMethods(BindingFlags.Static | BindingFlags.Public)
342342
.Where(z => z.Name == onMethodName)
343343
.Where(z => item.matcher(z.GetParameters()[0]))
344-
.Should().HaveCountGreaterOrEqualTo(1, $"{descriptor.HandlerType.FullName} is missing a registry implementation for {item.type}");
344+
.Should().HaveCountGreaterThanOrEqualTo(1, $"{descriptor.HandlerType.FullName} is missing a registry implementation for {item.type}");
345345
}
346346

347347
foreach (var item in expectedRequestHandlers)
348348
{
349349
extensionClass.GetMethods(BindingFlags.Static | BindingFlags.Public)
350350
.Where(z => z.Name == sendMethodName)
351351
.Where(z => item.matcher(z.GetParameters()[0]))
352-
.Should().HaveCountGreaterOrEqualTo(1, $"{descriptor.HandlerType.FullName} is missing a request implementation for {item.type}");
352+
.Should().HaveCountGreaterThanOrEqualTo(1, $"{descriptor.HandlerType.FullName} is missing a request implementation for {item.type}");
353353
}
354354
}
355355

@@ -386,7 +386,7 @@ Func<MethodInfo, bool> ForAnyParameter(Func<ParameterInfo, bool> m)
386386
}
387387

388388
var containsCancellationToken = ForAnyParameter(
389-
info => info.ParameterType.GetGenericArguments().Reverse().Take(2).Any(x => x == typeof(CancellationToken))
389+
info => info.ParameterType.GetGenericArguments().AsEnumerable().Reverse().Take(2).Any(x => x == typeof(CancellationToken))
390390
);
391391
var returnType = descriptor.HasResponseType ? typeof(Task<>).MakeGenericType(descriptor.ResponseType!) : typeof(Task);
392392
var returns = ForAnyParameter(info => info.ParameterType.GetGenericArguments().LastOrDefault() == returnType);
@@ -517,7 +517,7 @@ Func<MethodInfo, bool> ForAnyParameter(Func<ParameterInfo, bool> m)
517517
{
518518
var matcher = new MethodMatcher(sendMethodRegistries, descriptor, extensionClass);
519519
Func<MethodInfo, bool> containsCancellationToken =
520-
info => info.GetParameters().Reverse().Take(2).Any(x => x.ParameterType == typeof(CancellationToken));
520+
info => info.GetParameters().AsEnumerable().Reverse().Take(2).Any(x => x.ParameterType == typeof(CancellationToken));
521521
var returnType = descriptor.HasResponseType ? typeof(Task<>).MakeGenericType(descriptor.ResponseType!) : typeof(Task);
522522
Func<MethodInfo, bool> returns = info => info.ReturnType == returnType;
523523
Func<MethodInfo, bool> isAction = info => info.ReturnType.Name == "Void";

test/Lsp.Tests/Models/PositionTests.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ public void Is_Sortable_By_Character()
3434

3535
a.CompareTo(c).Should().Be(0);
3636

37-
a.Should().BeLessOrEqualTo(c);
38-
a.Should().BeGreaterOrEqualTo(c);
37+
a.Should().BeLessThanOrEqualTo(c);
38+
a.Should().BeGreaterThanOrEqualTo(c);
3939
}
4040

4141
[Fact]
@@ -50,8 +50,8 @@ public void Is_Sortable_By_Line()
5050

5151
a.CompareTo(c).Should().Be(0);
5252

53-
a.Should().BeLessOrEqualTo(c);
54-
a.Should().BeGreaterOrEqualTo(c);
53+
a.Should().BeLessThanOrEqualTo(c);
54+
a.Should().BeGreaterThanOrEqualTo(c);
5555
}
5656

5757
[Fact]

test/TestingUtils/RecordExtensions.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
using FluentAssertions.Equivalency;
1+
using FluentAssertions.Equivalency;
22

33
namespace TestingUtils
44
{
55
public static class RecordExtensions
66
{
7-
public static EquivalencyAssertionOptions<TExpectation> UsingStructuralRecordEquality<TExpectation>(this EquivalencyAssertionOptions<TExpectation> options)
7+
public static EquivalencyOptions<TExpectation> UsingStructuralRecordEquality<TExpectation>(this EquivalencyOptions<TExpectation> options)
88
{
99
return options.Using(new RecordStructuralEqualityEquivalencyStep());
1010
}
1111
}
12-
}
12+
}

test/TestingUtils/RecordStructuralEqualityEquivalencyStep.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ namespace TestingUtils
55
{
66
public class RecordStructuralEqualityEquivalencyStep : StructuralEqualityEquivalencyStep, IEquivalencyStep
77
{
8-
EquivalencyResult IEquivalencyStep.Handle(Comparands comparands, IEquivalencyValidationContext context, IEquivalencyValidator nestedValidator)
8+
EquivalencyResult IEquivalencyStep.Handle(Comparands comparands, IEquivalencyValidationContext context, IValidateChildNodeEquivalency nestedValidator)
99
{
10-
return comparands.Subject?.GetType()?.GetMethod("<Clone>$") != null ? EquivalencyResult.AssertionCompleted : EquivalencyResult.ContinueWithNext;
10+
return comparands.Subject?.GetType()?.GetMethod("<Clone>$") != null ? EquivalencyResult.EquivalencyProven : EquivalencyResult.ContinueWithNext;
1111
}
1212
}
1313
}

0 commit comments

Comments
 (0)