@@ -101,7 +101,7 @@ Private Property Get Interface1_a() As String
101
101
Err.Raise 5 'TODO implement interface member
102
102
End Property
103
103
104
- Private Property Let Interface1_a(ByRef RHS As String)
104
+ Private Property Let Interface1_a(RHS As String)
105
105
Err.Raise 5 'TODO implement interface member
106
106
End Property
107
107
@@ -129,7 +129,7 @@ public void ImplementInterface_Procedure_WithParams()
129
129
const string expectedCode =
130
130
@"Implements Interface1
131
131
132
- Private Sub Interface1_Foo(ByVal a As Integer, ByRef b As Variant, ByRef c As Variant, ByRef d As Long)
132
+ Private Sub Interface1_Foo(ByVal a As Integer, ByRef b As Variant, c As Variant, d As Long)
133
133
Err.Raise 5 'TODO implement interface member
134
134
End Sub
135
135
" ;
@@ -201,7 +201,7 @@ public void ImplementInterface_Function_WithParam()
201
201
const string expectedCode =
202
202
@"Implements Interface1
203
203
204
- Private Function Interface1_Foo(ByRef a As Variant) As Variant
204
+ Private Function Interface1_Foo(a As Variant) As Variant
205
205
Err.Raise 5 'TODO implement interface member
206
206
End Function
207
207
" ;
@@ -273,7 +273,7 @@ public void ImplementInterface_PropertyGet_WithParam()
273
273
const string expectedCode =
274
274
@"Implements Interface1
275
275
276
- Private Property Get Interface1_Foo(ByRef a As Variant) As Variant
276
+ Private Property Get Interface1_Foo(a As Variant) As Variant
277
277
Err.Raise 5 'TODO implement interface member
278
278
End Property
279
279
" ;
@@ -321,7 +321,7 @@ public void ImplementInterface_PropertyLet_WithParam()
321
321
const string expectedCode =
322
322
@"Implements Interface1
323
323
324
- Private Property Let Interface1_Foo(ByRef a As Variant)
324
+ Private Property Let Interface1_Foo(a As Variant)
325
325
Err.Raise 5 'TODO implement interface member
326
326
End Property
327
327
" ;
@@ -369,7 +369,7 @@ public void ImplementInterface_PropertySet_WithParam()
369
369
const string expectedCode =
370
370
@"Implements Interface1
371
371
372
- Private Property Set Interface1_Foo(ByRef a As Variant)
372
+ Private Property Set Interface1_Foo(a As Variant)
373
373
Err.Raise 5 'TODO implement interface member
374
374
End Property
375
375
" ;
@@ -454,19 +454,19 @@ Private Sub Interface1_Foo(ByVal arg1 As Integer, ByVal arg2 As String)
454
454
Err.Raise 5 'TODO implement interface member
455
455
End Sub
456
456
457
- Private Function Interface1_Fizz(ByRef b As Variant) As Variant
457
+ Private Function Interface1_Fizz(b As Variant) As Variant
458
458
Err.Raise 5 'TODO implement interface member
459
459
End Function
460
460
461
461
Private Property Get Interface1_Buzz() As Variant
462
462
Err.Raise 5 'TODO implement interface member
463
463
End Property
464
464
465
- Private Property Let Interface1_Buzz(ByRef value As Variant)
465
+ Private Property Let Interface1_Buzz(value As Variant)
466
466
Err.Raise 5 'TODO implement interface member
467
467
End Property
468
468
469
- Private Property Set Interface1_Buzz(ByRef value As Variant)
469
+ Private Property Set Interface1_Buzz(value As Variant)
470
470
Err.Raise 5 'TODO implement interface member
471
471
End Property
472
472
" ;
@@ -554,6 +554,198 @@ End Property
554
554
ExecuteTest ( classCode , interfaceCode , expectedCode ) ;
555
555
}
556
556
557
+ [ Test ]
558
+ [ Category ( "Refactorings" ) ]
559
+ [ Category ( "Implement Interface" ) ]
560
+ public void ImplementInterface_ImplicitByRefParameter ( )
561
+ {
562
+ //Input
563
+ const string interfaceCode =
564
+ @"Public Sub Foo(arg As Variant)
565
+ End Sub" ;
566
+
567
+ const string classCode =
568
+ @"Implements Interface1" ;
569
+
570
+ //Expectation
571
+ const string expectedCode =
572
+ @"Implements Interface1
573
+
574
+ Private Sub Interface1_Foo(arg As Variant)
575
+ Err.Raise 5 'TODO implement interface member
576
+ End Sub
577
+ " ;
578
+ ExecuteTest ( classCode , interfaceCode , expectedCode ) ;
579
+ }
580
+
581
+ [ Test ]
582
+ [ Category ( "Refactorings" ) ]
583
+ [ Category ( "Implement Interface" ) ]
584
+ public void ImplementInterface_ExplicitByRefParameter ( )
585
+ {
586
+ //Input
587
+ const string interfaceCode =
588
+ @"Public Sub Foo(ByRef arg As Variant)
589
+ End Sub" ;
590
+
591
+ const string classCode =
592
+ @"Implements Interface1" ;
593
+
594
+ //Expectation
595
+ const string expectedCode =
596
+ @"Implements Interface1
597
+
598
+ Private Sub Interface1_Foo(ByRef arg As Variant)
599
+ Err.Raise 5 'TODO implement interface member
600
+ End Sub
601
+ " ;
602
+ ExecuteTest ( classCode , interfaceCode , expectedCode ) ;
603
+ }
604
+
605
+ [ Test ]
606
+ [ Category ( "Refactorings" ) ]
607
+ [ Category ( "Implement Interface" ) ]
608
+ public void ImplementInterface_ByValParameter ( )
609
+ {
610
+ //Input
611
+ const string interfaceCode =
612
+ @"Public Sub Foo(ByVal arg As Variant)
613
+ End Sub" ;
614
+
615
+ const string classCode =
616
+ @"Implements Interface1" ;
617
+
618
+ //Expectation
619
+ const string expectedCode =
620
+ @"Implements Interface1
621
+
622
+ Private Sub Interface1_Foo(ByVal arg As Variant)
623
+ Err.Raise 5 'TODO implement interface member
624
+ End Sub
625
+ " ;
626
+ ExecuteTest ( classCode , interfaceCode , expectedCode ) ;
627
+ }
628
+
629
+ [ Test ]
630
+ [ Category ( "Refactorings" ) ]
631
+ [ Category ( "Implement Interface" ) ]
632
+ public void ImplementInterface_OptionalParameter_WoDefault ( )
633
+ {
634
+ //Input
635
+ const string interfaceCode =
636
+ @"Public Sub Foo(Optional arg As Variant)
637
+ End Sub" ;
638
+
639
+ const string classCode =
640
+ @"Implements Interface1" ;
641
+
642
+ //Expectation
643
+ const string expectedCode =
644
+ @"Implements Interface1
645
+
646
+ Private Sub Interface1_Foo(Optional arg As Variant)
647
+ Err.Raise 5 'TODO implement interface member
648
+ End Sub
649
+ " ;
650
+ ExecuteTest ( classCode , interfaceCode , expectedCode ) ;
651
+ }
652
+
653
+ [ Test ]
654
+ [ Category ( "Refactorings" ) ]
655
+ [ Category ( "Implement Interface" ) ]
656
+ public void ImplementInterface_OptionalParameter_WithDefault ( )
657
+ {
658
+ //Input
659
+ const string interfaceCode =
660
+ @"Public Sub Foo(Optional arg As Variant = 42)
661
+ End Sub" ;
662
+
663
+ const string classCode =
664
+ @"Implements Interface1" ;
665
+
666
+ //Expectation
667
+ const string expectedCode =
668
+ @"Implements Interface1
669
+
670
+ Private Sub Interface1_Foo(Optional arg As Variant = 42)
671
+ Err.Raise 5 'TODO implement interface member
672
+ End Sub
673
+ " ;
674
+ ExecuteTest ( classCode , interfaceCode , expectedCode ) ;
675
+ }
676
+
677
+ [ Test ]
678
+ [ Category ( "Refactorings" ) ]
679
+ [ Category ( "Implement Interface" ) ]
680
+ public void ImplementInterface_ParamArray ( )
681
+ {
682
+ //Input
683
+ const string interfaceCode =
684
+ @"Public Sub Foo(arg1 As Long, ParamArray args() As Variant)
685
+ End Sub" ;
686
+
687
+ const string classCode =
688
+ @"Implements Interface1" ;
689
+
690
+ //Expectation
691
+ const string expectedCode =
692
+ @"Implements Interface1
693
+
694
+ Private Sub Interface1_Foo(arg1 As Long, ParamArray args() As Variant)
695
+ Err.Raise 5 'TODO implement interface member
696
+ End Sub
697
+ " ;
698
+ ExecuteTest ( classCode , interfaceCode , expectedCode ) ;
699
+ }
700
+
701
+ [ Test ]
702
+ [ Category ( "Refactorings" ) ]
703
+ [ Category ( "Implement Interface" ) ]
704
+ public void ImplementInterface_MakesMissingAsTypesExplicit ( )
705
+ {
706
+ //Input
707
+ const string interfaceCode =
708
+ @"Public Sub Foo(arg1)
709
+ End Sub" ;
710
+
711
+ const string classCode =
712
+ @"Implements Interface1" ;
713
+
714
+ //Expectation
715
+ const string expectedCode =
716
+ @"Implements Interface1
717
+
718
+ Private Sub Interface1_Foo(arg1 As Variant)
719
+ Err.Raise 5 'TODO implement interface member
720
+ End Sub
721
+ " ;
722
+ ExecuteTest ( classCode , interfaceCode , expectedCode ) ;
723
+ }
724
+
725
+ [ Test ]
726
+ [ Category ( "Refactorings" ) ]
727
+ [ Category ( "Implement Interface" ) ]
728
+ public void ImplementInterface_Array ( )
729
+ {
730
+ //Input
731
+ const string interfaceCode =
732
+ @"Public Sub Foo(arg1() As Long)
733
+ End Sub" ;
734
+
735
+ const string classCode =
736
+ @"Implements Interface1" ;
737
+
738
+ //Expectation
739
+ const string expectedCode =
740
+ @"Implements Interface1
741
+
742
+ Private Sub Interface1_Foo(arg1() As Long)
743
+ Err.Raise 5 'TODO implement interface member
744
+ End Sub
745
+ " ;
746
+ ExecuteTest ( classCode , interfaceCode , expectedCode ) ;
747
+ }
748
+
557
749
private void ExecuteTest ( string classCode , string interfaceCode , string expectedClassCode )
558
750
{
559
751
var refactoredCode = RefactoredCode (
0 commit comments