Skip to content

Commit

Permalink
adding failed test for #672
Browse files Browse the repository at this point in the history
  • Loading branch information
dadhi committed Dec 26, 2024
1 parent 88b5dfa commit 1236ccf
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 6 deletions.
5 changes: 3 additions & 2 deletions b.bat
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ echo:
echo:# Build and Run TestRunners for %LatestSupportedNet% and .NET FRAMEWORK 4.7.2
echo:
echo:## %LatestSupportedNet%
dotnet run -v:minimal -f:net8.0 -c:Release -p:GeneratePackageOnBuild=false --project test/DryIoc.TestRunner/DryIoc.TestRunner.csproj
dotnet run -v:minimal -c:Release -f:net9.0 -p:LatestSupportedNet=net9.0 --project test/DryIoc.TestRunner/DryIoc.TestRunner.csproj

echo:
echo:## .NET FRAMEWORK 4.7.2
dotnet run -v:minimal -c:Release -p:GeneratePackageOnBuild=false --project test/DryIoc.TestRunner.net472/DryIoc.TestRunner.net472.csproj
dotnet run -v:minimal -c:Release --project test/DryIoc.TestRunner.net472/DryIoc.TestRunner.net472.csproj

if %ERRORLEVEL% neq 0 goto :error

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using NUnit.Framework;
using DryIoc.ImTools;
using DryIoc.MefAttributedModel;
using DryIoc.Microsoft.DependencyInjection;

Expand Down
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);
}
}
8 changes: 5 additions & 3 deletions test/DryIoc.TestRunner/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ public class Program
{
public static void Main()
{
Rules.UnsafeResetDefaultRulesToUseCompilationOnly();
new GHIssue623_Scoped_service_decorator().Run();
new GHIssue672_Wrong_decorator_parameter_with_custom_args().Run();

// Rules.UnsafeResetDefaultRulesToUseCompilationOnly();
// new GHIssue623_Scoped_service_decorator().Run();

new GHIssue503_Compile_time_container().Run();
// new GHIssue503_Compile_time_container().Run();
// new GHIssue667_Resolve_with_serviceKey_does_not_invoke_factory_selector().Run();

RunAllTests();
Expand Down

0 comments on commit 1236ccf

Please sign in to comment.