Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support for mimicking classes #4

Merged
merged 1 commit into from
Feb 22, 2024
Merged

feat: Support for mimicking classes #4

merged 1 commit into from
Feb 22, 2024

Conversation

DrBarnabus
Copy link
Owner

Adds support for mimicking classes along with the previously supported interfaces provided the class meets some criteria; non-static, non-sealed and accessible by the proxy generator.

Example usage (when class has a parameterless constructor):

var mimickedClass = new Mimic<ClassWithParameterlessConstructor>();

Example usage (when class needs constructor arguments):

var mimickedClass = new Mimic<ClassWithSpecificConstructor>
{
    ConstructorArguments = [1, "arg2", 3m, new object()]
};

Copy link

codecov bot commented Feb 21, 2024

Codecov Report

Attention: Patch coverage is 76.92308% with 12 lines in your changes are missing coverage. Please review.

Project coverage is 72.10%. Comparing base (6fdddd7) to head (67df33d).

Files Patch % Lines
src/Mimic/Mimic`1.cs 11.11% 7 Missing and 1 partial ⚠️
src/Mimic/Mimic`1.Setup.cs 0.00% 2 Missing ⚠️
...Mimic/Exceptions/UnsupportedExpressionException.cs 50.00% 1 Missing ⚠️
src/Mimic/Mimic`1.VerifyReceived.cs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main       #4      +/-   ##
==========================================
+ Coverage   71.65%   72.10%   +0.45%     
==========================================
  Files          60       60              
  Lines        1937     1972      +35     
  Branches      335      341       +6     
==========================================
+ Hits         1388     1422      +34     
- Misses        482      483       +1     
  Partials       67       67              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Adds support for mimicking classes along with the previously supported interfaces provided the class meets some criteria; non-static, non-sealed and accessible by the proxy generator.

Example usage (when class has a parameterless constructor):
```cs
var mimickedClass = new Mimic<ClassWithParameterlessConstructor>();
```

Example usage (when class needs constructor arguments):
```cs
var mimickedClass = new Mimic<ClassWithSpecificConstructor>
{
    ConstructorArguments = [1, "arg2", 3m, new object()]
};
```
@DrBarnabus DrBarnabus marked this pull request as ready for review February 22, 2024 21:32
@DrBarnabus DrBarnabus merged commit 26d73e9 into main Feb 22, 2024
20 checks passed
@DrBarnabus DrBarnabus deleted the mimic-of-classes branch February 22, 2024 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant