@@ -405,27 +405,43 @@ internal void GetBoundsForSelectionType_ShouldReturnExpectedBounds(
405
405
}
406
406
407
407
[ WinFormsFact ]
408
- public void ApplyListViewThemeStyles_ShouldNotThrow_WhenCalledWithValidListView ( )
408
+ public void ApplyListViewThemeStyles_ShouldSetWindowThemeToExplorer ( )
409
409
{
410
410
using ListView listView = new ( ) ;
411
411
Exception exception = Record . Exception ( ( ) => DesignerUtils . ApplyListViewThemeStyles ( listView ) ) ;
412
412
exception . Should ( ) . BeNull ( ) ;
413
+ listView . IsHandleCreated . Should ( ) . BeTrue ( ) ;
413
414
}
414
415
415
416
[ WinFormsFact ]
416
- public void ApplyTreeViewThemeStyles_ShouldNotThrow_WhenCalledWithValidTreeView ( )
417
+ public void ApplyListViewThemeStyles_ShouldThrowArgumentNullException_WhenListViewIsNull ( )
418
+ {
419
+ Action action = ( ) => DesignerUtils . ApplyListViewThemeStyles ( null ! ) ;
420
+ action . Should ( ) . Throw < ArgumentNullException > ( ) ;
421
+ }
422
+
423
+ [ WinFormsFact ]
424
+ public void ApplyTreeViewThemeStyles_ShouldSetWindowThemeToExplorer ( )
417
425
{
418
426
using TreeView treeView = new ( ) ;
419
427
Exception exception = Record . Exception ( ( ) => DesignerUtils . ApplyTreeViewThemeStyles ( treeView ) ) ;
420
428
exception . Should ( ) . BeNull ( ) ;
429
+ treeView . IsHandleCreated . Should ( ) . BeTrue ( ) ;
430
+ }
431
+
432
+ [ WinFormsFact ]
433
+ public void ApplyTreeViewThemeStyles_ShouldThrowArgumentNullException_WhenTreeViewIsNull ( )
434
+ {
435
+ Action action = ( ) => DesignerUtils . ApplyTreeViewThemeStyles ( null ! ) ;
436
+ action . Should ( ) . Throw < ArgumentNullException > ( ) ;
421
437
}
422
438
423
439
[ WinFormsFact ]
424
440
public void CheckForNestedContainer_ShouldReturnSameContainer_WhenNotNested ( )
425
441
{
426
- Mock < IContainer > mockContainer = new ( ) ;
427
- IContainer ? result = DesignerUtils . CheckForNestedContainer ( mockContainer . Object ) ;
428
- result . Should ( ) . BeSameAs ( mockContainer . Object ) ;
442
+ Mock < IContainer > nestedContainer = new ( ) ;
443
+ IContainer ? result = DesignerUtils . CheckForNestedContainer ( nestedContainer . Object ) ;
444
+ result . Should ( ) . BeSameAs ( nestedContainer . Object ) ;
429
445
}
430
446
431
447
[ WinFormsFact ]
@@ -499,36 +515,59 @@ public void GetUniqueSiteName_ShouldReturnName_WhenNameIsNotInUseAndValid()
499
515
[ InlineData ( 0 , 0 , 100 , 100 , 10 , 10 , ToolboxSnapDragDropEventArgs . SnapDirection . Top , true , 0 , 10 ) ]
500
516
[ InlineData ( 0 , 0 , 100 , 100 , 10 , 10 , ToolboxSnapDragDropEventArgs . SnapDirection . Right , true , - 10 , 0 ) ]
501
517
internal void GetBoundsFromToolboxSnapDragDropInfo_ShouldReturnExpectedBounds (
502
- int x , int y , int width , int height , int offsetX , int offsetY ,
503
- ToolboxSnapDragDropEventArgs . SnapDirection snapDirection , bool isMirrored ,
504
- int expectedX , int expectedY )
518
+ int x ,
519
+ int y ,
520
+ int width ,
521
+ int height ,
522
+ int offsetX ,
523
+ int offsetY ,
524
+ ToolboxSnapDragDropEventArgs . SnapDirection snapDirection ,
525
+ bool isMirrored ,
526
+ int expectedX ,
527
+ int expectedY )
505
528
{
506
529
Rectangle originalBounds = new ( x , y , width , height ) ;
507
- ToolboxSnapDragDropEventArgs args = new ( snapDirection , new Point ( offsetX , offsetY ) , new DragEventArgs ( null , 0 , 0 , 0 , DragDropEffects . None , DragDropEffects . None ) ) ;
508
-
509
- Rectangle result = DesignerUtils . GetBoundsFromToolboxSnapDragDropInfo ( e : args , originalBounds : originalBounds , isMirrored : isMirrored ) ;
530
+ ToolboxSnapDragDropEventArgs args = new (
531
+ snapDirection ,
532
+ new Point ( offsetX , offsetY ) ,
533
+ new DragEventArgs (
534
+ null ,
535
+ 0 ,
536
+ 0 ,
537
+ 0 ,
538
+ DragDropEffects . None ,
539
+ DragDropEffects . None ) ) ;
540
+
541
+ Rectangle result = DesignerUtils . GetBoundsFromToolboxSnapDragDropInfo (
542
+ e : args ,
543
+ originalBounds : originalBounds ,
544
+ isMirrored : isMirrored ) ;
510
545
511
546
result . X . Should ( ) . Be ( expectedX ) ;
512
547
result . Y . Should ( ) . Be ( expectedY ) ;
513
548
}
514
549
515
550
[ WinFormsTheory ]
516
- [ InlineData ( ContentAlignment . TopLeft , 14 ) ]
517
- [ InlineData ( ContentAlignment . TopCenter , 14 ) ]
518
- [ InlineData ( ContentAlignment . TopRight , 14 ) ]
519
- [ InlineData ( ContentAlignment . MiddleLeft , 31 ) ]
520
- [ InlineData ( ContentAlignment . MiddleCenter , 31 ) ]
521
- [ InlineData ( ContentAlignment . MiddleRight , 31 ) ]
522
- [ InlineData ( ContentAlignment . BottomLeft , 48 ) ]
523
- [ InlineData ( ContentAlignment . BottomCenter , 48 ) ]
524
- [ InlineData ( ContentAlignment . BottomRight , 48 ) ]
525
- public void GetTextBaseline_ShouldReturnExpectedBaseline ( ContentAlignment alignment , int expectedBaseline )
551
+ [ InlineData ( 100 , 50 , "Arial" , 10 , ContentAlignment . TopLeft , 14 ) ]
552
+ [ InlineData ( 100 , 50 , "Arial" , 10 , ContentAlignment . TopCenter , 14 ) ]
553
+ [ InlineData ( 100 , 50 , "Arial" , 10 , ContentAlignment . TopRight , 14 ) ]
554
+ [ InlineData ( 100 , 50 , "Arial" , 10 , ContentAlignment . MiddleLeft , 31 ) ]
555
+ [ InlineData ( 100 , 50 , "Arial" , 10 , ContentAlignment . MiddleCenter , 31 ) ]
556
+ [ InlineData ( 100 , 50 , "Arial" , 10 , ContentAlignment . MiddleRight , 31 ) ]
557
+ [ InlineData ( 100 , 50 , "Arial" , 10 , ContentAlignment . BottomLeft , 48 ) ]
558
+ [ InlineData ( 100 , 50 , "Arial" , 10 , ContentAlignment . BottomCenter , 48 ) ]
559
+ [ InlineData ( 100 , 50 , "Arial" , 10 , ContentAlignment . BottomRight , 48 ) ]
560
+ [ InlineData ( 200 , 100 , "Times New Roman" , 12 , ContentAlignment . TopLeft , 16 ) ]
561
+ [ InlineData ( 200 , 100 , "Times New Roman" , 12 , ContentAlignment . MiddleCenter , 57 ) ]
562
+ [ InlineData ( 200 , 100 , "Times New Roman" , 12 , ContentAlignment . BottomRight , 97 ) ]
563
+ public void GetTextBaseline_ShouldReturnExpectedBaseline_WithVariousFontsAndBounds (
564
+ int width , int height , string fontFamily , float fontSize , ContentAlignment alignment , int expectedBaseline )
526
565
{
527
566
using Button button = new ( )
528
567
{
529
- Width = 100 ,
530
- Height = 50 ,
531
- Font = new Font ( "Arial" , 10 )
568
+ Width = width ,
569
+ Height = height ,
570
+ Font = new Font ( fontFamily , fontSize )
532
571
} ;
533
572
534
573
int baseline = DesignerUtils . GetTextBaseline ( button , alignment ) ;
@@ -543,22 +582,4 @@ public void GetTextBaseline_ShouldThrowNullNullException_WhenControlIsNull()
543
582
544
583
action . Should ( ) . Throw < NullReferenceException > ( ) ;
545
584
}
546
-
547
- [ WinFormsTheory ]
548
- [ InlineData ( ContentAlignment . TopLeft , 16 ) ]
549
- [ InlineData ( ContentAlignment . MiddleCenter , 57 ) ]
550
- [ InlineData ( ContentAlignment . BottomRight , 97 ) ]
551
- public void GetTextBaseline_ShouldRespectFontAndBounds ( ContentAlignment alignment , int expectedBaseline )
552
- {
553
- using Button button = new ( )
554
- {
555
- Width = 200 ,
556
- Height = 100 ,
557
- Font = new Font ( "Times New Roman" , 12 )
558
- } ;
559
-
560
- int baseline = DesignerUtils . GetTextBaseline ( button , alignment ) ;
561
-
562
- baseline . Should ( ) . Be ( expectedBaseline ) ;
563
- }
564
585
}
0 commit comments