Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix FluentAssertions after major update #1442

Merged
merged 3 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.1" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="FluentAssertions" Version="7.1.0" />
<PackageVersion Include="FluentAssertions" Version="8.0.1" />
<PackageVersion Include="Verify.Xunit" Version="28.0.0" />
<PackageVersion Include="Verify.SourceGenerators" Version="2.4.3" />
<PackageVersion Include="NSubstitute" Version="5.3.0" />
Expand Down
8 changes: 4 additions & 4 deletions test/Dap.Tests/FoundationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,15 +249,15 @@ public void HandlersShouldHaveExpectedExtensionMethodsBasedOnDirection(
extensionClass.GetMethods(BindingFlags.Static | BindingFlags.Public)
.Where(z => z.Name == onMethodName)
.Where(z => item.matcher(z.GetParameters()[0]))
.Should().HaveCountGreaterOrEqualTo(1, $"{descriptor.HandlerType.FullName} is missing a registry implementation for {item.type}");
.Should().HaveCountGreaterThanOrEqualTo(1, $"{descriptor.HandlerType.FullName} is missing a registry implementation for {item.type}");
}

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

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

var containsCancellationToken = ForParameter(1, info => info.ParameterType.GetGenericArguments().Reverse().Take(2).Any(x => x == typeof(CancellationToken)));
var containsCancellationToken = ForParameter(1, info => info.ParameterType.GetGenericArguments().AsEnumerable().Reverse().Take(2).Any(x => x == typeof(CancellationToken)));
var returnType = descriptor.HasResponseType ? typeof(Task<>).MakeGenericType(descriptor.ResponseType!) : typeof(Task);
var returns = ForParameter(1, info => info.ParameterType.GetGenericArguments().LastOrDefault() == returnType);
var isAction = ForParameter(1, info => info.ParameterType.Name.StartsWith(nameof(Action)));
Expand All @@ -291,7 +291,7 @@ Func<MethodInfo, bool> ForParameter(int index, Func<ParameterInfo, bool> m)
}
{
var matcher = new MethodMatcher(sendMethodRegistries, descriptor, extensionClass, sendMethodName);
Func<MethodInfo, bool> containsCancellationToken = info => info.GetParameters().Reverse().Take(2).Any(x => x.ParameterType == typeof(CancellationToken));
Func<MethodInfo, bool> containsCancellationToken = info => info.GetParameters().AsEnumerable().Reverse().Take(2).Any(x => x.ParameterType == typeof(CancellationToken));
var returnType = descriptor.HasResponseType ? typeof(Task<>).MakeGenericType(descriptor.ResponseType!) : typeof(Task);
Func<MethodInfo, bool> returns = info => info.ReturnType == returnType;
Func<MethodInfo, bool> isAction = info => info.ReturnType.Name == "Void";
Expand Down
2 changes: 1 addition & 1 deletion test/Lsp.Integration.Tests/FluentAssertionsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Lsp.Integration.Tests
{
public static class FluentAssertionsExtensions
{
public static EquivalencyAssertionOptions<T> ConfigureForSupports<T>(this EquivalencyAssertionOptions<T> options, ILogger? logger = null)
public static EquivalencyOptions<T> ConfigureForSupports<T>(this EquivalencyOptions<T> options, ILogger? logger = null)
{
return options
.WithTracing(new TraceWriter(logger ?? NullLogger.Instance))
Expand Down
2 changes: 1 addition & 1 deletion test/Lsp.Tests/FluentAssertionsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Lsp.Tests
{
public static class FluentAssertionsExtensions
{
public static EquivalencyAssertionOptions<T> ConfigureForSupports<T>(this EquivalencyAssertionOptions<T> options, ILogger? logger = null)
public static EquivalencyOptions<T> ConfigureForSupports<T>(this EquivalencyOptions<T> options, ILogger? logger = null)
{
return options
.WithTracing(new TraceWriter(logger ?? NullLogger.Instance))
Expand Down
18 changes: 9 additions & 9 deletions test/Lsp.Tests/FoundationTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO.Pipelines;
Expand Down Expand Up @@ -262,13 +262,13 @@ public void HandlersShouldExtensionMethodClassWithMethods(
{
registries
.Where(z => typeof(ILanguageClientProxy).IsAssignableFrom(z) || typeof(ILanguageServerRegistry).IsAssignableFrom(z))
.Should().HaveCountGreaterOrEqualTo(
.Should().HaveCountGreaterThanOrEqualTo(
1,
$"{descriptor.HandlerType.FullName} there should be methods for both handing the event and sending the event"
);
registries
.Where(z => typeof(ILanguageServerProxy).IsAssignableFrom(z) || typeof(ILanguageClientRegistry).IsAssignableFrom(z))
.Should().HaveCountGreaterOrEqualTo(
.Should().HaveCountGreaterThanOrEqualTo(
1,
$"{descriptor.HandlerType.FullName} there should be methods for both handing the event and sending the event"
);
Expand All @@ -277,7 +277,7 @@ public void HandlersShouldExtensionMethodClassWithMethods(
{
registries
.Where(z => typeof(ILanguageServerProxy).IsAssignableFrom(z) || typeof(ILanguageClientRegistry).IsAssignableFrom(z))
.Should().HaveCountGreaterOrEqualTo(
.Should().HaveCountGreaterThanOrEqualTo(
1,
$"{descriptor.HandlerType.FullName} there should be methods for both handing the event and sending the event"
);
Expand All @@ -289,7 +289,7 @@ public void HandlersShouldExtensionMethodClassWithMethods(
{
registries
.Where(z => typeof(ILanguageClientProxy).IsAssignableFrom(z) || typeof(ILanguageServerRegistry).IsAssignableFrom(z))
.Should().HaveCountGreaterOrEqualTo(
.Should().HaveCountGreaterThanOrEqualTo(
1,
$"{descriptor.HandlerType.FullName} there should be methods for both handing the event and sending the event"
);
Expand Down Expand Up @@ -341,15 +341,15 @@ public void HandlersShouldHaveExpectedExtensionMethodsBasedOnDirection(
extensionClass.GetMethods(BindingFlags.Static | BindingFlags.Public)
.Where(z => z.Name == onMethodName)
.Where(z => item.matcher(z.GetParameters()[0]))
.Should().HaveCountGreaterOrEqualTo(1, $"{descriptor.HandlerType.FullName} is missing a registry implementation for {item.type}");
.Should().HaveCountGreaterThanOrEqualTo(1, $"{descriptor.HandlerType.FullName} is missing a registry implementation for {item.type}");
}

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

Expand Down Expand Up @@ -386,7 +386,7 @@ Func<MethodInfo, bool> ForAnyParameter(Func<ParameterInfo, bool> m)
}

var containsCancellationToken = ForAnyParameter(
info => info.ParameterType.GetGenericArguments().Reverse().Take(2).Any(x => x == typeof(CancellationToken))
info => info.ParameterType.GetGenericArguments().AsEnumerable().Reverse().Take(2).Any(x => x == typeof(CancellationToken))
);
var returnType = descriptor.HasResponseType ? typeof(Task<>).MakeGenericType(descriptor.ResponseType!) : typeof(Task);
var returns = ForAnyParameter(info => info.ParameterType.GetGenericArguments().LastOrDefault() == returnType);
Expand Down Expand Up @@ -517,7 +517,7 @@ Func<MethodInfo, bool> ForAnyParameter(Func<ParameterInfo, bool> m)
{
var matcher = new MethodMatcher(sendMethodRegistries, descriptor, extensionClass);
Func<MethodInfo, bool> containsCancellationToken =
info => info.GetParameters().Reverse().Take(2).Any(x => x.ParameterType == typeof(CancellationToken));
info => info.GetParameters().AsEnumerable().Reverse().Take(2).Any(x => x.ParameterType == typeof(CancellationToken));
var returnType = descriptor.HasResponseType ? typeof(Task<>).MakeGenericType(descriptor.ResponseType!) : typeof(Task);
Func<MethodInfo, bool> returns = info => info.ReturnType == returnType;
Func<MethodInfo, bool> isAction = info => info.ReturnType.Name == "Void";
Expand Down
8 changes: 4 additions & 4 deletions test/Lsp.Tests/Models/PositionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public void Is_Sortable_By_Character()

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

a.Should().BeLessOrEqualTo(c);
a.Should().BeGreaterOrEqualTo(c);
a.Should().BeLessThanOrEqualTo(c);
a.Should().BeGreaterThanOrEqualTo(c);
}

[Fact]
Expand All @@ -50,8 +50,8 @@ public void Is_Sortable_By_Line()

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

a.Should().BeLessOrEqualTo(c);
a.Should().BeGreaterOrEqualTo(c);
a.Should().BeLessThanOrEqualTo(c);
a.Should().BeGreaterThanOrEqualTo(c);
}

[Fact]
Expand Down
6 changes: 3 additions & 3 deletions test/TestingUtils/RecordExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using FluentAssertions.Equivalency;
using FluentAssertions.Equivalency;

namespace TestingUtils
{
public static class RecordExtensions
{
public static EquivalencyAssertionOptions<TExpectation> UsingStructuralRecordEquality<TExpectation>(this EquivalencyAssertionOptions<TExpectation> options)
public static EquivalencyOptions<TExpectation> UsingStructuralRecordEquality<TExpectation>(this EquivalencyOptions<TExpectation> options)
{
return options.Using(new RecordStructuralEqualityEquivalencyStep());
}
}
}
}
4 changes: 2 additions & 2 deletions test/TestingUtils/RecordStructuralEqualityEquivalencyStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ namespace TestingUtils
{
public class RecordStructuralEqualityEquivalencyStep : StructuralEqualityEquivalencyStep, IEquivalencyStep
{
EquivalencyResult IEquivalencyStep.Handle(Comparands comparands, IEquivalencyValidationContext context, IEquivalencyValidator nestedValidator)
EquivalencyResult IEquivalencyStep.Handle(Comparands comparands, IEquivalencyValidationContext context, IValidateChildNodeEquivalency nestedValidator)
{
return comparands.Subject?.GetType()?.GetMethod("<Clone>$") != null ? EquivalencyResult.AssertionCompleted : EquivalencyResult.ContinueWithNext;
return comparands.Subject?.GetType()?.GetMethod("<Clone>$") != null ? EquivalencyResult.EquivalencyProven : EquivalencyResult.ContinueWithNext;
}
}
}
Loading