Skip to content

Commit e5435eb

Browse files
committed
Update migration doc with proximity assertion syntax
1 parent 7ff63eb commit e5435eb

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

MIGRATION.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ using static SharpAssert.Sharp; // For Assert(), Throws<T>()
127127
using SharpAssert; // For custom expectations (IsEquivalentTo, etc.)
128128
using SharpAssert.Features.Collections; // For IsInAscendingOrder(), AllUnique()
129129
using SharpAssert.Features.Strings; // For Matches(), occurrence counting
130+
using SharpAssert.Features.Proximity; // For BeCloseTo(), BeApproximately()
130131
```
131132

132133
Migration:
@@ -220,12 +221,15 @@ act.Should().Throw<T>().WithMessage(msg) → var ex = Throws<T>(act);
220221
val.Should().BePositive() → Assert(val > 0)
221222
val.Should().BeNegative() → Assert(val < 0)
222223
val.Should().BeInRange(min, max) → Assert(val >= min && val <= max)
223-
val.Should().BeCloseTo(target, precision) → Assert(Math.Abs(val - target) <= precision)
224-
val.Should().BeApproximately(pi, 0.01) → Assert(Math.Abs(val - pi) <= 0.01)
224+
val.Should().BeCloseTo(target, precision) → Assert(val.BeCloseTo(target, precision))
225+
// Or native: Assert(Math.Abs(val - target) <= precision)
226+
val.Should().BeApproximately(pi, 0.01) → Assert(val.BeApproximately(pi, 0.01))
227+
// Or native: Assert(Math.Abs(val - pi) <= 0.01)
225228
226229
// DateTime Proximity
227230
dt.Should().BeCloseTo(expected, 100.Milliseconds())
228-
Assert(Math.Abs((dt - expected).TotalMilliseconds) <= 100)
231+
Assert(dt.BeCloseTo(expected, TimeSpan.FromMilliseconds(100)))
232+
// Or native: Assert(Math.Abs((dt - expected).TotalMilliseconds) <= 100)
229233
dt.Should().BeAfter(baseDate).Within(5.Minutes())
230234
Assert(dt >= baseDate && dt <= baseDate.AddMinutes(5))
231235
dt.Should().BeBefore(deadline).Within(1.Hours())

0 commit comments

Comments
 (0)