-
-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
62 additions
and
6 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
..._Unable_to_resolve_type_with_optional_arguments_with_both_MefAttributedModel_and_MS_DI.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
54 changes: 54 additions & 0 deletions
54
test/DryIoc.IssuesTests/GHIssue672_Wrong_decorator_parameter_with_custom_args.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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using NUnit.Framework; | ||
using System; | ||
|
||
namespace DryIoc.IssuesTests; | ||
|
||
[TestFixture] | ||
public class GHIssue672_Wrong_decorator_parameter_with_custom_args : ITest | ||
{ | ||
public int Run() | ||
{ | ||
// Original_case(); | ||
Case_without_args(); | ||
return 2; | ||
} | ||
|
||
public abstract class A { } | ||
public class B : A { } | ||
|
||
private static object DecoratorA(object t) => t; | ||
|
||
[Test] | ||
public void Original_case() | ||
{ | ||
var now = DateTime.Now; | ||
|
||
var container = new Container(); | ||
|
||
container.Register<object, B>(serviceKey: "xyz"); | ||
|
||
var decorateMethod = typeof(GHIssue672_Wrong_decorator_parameter_with_custom_args).SingleMethod(nameof(DecoratorA), true); | ||
|
||
container.Register<object>(made: Made.Of(_ => decorateMethod), setup: Setup.DecoratorOf<A>()); | ||
|
||
var res = container.Resolve<object>("xyz", args: new object[] { now }); | ||
|
||
// Assert.IsInstanceOf<B>(res); // todo: @fixme | ||
} | ||
|
||
[Test] | ||
public void Case_without_args() | ||
{ | ||
var container = new Container(); | ||
|
||
container.Register<object, B>(serviceKey: "xyz"); | ||
|
||
var decorateMethod = typeof(GHIssue672_Wrong_decorator_parameter_with_custom_args).SingleMethod(nameof(DecoratorA), true); | ||
|
||
container.Register<object>(made: Made.Of(_ => decorateMethod), setup: Setup.DecoratorOf<A>()); | ||
|
||
var res = container.Resolve<object>("xyz"); | ||
|
||
Assert.IsInstanceOf<B>(res); | ||
} | ||
} |
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