-
Notifications
You must be signed in to change notification settings - Fork 731
Closed
Labels
Description
Description
- I'm iterating over 2 lists
- I want to compare the 2 values at each point in the list
- I want the value to be within 0.1% of each other
Complete minimal example reproducing the issue
var sheetRows = new List<float> { -24.0, 0.1, 10};
var loads= new List<float> { -24.0, 0.1, 10.05};
foreach ((var xl, var db) in sheetRows.Zip(loads, (n, w) => (n, w)))
{
xl.Should().BeApproximately(db, db*0.001f);
}Expected behavior:
To pass
Actual behavior:
Expected xl to approximate -24F +/- -0.024F, but -24F differed by 0F.
at FluentAssertions.Execution.LateBoundTestFramework.Throw(String message)
at FluentAssertions.Execution.TestFrameworkProvider.Throw(String message)
at FluentAssertions.Execution.DefaultAssertionStrategy.HandleFailure(String message)
at FluentAssertions.Execution.AssertionScope.FailWith(Func`1 failReasonFunc)
at FluentAssertions.Execution.AssertionScope.FailWith(Func`1 failReasonFunc)
at FluentAssertions.Execution.AssertionScope.FailWith(String message, Object[] args)
at FluentAssertions.NumericAssertionsExtensions.FailIfDifferenceOutsidePrecision[T](Boolean differenceWithinPrecision, NumericAssertions`1 parent, T expectedValue, T precision, T actualDifference, String because, Object[] becauseArgs)
at FluentAssertions.NumericAssertionsExtensions.BeApproximately(NumericAssertions`1 parent, Single expectedValue, Single precision, String because, Object[] becauseArgs)
at RoutingTests.UnitResponseModuleTests.U010_CheckTranslationAsync(Int64 sId, String sheetName, Int32 expected, Int32 excelRowCount) in C:\Users\sogscx\source\repos\Float\Compute\Test\RoutingTests\UnitResponseModuleTests.cs:line 480
at NUnit.Framework.Internal.TaskAwaitAdapter.GenericAdapter`1.BlockUntilCompleted()
Versions
- Which version of Fluent Assertions are you using?
latest - Which .NET runtime and version are you targeting? E.g. .NET framework 4.6.1 or .NET Core 2.1.
.NET Core 3.1 running NUnit