Migrate from FluentAssertions to Shouldly#666
Migrate from FluentAssertions to Shouldly#666Joy-less wants to merge 3 commits intobitfaster:mainfrom
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. |
| 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.
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.
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.
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.
I think I fixed it.
There was a problem hiding this comment.
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.
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