-
-
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.
Releasing v4.0.6 with the fixed #171
removing the direct parameter injection of IContainer (and implemented interfaces) and always rely on registration - perf reason is not applied anymore - it is fast enough
- Loading branch information
Showing
7 changed files
with
83 additions
and
21 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
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
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
62 changes: 62 additions & 0 deletions
62
test/DryIoc.IssuesTests/GHIssue171_Wrong_IContainer_resolved.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,62 @@ | ||
using NUnit.Framework; | ||
|
||
namespace DryIoc.IssuesTests | ||
{ | ||
[TestFixture] | ||
public class GHIssue171_Wrong_IContainer_resolved | ||
{ | ||
[Test] | ||
public void Should_resolve_correct_registered_container_with_RegisterDelegate() | ||
{ | ||
var mainContainer = new Container(); | ||
var configureContainer = new Container(); | ||
|
||
configureContainer.RegisterDelegate<IContainer>(r => mainContainer, ifAlreadyRegistered: IfAlreadyRegistered.Replace); | ||
|
||
configureContainer.Register<Module>(); | ||
|
||
// init code ... | ||
configureContainer.Resolve<Module>().Register(); | ||
|
||
Assert.False(configureContainer.IsRegistered<IFoo>()); | ||
Assert.True(mainContainer.IsRegistered<IFoo>()); | ||
Assert.AreSame(configureContainer.Resolve<IContainer>(), mainContainer); | ||
} | ||
|
||
[Test] | ||
public void Should_resolve_correct_registered_container_with_Use() | ||
{ | ||
var mainContainer = new Container(); | ||
var configureContainer = new Container(); | ||
|
||
configureContainer.Use<IContainer>(mainContainer); | ||
|
||
configureContainer.Register<Module>(); | ||
|
||
// init code ... | ||
configureContainer.Resolve<Module>().Register(); | ||
|
||
Assert.False(configureContainer.IsRegistered<IFoo>()); | ||
Assert.True(mainContainer.IsRegistered<IFoo>()); | ||
Assert.AreSame(configureContainer.Resolve<IContainer>(), mainContainer); | ||
} | ||
|
||
class Module | ||
{ | ||
private readonly IContainer _container; | ||
public Module(IContainer container) => | ||
_container = container; | ||
|
||
public void Register() => | ||
_container.Register<IFoo, Foo>(); | ||
} | ||
|
||
public interface IFoo | ||
{ | ||
} | ||
|
||
public class Foo : IFoo | ||
{ | ||
} | ||
} | ||
} |