-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(DependencyInjector): throw ArgumentNullException in SetDependency
- Loading branch information
Showing
3 changed files
with
53 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System; | ||
using NUnit.Framework; | ||
using UIComponents.Core; | ||
|
||
namespace UIComponents.Tests | ||
{ | ||
[TestFixture] | ||
public class DependencyInjectorTests | ||
{ | ||
private interface IDependency {} | ||
|
||
public class DependencyOne : IDependency {} | ||
|
||
public class DependencyTwo : IDependency {} | ||
|
||
[TestFixture] | ||
public class SetDependency | ||
{ | ||
[Test] | ||
public void Switches_The_Dependency() | ||
{ | ||
var injector = new DependencyInjector(); | ||
|
||
injector.SetDependency<IDependency>(new DependencyOne()); | ||
|
||
Assert.That(injector.Provide<IDependency>(), Is.InstanceOf<DependencyOne>()); | ||
|
||
injector.SetDependency<IDependency>(new DependencyTwo()); | ||
|
||
Assert.That(injector.Provide<IDependency>(), Is.InstanceOf<DependencyTwo>()); | ||
} | ||
|
||
[Test] | ||
public void Throws_Exception_If_Null_Is_Given_As_Parameter() | ||
{ | ||
var injector = new DependencyInjector(); | ||
|
||
Assert.Throws<ArgumentNullException>( | ||
() => injector.SetDependency<IDependency>(null) | ||
); | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.