|
|
|
@ -7,7 +7,7 @@ using LightweightIocContainer; |
|
|
|
using LightweightIocContainer.Exceptions; |
|
|
|
using LightweightIocContainer.Exceptions; |
|
|
|
using LightweightIocContainer.Registrations; |
|
|
|
using LightweightIocContainer.Registrations; |
|
|
|
using LightweightIocContainer.ResolvePlaceholders; |
|
|
|
using LightweightIocContainer.ResolvePlaceholders; |
|
|
|
using Moq; |
|
|
|
using NSubstitute; |
|
|
|
using NUnit.Framework; |
|
|
|
using NUnit.Framework; |
|
|
|
|
|
|
|
|
|
|
|
namespace Test.LightweightIocContainer; |
|
|
|
namespace Test.LightweightIocContainer; |
|
|
|
@ -53,7 +53,7 @@ public class RegistrationBaseTest |
|
|
|
[Test] |
|
|
|
[Test] |
|
|
|
public void TestWithParameters() |
|
|
|
public void TestWithParameters() |
|
|
|
{ |
|
|
|
{ |
|
|
|
RegistrationFactory registrationFactory = new(new Mock<IocContainer>().Object); |
|
|
|
RegistrationFactory registrationFactory = new(Substitute.For<IocContainer>()); |
|
|
|
|
|
|
|
|
|
|
|
IBar bar = new Bar(); |
|
|
|
IBar bar = new Bar(); |
|
|
|
ITest test = new Test(); |
|
|
|
ITest test = new Test(); |
|
|
|
@ -67,7 +67,7 @@ public class RegistrationBaseTest |
|
|
|
[Test] |
|
|
|
[Test] |
|
|
|
public void TestWithParametersDifferentOrder() |
|
|
|
public void TestWithParametersDifferentOrder() |
|
|
|
{ |
|
|
|
{ |
|
|
|
RegistrationFactory registrationFactory = new(new Mock<IocContainer>().Object); |
|
|
|
RegistrationFactory registrationFactory = new(Substitute.For<IocContainer>()); |
|
|
|
|
|
|
|
|
|
|
|
IBar bar = new Bar(); |
|
|
|
IBar bar = new Bar(); |
|
|
|
ITest test = new Test(); |
|
|
|
ITest test = new Test(); |
|
|
|
@ -83,7 +83,7 @@ public class RegistrationBaseTest |
|
|
|
[Test] |
|
|
|
[Test] |
|
|
|
public void TestWithParametersCalledTwice() |
|
|
|
public void TestWithParametersCalledTwice() |
|
|
|
{ |
|
|
|
{ |
|
|
|
RegistrationFactory registrationFactory = new(new Mock<IocContainer>().Object); |
|
|
|
RegistrationFactory registrationFactory = new(Substitute.For<IocContainer>()); |
|
|
|
Assert.Throws<InvalidRegistrationException>(() => registrationFactory.Register<IFoo, Foo>(Lifestyle.Transient).WithParameters(new Bar()).WithParameters(new Test())); |
|
|
|
Assert.Throws<InvalidRegistrationException>(() => registrationFactory.Register<IFoo, Foo>(Lifestyle.Transient).WithParameters(new Bar()).WithParameters(new Test())); |
|
|
|
Assert.Throws<InvalidRegistrationException>(() => registrationFactory.Register<IFoo, Foo>(Lifestyle.Transient).WithParameters((0, new Bar())).WithParameters((1, new Test()))); |
|
|
|
Assert.Throws<InvalidRegistrationException>(() => registrationFactory.Register<IFoo, Foo>(Lifestyle.Transient).WithParameters((0, new Bar())).WithParameters((1, new Test()))); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -91,7 +91,7 @@ public class RegistrationBaseTest |
|
|
|
[Test] |
|
|
|
[Test] |
|
|
|
public void TestWithParametersNoParametersGiven() |
|
|
|
public void TestWithParametersNoParametersGiven() |
|
|
|
{ |
|
|
|
{ |
|
|
|
RegistrationFactory registrationFactory = new(new Mock<IocContainer>().Object); |
|
|
|
RegistrationFactory registrationFactory = new(Substitute.For<IocContainer>()); |
|
|
|
Assert.Throws<InvalidRegistrationException>(() => registrationFactory.Register<IFoo, Foo>(Lifestyle.Transient).WithParameters((object[])null)); |
|
|
|
Assert.Throws<InvalidRegistrationException>(() => registrationFactory.Register<IFoo, Foo>(Lifestyle.Transient).WithParameters((object[])null)); |
|
|
|
Assert.Throws<InvalidRegistrationException>(() => registrationFactory.Register<IFoo, Foo>(Lifestyle.Transient).WithParameters(((int index, object parameter)[])null)); |
|
|
|
Assert.Throws<InvalidRegistrationException>(() => registrationFactory.Register<IFoo, Foo>(Lifestyle.Transient).WithParameters(((int index, object parameter)[])null)); |
|
|
|
} |
|
|
|
} |
|
|
|
|