@@ -120,7 +120,7 @@ public void GetVisualState_Filled(bool enabled, bool hovered, string stroke, str
120
120
[ InlineData ( OtpInputStyle . Outlined , 13 , false , OtpInputState . Error , "#008000" , "#FF0000" , "#1C1B1F" , "#611c1b1f" ) ]
121
121
public void UpdateParameters ( OtpInputStyle otpInputStyle , double cornerRadius , bool isEnabled , OtpInputState otpInputState , string stroke , string background , string textColor , string disabledTextColor )
122
122
{
123
- OTPEntry otpEntry = new OTPEntry ( ) ;
123
+ OTPEntry otpEntry = new OTPEntry ( ) ;
124
124
otpEntry . UpdateParameters ( otpInputStyle , cornerRadius , new PointF ( 10 , 10 ) , new PointF ( 30 , 30 ) , new SfOtpInput ( ) , isEnabled , otpInputState , Color . FromArgb ( stroke ) , Color . FromArgb ( background ) , Color . FromArgb ( textColor ) , Color . FromArgb ( disabledTextColor ) ) ;
125
125
OtpInputStyle ? resultInputStyle = ( OtpInputStyle ? ) GetPrivateField ( otpEntry , "_styleMode" ) ;
126
126
double ? resultCornerRadius = ( double ? ) GetPrivateField ( otpEntry , "_cornerRadius" ) ;
@@ -292,6 +292,48 @@ public void InputBackground(Color input, Color expected)
292
292
Assert . Equal ( expected , actual ) ;
293
293
}
294
294
295
+
296
+
297
+ [ Theory ]
298
+ [ InlineData ( 40 ) ]
299
+ [ InlineData ( 60 ) ]
300
+ [ InlineData ( 100 ) ]
301
+ public void BoxWidth_UpdatesEntryDimensions ( double newWidth )
302
+ {
303
+ var otpInput = new SfOtpInput ( ) ;
304
+ otpInput . BoxWidth = newWidth ;
305
+ var _otpEntries = ( OTPEntry [ ] ? ) GetPrivateField ( otpInput , "_otpEntries" ) ;
306
+ if ( _otpEntries != null )
307
+ {
308
+ foreach ( var entry in _otpEntries )
309
+ {
310
+ Assert . Equal ( newWidth , entry . MinimumWidthRequest ) ;
311
+ Assert . Equal ( newWidth , entry . WidthRequest ) ;
312
+ }
313
+ }
314
+ }
315
+
316
+
317
+
318
+ [ Theory ]
319
+ [ InlineData ( 40 ) ]
320
+ [ InlineData ( 55 ) ]
321
+ [ InlineData ( 80 ) ]
322
+ public void BoxHeight_UpdatesEntryDimensions ( double newHeight )
323
+ {
324
+ var otpInput = new SfOtpInput ( ) ;
325
+ otpInput . BoxHeight = newHeight ;
326
+ var _otpEntries = ( OTPEntry [ ] ? ) GetPrivateField ( otpInput , "_otpEntries" ) ;
327
+ if ( _otpEntries != null )
328
+ {
329
+ foreach ( var entry in _otpEntries )
330
+ {
331
+ Assert . Equal ( newHeight , entry . MinimumHeightRequest ) ;
332
+ Assert . Equal ( newHeight , entry . HeightRequest ) ;
333
+ }
334
+ }
335
+ }
336
+
295
337
#endregion
296
338
297
339
#region Internal Properties
@@ -548,11 +590,11 @@ public void FocusAsync()
548
590
var otpInput = new SfOtpInput ( ) ;
549
591
OTPEntry [ ] ? otpEntries = ( OTPEntry [ ] ? ) GetPrivateField ( otpInput , "_otpEntries" ) ;
550
592
SetPrivateField ( otpInput , "_otpEntries" , otpEntries ) ;
551
- var sender = otpEntries ? [ 2 ] ;
593
+ var sender = otpEntries ? [ 2 ] ;
552
594
var focusEventArgs = new FocusEventArgs ( otpInput , true ) ;
553
595
InvokePrivateMethod ( otpInput , "FocusAsync" , sender , focusEventArgs ) ;
554
596
var focusedIndex = ( int ? ) GetPrivateField ( otpInput , "_focusedIndex" ) ;
555
- Assert . Equal ( 2 , focusedIndex ) ;
597
+ Assert . Equal ( 2 , focusedIndex ) ;
556
598
}
557
599
558
600
@@ -567,14 +609,14 @@ public void FocusOutAsync()
567
609
}
568
610
569
611
[ Theory ]
570
- [ InlineData ( 0 , true , 0 ) ]
612
+ [ InlineData ( 0 , true , 0 ) ]
571
613
[ InlineData ( 1 , false , 1 ) ]
572
614
public void FocusEntry ( int index , bool setCursorToStart , int expectedCursorPosition )
573
615
{
574
616
var otpInput = new SfOtpInput ( ) ;
575
617
OTPEntry [ ] ? otpEntries = ( OTPEntry [ ] ? ) GetPrivateField ( otpInput , "_otpEntries" ) ;
576
618
SetPrivateField ( otpInput , "_otpEntries" , otpEntries ) ;
577
- SetPrivateField ( otpInput , "_focusedIndex" , 0 ) ;
619
+ SetPrivateField ( otpInput , "_focusedIndex" , 0 ) ;
578
620
otpEntries ? [ 0 ] . Focus ( ) ;
579
621
InvokePrivateMethod ( otpInput , "FocusEntry" , index , setCursorToStart ) ;
580
622
int ? resultFocusedIndex = ( int ? ) GetPrivateField ( otpInput , "_focusedIndex" ) ;
@@ -584,9 +626,9 @@ public void FocusEntry(int index, bool setCursorToStart, int expectedCursorPosit
584
626
}
585
627
586
628
[ Theory ]
587
- [ InlineData ( 3 , true , 3 ) ]
629
+ [ InlineData ( 3 , true , 3 ) ]
588
630
[ InlineData ( 0 , false , 0 ) ]
589
- [ InlineData ( 3 , false , 3 ) ]
631
+ [ InlineData ( 3 , false , 3 ) ]
590
632
public void HandleFocus ( int index , bool hasText , int expectedFocusIndex )
591
633
{
592
634
var otpInput = new SfOtpInput ( ) ;
@@ -596,26 +638,26 @@ public void HandleFocus(int index, bool hasText, int expectedFocusIndex)
596
638
SetPrivateField ( otpInput , "_focusedIndex" , index ) ;
597
639
InvokePrivateMethod ( otpInput , "HandleFocus" , index , hasText ) ;
598
640
focusedIndex = GetPrivateField ( otpInput , "_focusedIndex" ) ;
599
- Assert . Equal ( expectedFocusIndex , focusedIndex ) ;
641
+ Assert . Equal ( expectedFocusIndex , focusedIndex ) ;
600
642
}
601
643
602
644
[ Theory ]
603
- [ InlineData ( 0 , 1 ) ]
645
+ [ InlineData ( 0 , 1 ) ]
604
646
[ InlineData ( 1 , 1 ) ]
605
- [ InlineData ( 2 , 1 ) ]
606
- [ InlineData ( 3 , 1 ) ]
647
+ [ InlineData ( 2 , 1 ) ]
648
+ [ InlineData ( 3 , 1 ) ]
607
649
public void GetStrokeThickness ( int index , float expectedStrokeThickness )
608
650
{
609
651
var otpInput = new SfOtpInput ( ) ;
610
652
OTPEntry [ ] ? otpEntries = ( OTPEntry [ ] ? ) GetPrivateField ( otpInput , "_otpEntries" ) ;
611
653
SetPrivateField ( otpInput , "_otpEntries" , otpEntries ) ;
612
654
float ? strokeThickness = ( float ? ) InvokePrivateMethod ( otpInput , "GetStrokeThickness" , index ) ;
613
- Assert . Equal ( expectedStrokeThickness , strokeThickness ) ;
655
+ Assert . Equal ( expectedStrokeThickness , strokeThickness ) ;
614
656
}
615
657
616
658
617
659
[ Theory ]
618
- [ InlineData ( 0 , 30f , 40f , 5f , 3f , 50f , false , 300f ) ]
660
+ [ InlineData ( 0 , 30f , 40f , 5f , 3f , 50f , false , 300f ) ]
619
661
[ InlineData ( 1 , 35f , 45f , 10f , 5f , 60f , false , 300f ) ]
620
662
public void UpdateDrawingParameters ( int index , float entryWidth , float entryHeight , float spacing , float extraSpacing , float lineLength , bool isRTL , float controlWidth )
621
663
{
@@ -667,14 +709,14 @@ public void UpdateValue()
667
709
var otpInput = new SfOtpInput ( ) ;
668
710
OTPEntry [ ] ? _otpEntries = ( OTPEntry [ ] ? ) GetPrivateField ( otpInput , "_otpEntries" ) ;
669
711
670
- string invalidInput = "12A4" ;
671
- InvokePrivateMethod ( otpInput , "UpdateValue" , otpInput , invalidInput ) ;
712
+ string invalidInput = "12A4" ;
713
+ InvokePrivateMethod ( otpInput , "UpdateValue" , otpInput , invalidInput ) ;
672
714
Assert . Equal ( "1" , _otpEntries ? [ 0 ] . Text ) ;
673
715
Assert . Equal ( "2" , _otpEntries ? [ 1 ] . Text ) ;
674
- Assert . Equal ( "" , _otpEntries ? [ 2 ] . Text ) ;
716
+ Assert . Equal ( "" , _otpEntries ? [ 2 ] . Text ) ;
675
717
Assert . Equal ( "4" , _otpEntries ? [ 3 ] . Text ) ;
676
718
677
- otpInput . Type = OtpInputType . Password ;
719
+ otpInput . Type = OtpInputType . Password ;
678
720
string passwordInput = "1234" ;
679
721
InvokePrivateMethod ( otpInput , "UpdateValue" , otpInput , passwordInput ) ;
680
722
if ( _otpEntries != null )
@@ -696,7 +738,7 @@ public void UpdateEntriesLength(int initialLength, int newLength)
696
738
InvokePrivateMethod ( otpInput , "UpdateEntriesLength" , initialLength , newLength ) ;
697
739
OTPEntry [ ] ? _otpEntries = ( OTPEntry [ ] ? ) GetPrivateField ( otpInput , "_otpEntries" ) ;
698
740
SetPrivateField ( otpInput , "_otpEntries" , _otpEntries ) ;
699
- Assert . Equal ( newLength , _otpEntries ? . Length ) ;
741
+ Assert . Equal ( newLength , _otpEntries ? . Length ) ;
700
742
}
701
743
702
744
[ Theory ]
@@ -753,14 +795,14 @@ public void AddEntry(int initialLength,int newLength)
753
795
int expectedSeparatorCount = newLength - 1 ;
754
796
int actualSeparatorCount = layout . Children . OfType < SfLabel > ( ) . Count ( ) ;
755
797
Assert . Equal ( expectedSeparatorCount , actualSeparatorCount ) ;
756
- int expectedTotalChildren = newLength + expectedSeparatorCount ;
798
+ int expectedTotalChildren = newLength + expectedSeparatorCount ;
757
799
Assert . Equal ( expectedTotalChildren , layout . Children . Count ) ;
758
800
}
759
801
760
802
761
803
[ Theory ]
762
- [ InlineData ( 0 , 50f , 30f , 5f , 5f ) ]
763
- [ InlineData ( 0 , 60f , 40f , 10f , 10f ) ]
804
+ [ InlineData ( 0 , 50f , 30f , 5f , 5f ) ]
805
+ [ InlineData ( 0 , 60f , 40f , 10f , 10f ) ]
764
806
public void SetInputFieldPosition ( int index , float entryWidth , float entryHeight , float spacing , float extraSpacing )
765
807
{
766
808
@@ -777,22 +819,22 @@ public void SetInputFieldPosition(int index, float entryWidth, float entryHeight
777
819
InvokePrivateMethod ( otpInput , "SetInputFieldPosition" , index , otpEntry ) ;
778
820
779
821
RectF [ ] ? entryBounds = ( RectF [ ] ? ) GetPrivateField ( otpInput , "_entryBounds" ) ;
780
- Assert . Equal ( index + 1 , entryBounds ? . Length ) ;
822
+ Assert . Equal ( index + 1 , entryBounds ? . Length ) ;
781
823
782
824
var layoutBounds = AbsoluteLayout . GetLayoutBounds ( otpEntry ) ;
783
825
784
826
float expectedX = ( entryWidth + spacing ) * index + extraSpacing ;
785
827
float expectedY = extraSpacing ;
786
828
787
- Assert . Equal ( expectedX , layoutBounds . X ) ;
829
+ Assert . Equal ( expectedX , layoutBounds . X ) ;
788
830
Assert . Equal ( expectedY , layoutBounds . Y ) ;
789
831
Assert . Equal ( entryWidth , layoutBounds . Width ) ;
790
- Assert . Equal ( entryHeight , layoutBounds . Height ) ;
832
+ Assert . Equal ( entryHeight , layoutBounds . Height ) ;
791
833
}
792
834
793
835
[ Theory ]
794
- [ InlineData ( 0 , 50f , 30f , 5f , 5f ) ]
795
- [ InlineData ( 1 , 60f , 40f , 10f , 10f ) ]
836
+ [ InlineData ( 0 , 50f , 30f , 5f , 5f ) ]
837
+ [ InlineData ( 1 , 60f , 40f , 10f , 10f ) ]
796
838
public void SetSeparatorPosition ( int index , float entryWidth , float entryHeight , float spacing , float separatorWidth )
797
839
{
798
840
var otpInput = new SfOtpInput ( ) ;
0 commit comments