-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add InstanceResolver * revert comment --------- Co-authored-by: Casey White <[email protected]>
- Loading branch information
Casey White
and
Casey White
committed
Sep 27, 2023
1 parent
f2313d7
commit 5fe9df5
Showing
7 changed files
with
86 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
|
||
/.vs | ||
*.idea/ | ||
|
||
bin/ | ||
obj/ | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace Moq.AutoMock.Tests.Util; | ||
|
||
[ExcludeFromCodeCoverage] | ||
public sealed class SealedService | ||
{ | ||
public SealedService() { } | ||
} |
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,14 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace Moq.AutoMock.Tests.Util; | ||
|
||
[ExcludeFromCodeCoverage] | ||
public class WithSealedService | ||
{ | ||
public SealedService SealedService { get; set; } | ||
|
||
public WithSealedService(SealedService service) | ||
{ | ||
SealedService = service; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace Moq.AutoMock.Resolvers; | ||
|
||
/// <summary> | ||
/// A resolver that resolves requested types with a created instance. | ||
/// </summary> | ||
public class InstanceResolver : IMockResolver | ||
{ | ||
/// <summary> | ||
/// Resolves requested types with created instances. | ||
/// </summary> | ||
/// <param name="context">The resolution context.</param> | ||
public void Resolve(MockResolutionContext context) | ||
{ | ||
if (context.AutoMocker.CreateInstanceInternal(context.RequestType, context.ObjectGraphContext) is { } instance) | ||
{ | ||
context.Value = instance; | ||
} | ||
} | ||
} |