-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix code generation for methods with default arguments * Fix code generation for interfaces inheriting from other interfaces (#36) - Update the code generator to properly recognize and process inherited interfaces. - Add unit test to validate the changes. * use unified interface and run formatter * Fix code generation for methods with default arguments (#35) * move default argument tests to shared project * Fix code generation for interfaces with overloaded methods (#38) * Fix code generation for interfaces inheriting from other interfaces - Update the code generator to properly recognize and process inherited interfaces. - Add unit test to validate the changes. * Fix code generation for interfaces with overloaded methods --------- Co-authored-by: Karsten Heimrich <[email protected]> Co-authored-by: Karsten Heimrich <[email protected]>
- Loading branch information
1 parent
f5c5713
commit d06658b
Showing
14 changed files
with
433 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
src/MockMe.Generator/MockGenerators/TypeGenerators/InterfaceMockGenerator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
using System.Text; | ||
using Microsoft.CodeAnalysis; | ||
using MockMe.Generator.Extensions; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 21 additions & 3 deletions
24
tests/MockMe.Tests.ExampleClasses/Interfaces/ICalculator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,30 @@ | ||
namespace MockMe.Tests.ExampleClasses.Interfaces | ||
{ | ||
public interface ICalculator | ||
public interface IAddition | ||
{ | ||
CalculatorType CalculatorType { get; set; } | ||
int Add(int x, int y); | ||
} | ||
|
||
public interface ISubtraction | ||
{ | ||
int Subtract(int a, int b); | ||
} | ||
|
||
public interface IMultiplication | ||
{ | ||
double Multiply(double x, double y); | ||
} | ||
|
||
public interface IDivision | ||
{ | ||
int Divide(int a, int b); | ||
} | ||
|
||
public interface ICalculator : IAddition, ISubtraction, IMultiplication, IDivision | ||
{ | ||
CalculatorType CalculatorType { get; set; } | ||
void DivideByZero(double numToDivide); | ||
bool IsOn(); | ||
double Multiply(double x, double y); | ||
void TurnOff(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System; | ||
|
||
namespace MockMe.Tests.Overloads | ||
{ | ||
public enum EnumLong : long | ||
{ | ||
Unknown = 0, | ||
First = 1, | ||
} | ||
|
||
public interface AllDefaultArgs | ||
{ | ||
public void MethodWithBoolDefault(bool value = true); | ||
public void MethodWithConstStringDefault(string greeting = "Hello World"); | ||
public void MethodWithDateTimeDefault(DateTime date = default); | ||
public void MethodWithEnumDefault(DayOfWeek day = DayOfWeek.Monday); | ||
public void MethodWithEnumLongDefault(EnumLong value = EnumLong.First); | ||
public void MethodWithMultipleDefaults( | ||
double factor = 1, | ||
bool enabled = true, | ||
string label = "default" | ||
); | ||
public void MethodWithNullableDefault(int? arg = 15); | ||
public void MethodWithPrimitiveDefault(int i = 5); | ||
public void MethodWithStringDefault(string greeting = "Hello World"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.