33using Blazor . Diagrams . Core . Events ;
44using Blazor . Diagrams . Core . Geometry ;
55using Blazor . Diagrams . Core . Models ;
6- using FluentAssertions ;
76using System . Linq ;
87using Xunit ;
98
@@ -32,11 +31,11 @@ public void Behavior_ShouldCreateLinkWithSinglePortAnchorSource_WhenMouseDownOnP
3231 // Assert
3332 var link = diagram . Links . Single ( ) ;
3433 var source = link . Source as SinglePortAnchor ;
35- source . Should ( ) . NotBeNull ( ) ;
36- source ! . Port . Should ( ) . BeSameAs ( port ) ;
34+ Assert . NotNull ( source ) ;
35+ Assert . Same ( port , source ! . Port ) ;
3736 var ongoingPosition = ( link . Target as PositionAnchor ) ! . GetPlainPosition ( ) ! ;
38- ongoingPosition . X . Should ( ) . Be ( 100 ) ;
39- ongoingPosition . Y . Should ( ) . Be ( 100 ) ;
37+ Assert . Equal ( 100 , ongoingPosition . X ) ;
38+ Assert . Equal ( 100 , ongoingPosition . Y ) ;
4039 }
4140
4241 [ Fact ]
@@ -64,14 +63,14 @@ public void Behavior_ShouldCreateLinkUsingFactory_WhenMouseDownOnPort()
6463 new PointerEventArgs ( 100 , 100 , 0 , 0 , false , false , false , 0 , 0 , 0 , 0 , 0 , 0 , string . Empty , true ) ) ;
6564
6665 // Assert
67- factoryCalled . Should ( ) . BeTrue ( ) ;
66+ Assert . True ( factoryCalled ) ;
6867 var link = diagram . Links . Single ( ) ;
6968 var source = link . Source as SinglePortAnchor ;
70- source . Should ( ) . NotBeNull ( ) ;
71- source ! . Port . Should ( ) . BeSameAs ( port ) ;
69+ Assert . NotNull ( source ) ;
70+ Assert . Same ( port , source ! . Port ) ;
7271 var ongoingPosition = ( link . Target as PositionAnchor ) ! . GetPlainPosition ( ) ! ;
73- ongoingPosition . X . Should ( ) . Be ( 100 ) ;
74- ongoingPosition . Y . Should ( ) . Be ( 100 ) ;
72+ Assert . Equal ( 100 , ongoingPosition . X ) ;
73+ Assert . Equal ( 100 , ongoingPosition . Y ) ;
7574 }
7675
7776 [ Fact ]
@@ -100,9 +99,9 @@ public void Behavior_ShouldUpdateOngoingPosition_WhenMouseMoveIsTriggered()
10099 // Assert
101100 var source = link . Source as SinglePortAnchor ;
102101 var ongoingPosition = ( link . Target as PositionAnchor ) ! . GetPlainPosition ( ) ! ;
103- ongoingPosition . X . Should ( ) . BeGreaterThan ( 145 ) ;
104- ongoingPosition . Y . Should ( ) . BeGreaterThan ( 145 ) ;
105- linkRefreshed . Should ( ) . BeTrue ( ) ;
102+ Assert . True ( ongoingPosition . X > 145 ) ;
103+ Assert . True ( ongoingPosition . Y > 145 ) ;
104+ Assert . True ( linkRefreshed ) ;
106105 }
107106
108107 [ Fact ]
@@ -132,9 +131,9 @@ public void Behavior_ShouldUpdateOngoingPosition_WhenMouseMoveIsTriggeredAndZoom
132131 // Assert
133132 var source = link . Source as SinglePortAnchor ;
134133 var ongoingPosition = ( link . Target as PositionAnchor ) ! . GetPlainPosition ( ) ! ;
135- ongoingPosition . X . Should ( ) . BeApproximately ( 107.7 , 0.1 ) ;
136- ongoingPosition . Y . Should ( ) . BeApproximately ( 101.7 , 0.1 ) ;
137- linkRefreshed . Should ( ) . BeTrue ( ) ;
134+ Assert . InRange ( ongoingPosition . X , 107.6 , 108.8 ) ;
135+ Assert . InRange ( ongoingPosition . Y , 101.6 , 101.8 ) ;
136+ Assert . True ( linkRefreshed ) ;
138137 }
139138
140139 [ Fact ]
@@ -172,9 +171,9 @@ public void Behavior_ShouldSnapToClosestPortAndRefreshPort_WhenSnappingIsEnabled
172171 // Assert
173172 var link = diagram . Links . Single ( ) ;
174173 var target = link . Target as SinglePortAnchor ;
175- target . Should ( ) . NotBeNull ( ) ;
176- target ! . Port . Should ( ) . BeSameAs ( port2 ) ;
177- port2Refreshed . Should ( ) . BeTrue ( ) ;
174+ Assert . NotNull ( target ) ;
175+ Assert . Same ( port2 , target ! . Port ) ;
176+ Assert . True ( port2Refreshed ) ;
178177 }
179178
180179 [ Fact ]
@@ -209,7 +208,7 @@ public void Behavior_ShouldNotSnapToPort_WhenSnappingIsEnabledAndPortIsNotInRadi
209208
210209 // Assert
211210 var link = diagram . Links . Single ( ) ;
212- link . Target . Should ( ) . BeOfType < PositionAnchor > ( ) ;
211+ Assert . IsType < PositionAnchor > ( link . Target ) ;
213212 }
214213
215214 [ Fact ]
@@ -251,8 +250,8 @@ public void Behavior_ShouldUnSnapAndRefreshPort_WhenSnappingIsEnabledAndPortIsNo
251250 // Assert
252251 var link = diagram . Links . Single ( ) ;
253252 var target = link . Target as SinglePortAnchor ;
254- target . Should ( ) . BeNull ( ) ;
255- port2Refreshes . Should ( ) . Be ( 2 ) ;
253+ Assert . Null ( target ) ;
254+ Assert . Equal ( 2 , port2Refreshes ) ;
256255 }
257256
258257 [ Fact ]
@@ -276,7 +275,7 @@ public void Behavior_ShouldRemoveLink_WhenMouseUpOnCanvasAndRequireTargetIsTrue(
276275 new PointerEventArgs ( 0 , 0 , 0 , 0 , false , false , false , 0 , 0 , 0 , 0 , 0 , 0 , string . Empty , true ) ) ;
277276
278277 // Assert
279- diagram . Links . Should ( ) . BeEmpty ( ) ;
278+ Assert . Empty ( diagram . Links ) ;
280279 }
281280
282281 [ Fact ]
@@ -300,7 +299,7 @@ public void Behavior_ShouldRemoveLink_WhenMouseUpOnSamePort()
300299 new PointerEventArgs ( 0 , 0 , 0 , 0 , false , false , false , 0 , 0 , 0 , 0 , 0 , 0 , string . Empty , true ) ) ;
301300
302301 // Assert
303- diagram . Links . Should ( ) . BeEmpty ( ) ;
302+ Assert . Empty ( diagram . Links ) ;
304303 }
305304
306305 [ Fact ]
@@ -336,9 +335,9 @@ public void Behavior_ShouldSetTarget_WhenMouseUp()
336335 // Assert
337336 var link = diagram . Links . Single ( ) ;
338337 var target = link . Target as SinglePortAnchor ;
339- target . Should ( ) . NotBeNull ( ) ;
340- target ! . Port . Should ( ) . BeSameAs ( port2 ) ;
341- port2Refreshes . Should ( ) . Be ( 1 ) ;
338+ Assert . NotNull ( target ) ;
339+ Assert . Same ( port2 , target ! . Port ) ;
340+ Assert . Equal ( 1 , port2Refreshes ) ;
342341 }
343342
344343 [ Fact ]
@@ -363,7 +362,7 @@ public void Behavior_ShouldNotCreateOngoingLink_WhenFactoryReturnsNull()
363362 new PointerEventArgs ( 100 , 100 , 0 , 0 , false , false , false , 0 , 0 , 0 , 0 , 0 , 0 , string . Empty , true ) ) ;
364363
365364 // Assert
366- diagram . Links . Should ( ) . HaveCount ( 0 ) ;
365+ Assert . Empty ( diagram . Links ) ;
367366 }
368367
369368 [ Fact ]
@@ -399,7 +398,7 @@ public void Behavior_ShouldTriggerLinkTargetAttached_WhenMouseUpOnOtherPort()
399398 new PointerEventArgs ( 105 , 105 , 0 , 0 , false , false , false , 0 , 0 , 0 , 0 , 0 , 0 , string . Empty , true ) ) ;
400399
401400 // Assert
402- targetAttachedTriggers . Should ( ) . Be ( 1 ) ;
401+ Assert . Equal ( 1 , targetAttachedTriggers ) ;
403402 }
404403
405404 [ Fact ]
@@ -440,7 +439,7 @@ public void Behavior_ShouldTriggerLinkTargetAttached_WhenLinkSnappedToPortAndMou
440439 new PointerEventArgs ( 140 , 100 , 0 , 0 , false , false , false , 0 , 0 , 0 , 0 , 0 , 0 , string . Empty , true ) ) ;
441440
442441 // Assert
443- targetAttachedTriggers . Should ( ) . Be ( 1 ) ;
442+ Assert . Equal ( 1 , targetAttachedTriggers ) ;
444443 }
445444
446445 [ Fact ]
@@ -463,7 +462,7 @@ public void Behavior_ShouldNotCreateLinkWithSinglePortAnchorSource_WhenMouseDown
463462 new PointerEventArgs ( 100 , 100 , 0 , 0 , false , false , false , 0 , 0 , 0 , 0 , 0 , 0 , string . Empty , true ) ) ;
464463
465464 // Assert
466- diagram . Links . Count . Should ( ) . Be ( 0 ) ;
465+ Assert . Equal ( 0 , diagram . Links . Count ) ;
467466 }
468467
469468 [ Fact ]
@@ -494,8 +493,8 @@ public void Behavior_ShouldUpdateOngoingPosition_WhenPanChanges()
494493 // Assert
495494 var source = link . Source as SinglePortAnchor ;
496495 var ongoingPosition = ( link . Target as PositionAnchor ) ! . GetPlainPosition ( ) ! ;
497- ongoingPosition . X . Should ( ) . BeApproximately ( expectedValue : 246 , 1 ) ;
498- ongoingPosition . Y . Should ( ) . BeApproximately ( expectedValue : 246 , 1 ) ;
499- linkRefreshed . Should ( ) . BeTrue ( ) ;
496+ Assert . InRange ( ongoingPosition . X , 245 , 247 ) ;
497+ Assert . InRange ( ongoingPosition . Y , 245 , 247 ) ;
498+ Assert . True ( linkRefreshed ) ;
500499 }
501500}
0 commit comments