-
Notifications
You must be signed in to change notification settings - Fork 34
Migrate from FluentAssertions to Shouldly #666
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
base: main
Are you sure you want to change the base?
Conversation
Thanks - I hadn't noticed they had changed the terms. It seems like because this is an open-source project, it is still legal to use v8 here. However, I dislike the change of license terms so would prefer to migrate. I will do some homework on Shouldly. |
I think it's not legal to use even here because this project is under the MIT license, which technically allows this library to be re-published verbatim under a paid license. It would only be fine if this project was under GPL or another viral license. |
@@ -25,13 +25,11 @@ public void SinceEpoch() | |||
// On .NET Standard, only windows uses TickCount64 | |||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) | |||
{ | |||
Duration.SinceEpoch().raw.Should().BeCloseTo(Duration.GetTickCount64(), 15); | |||
Duration.SinceEpoch().raw.ShouldBe(Duration.GetTickCount64()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per shouldly/shouldly#274, looks like you can give the tolerance like this:
Duration.SinceEpoch().raw.ShouldBe(Duration.GetTickCount64(), 15);
Not sure if that applies to all data types or just DateTime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, it only applies to DateTime and TimeSpan. Although there is ShouldBeInRange. Another solution could be to use TimeSpan.FromTicks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little bloated sadly but you can do this:
TimeSpan.FromTicks(Duration.SinceEpoch().raw).ShouldBe(TimeSpan.FromTicks(Stopwatch.GetTimestamp()), TimeSpan.FromTicks(15));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I fixed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like your current commit fails to build.
The convoluted version converting to TimeSpan is a bit of a mess - will need to think on how that might be cleaned up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extension method maybe? I thought you wouldn't want to bloat the project with extension methods.
As stated in #661, FluentAssertions v8 changed their license from open source (Apache 2.0) to paid costing $130 per seat for commercial use.
This pull request migrates the tests in BitFaster.Caching to Shouldly, a similar library under the BSD-3-clause license.
Alternatively, you can continue using FluentAssertions without updates, but you must pin it at
[7.0.0]
or[7.1.0]
to prevent accidental updates.There was a huge amount to change here so I used this PowerShell script to help me out: galadril/Shouldly.FromFluentAssertions