Skip to content

Commit 1236ccf

Browse files
committed
adding failed test for #672
1 parent 88b5dfa commit 1236ccf

4 files changed

+62
-6
lines changed

b.bat

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ echo:
1212
echo:# Build and Run TestRunners for %LatestSupportedNet% and .NET FRAMEWORK 4.7.2
1313
echo:
1414
echo:## %LatestSupportedNet%
15-
dotnet run -v:minimal -f:net8.0 -c:Release -p:GeneratePackageOnBuild=false --project test/DryIoc.TestRunner/DryIoc.TestRunner.csproj
15+
dotnet run -v:minimal -c:Release -f:net9.0 -p:LatestSupportedNet=net9.0 --project test/DryIoc.TestRunner/DryIoc.TestRunner.csproj
16+
1617
echo:
1718
echo:## .NET FRAMEWORK 4.7.2
18-
dotnet run -v:minimal -c:Release -p:GeneratePackageOnBuild=false --project test/DryIoc.TestRunner.net472/DryIoc.TestRunner.net472.csproj
19+
dotnet run -v:minimal -c:Release --project test/DryIoc.TestRunner.net472/DryIoc.TestRunner.net472.csproj
1920

2021
if %ERRORLEVEL% neq 0 goto :error
2122

test/DryIoc.IssuesTests/GHIssue669_Unable_to_resolve_type_with_optional_arguments_with_both_MefAttributedModel_and_MS_DI.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using NUnit.Framework;
2-
using DryIoc.ImTools;
32
using DryIoc.MefAttributedModel;
43
using DryIoc.Microsoft.DependencyInjection;
54

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using NUnit.Framework;
2+
using System;
3+
4+
namespace DryIoc.IssuesTests;
5+
6+
[TestFixture]
7+
public class GHIssue672_Wrong_decorator_parameter_with_custom_args : ITest
8+
{
9+
public int Run()
10+
{
11+
// Original_case();
12+
Case_without_args();
13+
return 2;
14+
}
15+
16+
public abstract class A { }
17+
public class B : A { }
18+
19+
private static object DecoratorA(object t) => t;
20+
21+
[Test]
22+
public void Original_case()
23+
{
24+
var now = DateTime.Now;
25+
26+
var container = new Container();
27+
28+
container.Register<object, B>(serviceKey: "xyz");
29+
30+
var decorateMethod = typeof(GHIssue672_Wrong_decorator_parameter_with_custom_args).SingleMethod(nameof(DecoratorA), true);
31+
32+
container.Register<object>(made: Made.Of(_ => decorateMethod), setup: Setup.DecoratorOf<A>());
33+
34+
var res = container.Resolve<object>("xyz", args: new object[] { now });
35+
36+
// Assert.IsInstanceOf<B>(res); // todo: @fixme
37+
}
38+
39+
[Test]
40+
public void Case_without_args()
41+
{
42+
var container = new Container();
43+
44+
container.Register<object, B>(serviceKey: "xyz");
45+
46+
var decorateMethod = typeof(GHIssue672_Wrong_decorator_parameter_with_custom_args).SingleMethod(nameof(DecoratorA), true);
47+
48+
container.Register<object>(made: Made.Of(_ => decorateMethod), setup: Setup.DecoratorOf<A>());
49+
50+
var res = container.Resolve<object>("xyz");
51+
52+
Assert.IsInstanceOf<B>(res);
53+
}
54+
}

test/DryIoc.TestRunner/Program.cs

+5-3
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ public class Program
99
{
1010
public static void Main()
1111
{
12-
Rules.UnsafeResetDefaultRulesToUseCompilationOnly();
13-
new GHIssue623_Scoped_service_decorator().Run();
12+
new GHIssue672_Wrong_decorator_parameter_with_custom_args().Run();
13+
14+
// Rules.UnsafeResetDefaultRulesToUseCompilationOnly();
15+
// new GHIssue623_Scoped_service_decorator().Run();
1416

15-
new GHIssue503_Compile_time_container().Run();
17+
// new GHIssue503_Compile_time_container().Run();
1618
// new GHIssue667_Resolve_with_serviceKey_does_not_invoke_factory_selector().Run();
1719

1820
RunAllTests();

0 commit comments

Comments
 (0)