diff --git a/Test.LightweightIocContainer/IocContainerInterfaceSegregationTest.cs b/Test.LightweightIocContainer/IocContainerInterfaceSegregationTest.cs index 91a5278..4f57d01 100644 --- a/Test.LightweightIocContainer/IocContainerInterfaceSegregationTest.cs +++ b/Test.LightweightIocContainer/IocContainerInterfaceSegregationTest.cs @@ -16,7 +16,6 @@ namespace Test.LightweightIocContainer private interface IBar { - void ThrowBar(); } private interface IFoo @@ -25,17 +24,14 @@ namespace Test.LightweightIocContainer } private interface IAnotherBar { - void ThrowAnotherBar(); } private interface IAnotherFoo { - void ThrowAnotherFoo(); } private interface IAnotherOne { - void ThrowAnotherOne(); } private class Foo : IFoo, IBar, IAnotherFoo, IAnotherBar, IAnotherOne @@ -44,26 +40,6 @@ namespace Test.LightweightIocContainer { throw new Exception("Foo"); } - - public void ThrowBar() - { - throw new Exception("Bar"); - } - - public void ThrowAnotherFoo() - { - throw new Exception("AnotherFoo"); - } - - public void ThrowAnotherBar() - { - throw new Exception("AnotherBar"); - } - - public void ThrowAnotherOne() - { - throw new Exception("AnotherOne"); - } } #endregion TestClasses @@ -85,67 +61,67 @@ namespace Test.LightweightIocContainer [Test] public void TestRegistrationOnCreate2() { - _container.Register().OnCreate(bar => bar.ThrowBar(), foo => foo.ThrowFoo()); + _container.Register().OnCreate(foo => foo.ThrowFoo()); Exception fooException = Assert.Throws(() => _container.Resolve()); Assert.AreEqual("Foo", fooException.Message); Exception barException = Assert.Throws(() => _container.Resolve()); - Assert.AreEqual("Bar", barException.Message); + Assert.AreEqual("Foo", barException.Message); } [Test] public void TestRegistrationOnCreate3() { - _container.Register().OnCreate(bar => bar.ThrowBar(), foo => foo.ThrowFoo(), anotherFoo => anotherFoo.ThrowAnotherFoo()); + _container.Register().OnCreate(foo => foo.ThrowFoo()); Exception fooException = Assert.Throws(() => _container.Resolve()); Assert.AreEqual("Foo", fooException.Message); Exception barException = Assert.Throws(() => _container.Resolve()); - Assert.AreEqual("Bar", barException.Message); + Assert.AreEqual("Foo", barException.Message); Exception anotherFooException = Assert.Throws(() => _container.Resolve()); - Assert.AreEqual("AnotherFoo", anotherFooException.Message); + Assert.AreEqual("Foo", anotherFooException.Message); } [Test] public void TestRegistrationOnCreate4() { - _container.Register().OnCreate(bar => bar.ThrowBar(), foo => foo.ThrowFoo(), anotherFoo => anotherFoo.ThrowAnotherFoo(), anotherBar => anotherBar.ThrowAnotherBar()); + _container.Register().OnCreate(foo => foo.ThrowFoo()); Exception fooException = Assert.Throws(() => _container.Resolve()); Assert.AreEqual("Foo", fooException.Message); Exception barException = Assert.Throws(() => _container.Resolve()); - Assert.AreEqual("Bar", barException.Message); + Assert.AreEqual("Foo", barException.Message); Exception anotherFooException = Assert.Throws(() => _container.Resolve()); - Assert.AreEqual("AnotherFoo", anotherFooException.Message); + Assert.AreEqual("Foo", anotherFooException.Message); Exception anotherBarException = Assert.Throws(() => _container.Resolve()); - Assert.AreEqual("AnotherBar", anotherBarException.Message); + Assert.AreEqual("Foo", anotherBarException.Message); } [Test] public void TestRegistrationOnCreate5() { - _container.Register().OnCreate(bar => bar.ThrowBar(), foo => foo.ThrowFoo(), anotherFoo => anotherFoo.ThrowAnotherFoo(), anotherBar => anotherBar.ThrowAnotherBar(), anotherOne => anotherOne.ThrowAnotherOne()); + _container.Register().OnCreate(foo => foo.ThrowFoo()); Exception fooException = Assert.Throws(() => _container.Resolve()); Assert.AreEqual("Foo", fooException.Message); Exception barException = Assert.Throws(() => _container.Resolve()); - Assert.AreEqual("Bar", barException.Message); + Assert.AreEqual("Foo", barException.Message); Exception anotherFooException = Assert.Throws(() => _container.Resolve()); - Assert.AreEqual("AnotherFoo", anotherFooException.Message); + Assert.AreEqual("Foo", anotherFooException.Message); Exception anotherBarException = Assert.Throws(() => _container.Resolve()); - Assert.AreEqual("AnotherBar", anotherBarException.Message); + Assert.AreEqual("Foo", anotherBarException.Message); Exception anotherOneException = Assert.Throws(() => _container.Resolve()); - Assert.AreEqual("AnotherOne", anotherOneException.Message); + Assert.AreEqual("Foo", anotherOneException.Message); } [Test] diff --git a/Test.LightweightIocContainer/OnCreateTest.cs b/Test.LightweightIocContainer/OnCreateTest.cs index 48cce75..6869986 100644 --- a/Test.LightweightIocContainer/OnCreateTest.cs +++ b/Test.LightweightIocContainer/OnCreateTest.cs @@ -3,7 +3,6 @@ // Copyright(c) 2019 SimonG. All Rights Reserved. using System; -using JetBrains.Annotations; using LightweightIocContainer; using LightweightIocContainer.Interfaces; using LightweightIocContainer.Interfaces.Registrations; @@ -23,16 +22,6 @@ namespace Test.LightweightIocContainer void DoSomething(); } - private interface IFoo - { - - } - - private interface IBar - { - - } - private class Test : ITest { public void DoSomething() @@ -41,27 +30,13 @@ namespace Test.LightweightIocContainer } } - [UsedImplicitly] - private class Foo : IFoo - { - public Foo(IBar bar, ITest test) - { - - } - } - - private class Bar : IBar - { - - } - #endregion [Test] public void TestOnCreate() { RegistrationFactory registrationFactory = new RegistrationFactory(new Mock().Object); - IDefaultRegistration testRegistration = (IDefaultRegistration) registrationFactory.Register(Lifestyle.Transient).OnCreate(t => t.DoSomething()); + ITypedRegistrationBase testRegistration = registrationFactory.Register(Lifestyle.Transient).OnCreate(t => t.DoSomething()); Test test = new Test();