22
33using System . ComponentModel ;
44using CommunityToolkit . Maui . Core ;
5- using CommunityToolkit . Maui . Core . Primitives ;
65using CommunityToolkit . Maui . Views ;
76using FluentAssertions ;
87using Microsoft . Maui . Controls . Shapes ;
@@ -17,13 +16,13 @@ public void Defaults_BindingContext()
1716 {
1817 MockRatingViewViewModel vm = new ( ) ;
1918 RatingView ratingViewWithBinding = new ( ) ;
20-
19+
2120 ratingViewWithBinding . BindingContext . Should ( ) . BeNull ( ) ;
2221 ratingViewWithBinding . RatingLayout . BindingContext . Should ( ) . BeNull ( ) ;
2322 ratingViewWithBinding . RatingLayout . BindingContext . Should ( ) . BeEquivalentTo ( ratingViewWithBinding . BindingContext ) ;
24-
23+
2524 ratingViewWithBinding . BindingContext = vm ;
26-
25+
2726 ratingViewWithBinding . BindingContext . Should ( ) . Be ( vm ) ;
2827 ratingViewWithBinding . RatingLayout . BindingContext . Should ( ) . Be ( vm ) ;
2928 ratingViewWithBinding . RatingLayout . BindingContext . Should ( ) . BeEquivalentTo ( ratingViewWithBinding . BindingContext ) ;
@@ -49,7 +48,7 @@ public void Defaults_ShapeDefaultsApplied()
4948 {
5049 RatingView ratingView = new ( ) ;
5150 var firstItemShape = GetItemShape ( ratingView , 0 ) ;
52-
51+
5352 firstItemShape . Should ( ) . NotBeNull ( ) ;
5453 firstItemShape . Should ( ) . BeOfType < Microsoft . Maui . Controls . Shapes . Path > ( ) ;
5554 firstItemShape . Aspect . Should ( ) . Be ( Stretch . Uniform ) ;
@@ -121,7 +120,7 @@ public void Events_RatingChanged_AddRemove()
121120 } ;
122121 ratingView . RatingChanged += OnRatingChanged ;
123122 ratingView . Rating = expectedRating ;
124- receivedEvents . Should ( ) . HaveCount ( 1 ) ;
123+ receivedEvents . Should ( ) . ContainSingle ( ) ;
125124 receivedEvents [ 0 ] . Rating . Should ( ) . Be ( expectedRating ) ;
126125
127126 void OnRatingChanged ( object ? sender , RatingChangedEventArgs e )
@@ -242,7 +241,7 @@ public void Events_ShouldBeRaised_MaximumRatingChanged_BelowRating()
242241 } ;
243242 ratingView . RatingChanged += ( sender , e ) => receivedEvents . Add ( e ) ;
244243 ratingView . MaximumRating = ( byte ) expectedRating ;
245- receivedEvents . Should ( ) . HaveCount ( 1 ) ;
244+ receivedEvents . Should ( ) . ContainSingle ( ) ;
246245 receivedEvents [ 0 ] . Rating . Should ( ) . Be ( expectedRating ) ;
247246 }
248247
@@ -269,7 +268,7 @@ public void Events_ShouldNotBeRaised_MaximumRatingChanged_AboveRating()
269268 } ;
270269 ratingView . RatingChanged += ( sender , e ) => receivedEvents . Add ( e ) ;
271270 ratingView . MaximumRating = 4 ;
272- receivedEvents . Should ( ) . HaveCount ( 0 ) ;
271+ receivedEvents . Should ( ) . BeEmpty ( ) ;
273272 }
274273
275274 [ Fact ]
@@ -381,7 +380,7 @@ public void Properties_Change_EmptyColor_Item()
381380 ratingView . EmptyColor . Should ( ) . NotBe ( emptyColor ) ;
382381 ratingView . EmptyColor = emptyColor ;
383382 ratingView . EmptyColor . Should ( ) . Be ( emptyColor ) ;
384-
383+
385384 var emptyRatingItem = ( Microsoft . Maui . Controls . Shapes . Path ) GetItemShape ( ratingView , maximumRating - 1 ) . GetVisualTreeDescendants ( ) [ 0 ] ;
386385 emptyRatingItem . Fill . Should ( ) . Be ( new SolidColorBrush ( emptyColor ) ) ;
387386 }
@@ -546,11 +545,11 @@ public void Properties_Change_ShapeBorderColor()
546545 var shapeBorderColor = Colors . Snow ;
547546 Brush brush = new SolidColorBrush ( shapeBorderColor ) ;
548547 RatingView ratingView = new ( ) ;
549-
548+
550549 ratingView . ShapeBorderColor . Should ( ) . NotBe ( shapeBorderColor ) ;
551550 ratingView . ShapeBorderColor = shapeBorderColor ;
552551 ratingView . ShapeBorderColor . Should ( ) . Be ( shapeBorderColor ) ;
553-
552+
554553 var firstRatingItem = GetItemShape ( ratingView , 0 ) ;
555554 firstRatingItem . Stroke . Should ( ) . BeOfType < SolidColorBrush > ( ) . And . Be ( brush ) ;
556555 }
@@ -563,7 +562,7 @@ public void Properties_Change_ShapeBorderThickness()
563562 ratingView . ShapeBorderThickness . Should ( ) . NotBe ( shapeBorderThickness ) ;
564563 ratingView . ShapeBorderThickness = shapeBorderThickness ;
565564 ratingView . ShapeBorderThickness . Should ( ) . Be ( shapeBorderThickness ) ;
566-
565+
567566 var firstRatingItem = GetItemShape ( ratingView , 0 ) ;
568567 firstRatingItem . StrokeThickness . Should ( ) . Be ( shapeBorderThickness ) ;
569568 }
@@ -576,7 +575,7 @@ public void Properties_Change_Size()
576575 ratingView . ItemShapeSize . Should ( ) . NotBe ( itemShapeSize ) ;
577576 ratingView . ItemShapeSize = itemShapeSize ;
578577 ratingView . ItemShapeSize . Should ( ) . Be ( itemShapeSize ) ;
579-
578+
580579 var firstRatingItem = GetItemShape ( ratingView , 0 ) ;
581580 firstRatingItem . WidthRequest . Should ( ) . Be ( itemShapeSize ) ;
582581 firstRatingItem . HeightRequest . Should ( ) . Be ( itemShapeSize ) ;
@@ -657,8 +656,8 @@ public void RatingViewDoesNotThrowsArgumentOutOfRangeExceptionWhenRatingSetBefor
657656 Rating = rating ,
658657 } ;
659658
660- Assert . Equal ( rating , ratingView . Rating ) ;
661- Assert . Equal ( maximumRating , ratingView . MaximumRating ) ;
659+ ratingView . Rating . Should ( ) . Be ( rating ) ;
660+ ratingView . MaximumRating . Should ( ) . Be ( maximumRating ) ;
662661 }
663662
664663 [ Fact ]
@@ -726,7 +725,7 @@ public void ViewStructure_CorrectNumberOfChildren()
726725 MaximumRating = maximumRating
727726 } ;
728727
729- Assert . NotNull ( ratingView . ControlTemplate ) ;
728+ ratingView . ControlTemplate . Should ( ) . NotBeNull ( ) ;
730729 ratingView . RatingLayout . GetVisualTreeDescendants ( ) . Should ( ) . HaveCount ( ( maximumRating * 2 ) + 1 ) ;
731730 ratingView . RatingLayout . Children . Should ( ) . HaveCount ( maximumRating ) ;
732731 }
@@ -747,7 +746,7 @@ public void ViewStructure_ItemChild_IsPath()
747746 ratingView . RatingLayout . Children [ 0 ] . Should ( ) . BeOfType < Border > ( ) ;
748747 var child = ( Border ) ratingView . RatingLayout . Children [ 0 ] ;
749748
750- Assert . NotNull ( child . Content ) ;
749+ child . Content . Should ( ) . NotBeNull ( ) ;
751750 child . Content . GetVisualTreeDescendants ( ) [ 0 ] . Should ( ) . BeOfType < Microsoft . Maui . Controls . Shapes . Path > ( ) ;
752751 }
753752
@@ -758,10 +757,10 @@ public void ViewStructure_ItemChild_Path_Star()
758757 ratingView . RatingLayout . Children [ 0 ] . Should ( ) . BeOfType < Border > ( ) ;
759758 var child = ( Border ) ratingView . RatingLayout . Children [ 0 ] ;
760759
761- Assert . NotNull ( child . Content ) ;
760+ child . Content . Should ( ) . NotBeNull ( ) ;
762761
763762 var shape = ( Microsoft . Maui . Controls . Shapes . Path ) child . Content . GetVisualTreeDescendants ( ) [ 0 ] ;
764- shape . GetPath ( ) . Should ( ) . Be ( Core . Primitives . RatingViewShapeHandler . Star . PathData ) ;
763+ shape . GetPath ( ) . Should ( ) . Be ( Core . Handlers . RatingViewShapeHandler . Star . PathData ) ;
765764 }
766765
767766 [ Fact ]
@@ -839,7 +838,7 @@ public void ViewStructure_Spacing()
839838 static Microsoft . Maui . Controls . Shapes . Path GetItemShape ( in RatingView ratingView , int itemIndex )
840839 {
841840 var border = ( Border ) ratingView . RatingLayout . Children [ itemIndex ] ;
842- Assert . NotNull ( border . Content ) ;
841+ border . Content . Should ( ) . NotBeNull ( ) ;
843842
844843 return ( Microsoft . Maui . Controls . Shapes . Path ) border . Content . GetVisualTreeDescendants ( ) [ 0 ] ;
845844 }
0 commit comments