Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Able to override inline dependencies with explicit args. Closes GH-519
- Loading branch information
1 parent
1a88b29
commit f7d08ce
Showing
4 changed files
with
74 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
60 changes: 60 additions & 0 deletions
60
src/StructureMap.Testing/Bugs/Bug_519_Uri_as_explicit_arg.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,60 @@ | ||
using System; | ||
using Shouldly; | ||
using Xunit; | ||
|
||
namespace StructureMap.Testing.Bugs | ||
{ | ||
public class Bug_519_Uri_as_explicit_arg | ||
{ | ||
[Fact] | ||
public void restclient_uri_should_not_be_null() | ||
{ | ||
var container = new Container(_ => | ||
{ | ||
_.ForConcreteType<RestClientTest>() | ||
.Configure | ||
.Ctor<string>("userAgent") | ||
.Is(() => "UA") | ||
.Ctor<Uri>("uri") | ||
.Is(() => null); | ||
}); | ||
|
||
|
||
var rc = container.With("uri").EqualTo(new Uri("http://www.google.com")).GetInstance<RestClientTest>(); | ||
|
||
rc.Uri.ShouldBe(new Uri("http://www.google.com")); | ||
} | ||
|
||
[Fact] | ||
public void restclient_uris_should_be_different() | ||
{ | ||
var container = new Container(_ => | ||
{ | ||
_.ForConcreteType<RestClientTest>() | ||
.Configure | ||
.Ctor<string>("userAgent") | ||
.Is(() => "UA") | ||
.Ctor<Uri>("uri") | ||
.Is(() => null); | ||
}); | ||
|
||
|
||
var rc1 = container.With("uri").EqualTo(new Uri("http://www.google.com")).GetInstance<RestClientTest>(); | ||
var rc2 = container.With("uri").EqualTo(new Uri("http://www.amazon.com")).GetInstance<RestClientTest>(); | ||
|
||
Assert.True(rc1.Uri.AbsoluteUri != rc2.Uri.AbsoluteUri); | ||
} | ||
|
||
public class RestClientTest | ||
{ | ||
public string UserAgent { get; set; } | ||
public Uri Uri { get; set; } | ||
|
||
public RestClientTest(string userAgent, Uri uri) | ||
{ | ||
UserAgent = userAgent; | ||
Uri = uri; | ||
} | ||
} | ||
} | ||
} |
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