diff --git a/LightweightIocContainer/Exceptions/ConstructorNotMatchingException.cs b/LightweightIocContainer/Exceptions/ConstructorNotMatchingException.cs index 0b6c889..ef01735 100644 --- a/LightweightIocContainer/Exceptions/ConstructorNotMatchingException.cs +++ b/LightweightIocContainer/Exceptions/ConstructorNotMatchingException.cs @@ -18,10 +18,8 @@ namespace LightweightIocContainer.Exceptions /// The constructor that does not match /// The inner exception public ConstructorNotMatchingException(ConstructorInfo constructor, Exception exception) - : base($"Constructor {constructor} does not match the given or resolvable arguments.", exception) - { + : base($"Constructor {constructor} does not match the given or resolvable arguments.", exception) => Constructor = constructor; - } /// /// The constructor that does not match diff --git a/LightweightIocContainer/Exceptions/IllegalAbstractMethodCreationException.cs b/LightweightIocContainer/Exceptions/IllegalAbstractMethodCreationException.cs index 8aa95e1..fbafcb7 100644 --- a/LightweightIocContainer/Exceptions/IllegalAbstractMethodCreationException.cs +++ b/LightweightIocContainer/Exceptions/IllegalAbstractMethodCreationException.cs @@ -17,10 +17,8 @@ namespace LightweightIocContainer.Exceptions /// The exception message /// The method that is illegal to create public IllegalAbstractMethodCreationException(string message, MethodInfo method) - : base(message) - { + : base(message) => Method = method; - } /// /// The Method whose creation is illegal diff --git a/LightweightIocContainer/Exceptions/IocContainerException.cs b/LightweightIocContainer/Exceptions/IocContainerException.cs index 6309d28..2023355 100644 --- a/LightweightIocContainer/Exceptions/IocContainerException.cs +++ b/LightweightIocContainer/Exceptions/IocContainerException.cs @@ -37,13 +37,8 @@ namespace LightweightIocContainer.Exceptions /// The message of the /// The inner protected IocContainerException(string message, Exception innerException) - : base(message, innerException) - { - InnerExceptions = new List() - { - innerException - }; - } + : base(message, innerException) => + InnerExceptions = new List() {innerException}; /// /// The inner exceptions of the diff --git a/LightweightIocContainer/Exceptions/MultipleRegistrationException.cs b/LightweightIocContainer/Exceptions/MultipleRegistrationException.cs index ce7e473..b37f3e8 100644 --- a/LightweightIocContainer/Exceptions/MultipleRegistrationException.cs +++ b/LightweightIocContainer/Exceptions/MultipleRegistrationException.cs @@ -17,10 +17,8 @@ namespace LightweightIocContainer.Exceptions /// /// The that is already registered in this public MultipleRegistrationException(Type type) - : base($"Type {type.Name} is already registered in this IocContainer.") - { + : base($"Type {type.Name} is already registered in this IocContainer.") => Type = type; - } /// /// The registered diff --git a/LightweightIocContainer/Exceptions/MultitonResolveException.cs b/LightweightIocContainer/Exceptions/MultitonResolveException.cs index 9d15714..b7034a0 100644 --- a/LightweightIocContainer/Exceptions/MultitonResolveException.cs +++ b/LightweightIocContainer/Exceptions/MultitonResolveException.cs @@ -17,10 +17,8 @@ namespace LightweightIocContainer.Exceptions /// The exception message /// The of the multiton that's responsible for the exception public MultitonResolveException(string message, Type type) - : base(message) - { + : base(message) => Type = type; - } /// /// The of the multiton that's responsible for the exception diff --git a/LightweightIocContainer/Exceptions/NoMatchingConstructorFoundException.cs b/LightweightIocContainer/Exceptions/NoMatchingConstructorFoundException.cs index c91391b..1c9e080 100644 --- a/LightweightIocContainer/Exceptions/NoMatchingConstructorFoundException.cs +++ b/LightweightIocContainer/Exceptions/NoMatchingConstructorFoundException.cs @@ -22,11 +22,7 @@ namespace LightweightIocContainer.Exceptions : base($"No matching constructor for {type} found.") { Type = type; - - if (exceptions == null) - InnerExceptions = new List(); - else - InnerExceptions = exceptions.OfType().ToList(); + InnerExceptions = exceptions == null ? new List() : exceptions.OfType().ToList(); } @@ -39,9 +35,6 @@ namespace LightweightIocContainer.Exceptions /// Add an inner exception to the /// /// The - public void AddInnerException(ConstructorNotMatchingException exception) - { - InnerExceptions.Add(exception); - } + public void AddInnerException(ConstructorNotMatchingException exception) => InnerExceptions.Add(exception); } } \ No newline at end of file diff --git a/LightweightIocContainer/Exceptions/NoPublicConstructorFoundException.cs b/LightweightIocContainer/Exceptions/NoPublicConstructorFoundException.cs index 79f3dbd..932b020 100644 --- a/LightweightIocContainer/Exceptions/NoPublicConstructorFoundException.cs +++ b/LightweightIocContainer/Exceptions/NoPublicConstructorFoundException.cs @@ -16,10 +16,8 @@ namespace LightweightIocContainer.Exceptions /// /// The with no public constructor public NoPublicConstructorFoundException(Type type) - : base($"No public constructor for {type} found.") - { + : base($"No public constructor for {type} found.") => Type = type; - } /// /// The with no public constructor diff --git a/LightweightIocContainer/Exceptions/TypeNotRegisteredException.cs b/LightweightIocContainer/Exceptions/TypeNotRegisteredException.cs index 9b075ad..11056b7 100644 --- a/LightweightIocContainer/Exceptions/TypeNotRegisteredException.cs +++ b/LightweightIocContainer/Exceptions/TypeNotRegisteredException.cs @@ -17,10 +17,8 @@ namespace LightweightIocContainer.Exceptions /// /// The unregistered public TypeNotRegisteredException(Type type) - : base($"Type {type.Name} is not registered in this IocContainer.") - { + : base($"Type {type.Name} is not registered in this IocContainer.") => Type = type; - } /// /// The unregistered diff --git a/LightweightIocContainer/Installers/FromAssembly.cs b/LightweightIocContainer/Installers/FromAssembly.cs index 1eafbb9..c13f2dd 100644 --- a/LightweightIocContainer/Installers/FromAssembly.cs +++ b/LightweightIocContainer/Installers/FromAssembly.cs @@ -27,9 +27,6 @@ namespace LightweightIocContainer.Installers /// /// The given /// A new with the given - public static IAssemblyInstaller Instance(Assembly assembly) - { - return new AssemblyInstaller(assembly); - } + public static IAssemblyInstaller Instance(Assembly assembly) => new AssemblyInstaller(assembly); } } \ No newline at end of file diff --git a/LightweightIocContainer/IocContainer.cs b/LightweightIocContainer/IocContainer.cs index 0382121..67a1b77 100644 --- a/LightweightIocContainer/IocContainer.cs +++ b/LightweightIocContainer/IocContainer.cs @@ -32,11 +32,7 @@ namespace LightweightIocContainer /// /// The main container that carries all the s and can resolve all the types you'll ever want /// - public IocContainer() - { - _registrationFactory = new RegistrationFactory(this); - } - + public IocContainer() => _registrationFactory = new RegistrationFactory(this); /// /// Install the given installers for the current @@ -259,10 +255,7 @@ namespace LightweightIocContainer /// /// The given /// An instance of the given - public T Resolve() - { - return ResolveInternal(null); - } + public T Resolve() => ResolveInternal(null); /// /// Gets an instance of the given @@ -270,10 +263,7 @@ namespace LightweightIocContainer /// The given /// The constructor arguments /// An instance of the given - public T Resolve(params object[] arguments) - { - return ResolveInternal(arguments); - } + public T Resolve(params object[] arguments) => ResolveInternal(arguments); /// /// Gets an instance of the given @@ -283,10 +273,8 @@ namespace LightweightIocContainer /// The current resolve stack /// An instance of the given /// Could not find function - private object Resolve(Type type, object[] arguments, List resolveStack) - { - return GenericMethodCaller.Call(this, nameof(ResolveInternal), type, BindingFlags.NonPublic | BindingFlags.Instance, arguments, resolveStack); - } + private object Resolve(Type type, object[] arguments, List resolveStack) => + GenericMethodCaller.Call(this, nameof(ResolveInternal), type, BindingFlags.NonPublic | BindingFlags.Instance, arguments, resolveStack); /// /// Gets an instance of a given registered @@ -582,9 +570,7 @@ namespace LightweightIocContainer } catch (Exception ex) { - if (noMatchingConstructorFoundException == null) - noMatchingConstructorFoundException = new NoMatchingConstructorFoundException(type); - + noMatchingConstructorFoundException ??= new NoMatchingConstructorFoundException(type); noMatchingConstructorFoundException.AddInnerException(new ConstructorNotMatchingException(ctor, ex)); } } diff --git a/LightweightIocContainer/Registrations/DefaultRegistration.cs b/LightweightIocContainer/Registrations/DefaultRegistration.cs index 09d5307..0b4917f 100644 --- a/LightweightIocContainer/Registrations/DefaultRegistration.cs +++ b/LightweightIocContainer/Registrations/DefaultRegistration.cs @@ -21,9 +21,7 @@ namespace LightweightIocContainer.Registrations /// The of the implementation /// The of the public DefaultRegistration(Type interfaceType, Type implementationType, Lifestyle lifestyle) - : base(interfaceType, implementationType, lifestyle) - { + : base(interfaceType, implementationType, lifestyle) => Name = $"{InterfaceType.Name}, {ImplementationType.Name}, Lifestyle: {Lifestyle.ToString()}"; - } } } \ No newline at end of file diff --git a/LightweightIocContainer/Registrations/MultitonRegistration.cs b/LightweightIocContainer/Registrations/MultitonRegistration.cs index 1e479e5..e49130b 100644 --- a/LightweightIocContainer/Registrations/MultitonRegistration.cs +++ b/LightweightIocContainer/Registrations/MultitonRegistration.cs @@ -21,10 +21,8 @@ namespace LightweightIocContainer.Registrations /// The of the Implementation /// The of the Multiton Scope public MultitonRegistration(Type interfaceType, Type implementationType, Type scope) - : base(interfaceType, implementationType, Lifestyle.Multiton) - { + : base(interfaceType, implementationType, Lifestyle.Multiton) => Scope = scope; - } /// /// The of the multiton scope diff --git a/LightweightIocContainer/Registrations/RegistrationFactory.cs b/LightweightIocContainer/Registrations/RegistrationFactory.cs index 03913e5..663abfa 100644 --- a/LightweightIocContainer/Registrations/RegistrationFactory.cs +++ b/LightweightIocContainer/Registrations/RegistrationFactory.cs @@ -16,10 +16,7 @@ namespace LightweightIocContainer.Registrations { private readonly IIocContainer _iocContainer; - internal RegistrationFactory(IIocContainer container) - { - _iocContainer = container; - } + internal RegistrationFactory(IIocContainer container) => _iocContainer = container; /// /// Register an Interface with a Type that implements it and create a @@ -28,16 +25,18 @@ namespace LightweightIocContainer.Registrations /// The Type that implements the interface /// The for this /// A new created with the given parameters - public IDefaultRegistration Register(Lifestyle lifestyle) where TImplementation : TInterface - { - return new DefaultRegistration(typeof(TInterface), typeof(TImplementation), lifestyle); - } + public IDefaultRegistration Register(Lifestyle lifestyle) where TImplementation : TInterface => + new DefaultRegistration(typeof(TInterface), typeof(TImplementation), lifestyle); + + /// + /// Register an open generic Interface with an open generic Type that implements it and create a + /// + /// The open generic Interface to register + /// The open generic Type that implements the interface + /// The for this + /// The created + public IOpenGenericRegistration Register(Type tInterface, Type tImplementation, Lifestyle lifestyle) => new OpenGenericRegistration(tInterface, tImplementation, lifestyle); - public IOpenGenericRegistration Register(Type tInterface, Type tImplementation, Lifestyle lifestyle) - { - return new OpenGenericRegistration(tInterface, tImplementation, lifestyle); - } - /// /// Register multiple interfaces for a that implements them and create a /// @@ -46,10 +45,8 @@ namespace LightweightIocContainer.Registrations /// The that implements both interfaces /// The for this /// The created - public IMultipleRegistration Register(Lifestyle lifestyle) where TImplementation : TInterface1, TInterface2 - { - return new MultipleRegistration(typeof(TInterface1), typeof(TInterface2), typeof(TImplementation), lifestyle); - } + public IMultipleRegistration Register(Lifestyle lifestyle) where TImplementation : TInterface1, TInterface2 => + new MultipleRegistration(typeof(TInterface1), typeof(TInterface2), typeof(TImplementation), lifestyle); /// /// Register multiple interfaces for a that implements them and create a @@ -60,10 +57,8 @@ namespace LightweightIocContainer.Registrations /// The that implements both interfaces /// The for this /// The created - public IMultipleRegistration Register(Lifestyle lifestyle) where TImplementation : TInterface1, TInterface2, TInterface3 - { - return new MultipleRegistration(typeof(TInterface1), typeof(TInterface2), typeof(TInterface3), typeof(TImplementation), lifestyle); - } + public IMultipleRegistration Register(Lifestyle lifestyle) where TImplementation : TInterface1, TInterface2, TInterface3 => + new MultipleRegistration(typeof(TInterface1), typeof(TInterface2), typeof(TInterface3), typeof(TImplementation), lifestyle); /// /// Register multiple interfaces for a that implements them and create a @@ -75,10 +70,8 @@ namespace LightweightIocContainer.Registrations /// The that implements both interfaces /// The for this /// The created - public IMultipleRegistration Register(Lifestyle lifestyle) where TImplementation : TInterface1, TInterface2, TInterface3, TInterface4 - { - return new MultipleRegistration(typeof(TInterface1), typeof(TInterface2), typeof(TInterface3), typeof(TInterface4), typeof(TImplementation), lifestyle); - } + public IMultipleRegistration Register(Lifestyle lifestyle) where TImplementation : TInterface1, TInterface2, TInterface3, TInterface4 => + new MultipleRegistration(typeof(TInterface1), typeof(TInterface2), typeof(TInterface3), typeof(TInterface4), typeof(TImplementation), lifestyle); /// /// Register multiple interfaces for a that implements them and create a @@ -91,10 +84,8 @@ namespace LightweightIocContainer.Registrations /// The that implements both interfaces /// The for this /// The created - public IMultipleRegistration Register(Lifestyle lifestyle) where TImplementation : TInterface1, TInterface2, TInterface3, TInterface4, TInterface5 - { - return new MultipleRegistration(typeof(TInterface1), typeof(TInterface2), typeof(TInterface3), typeof(TInterface4), typeof(TInterface5), typeof(TImplementation), lifestyle); - } + public IMultipleRegistration Register(Lifestyle lifestyle) where TImplementation : TInterface1, TInterface2, TInterface3, TInterface4, TInterface5 => + new MultipleRegistration(typeof(TInterface1), typeof(TInterface2), typeof(TInterface3), typeof(TInterface4), typeof(TInterface5), typeof(TImplementation), lifestyle); /// /// Register a without an interface and create a @@ -102,10 +93,7 @@ namespace LightweightIocContainer.Registrations /// The to register /// The for this /// A new created with the given parameters - public ISingleTypeRegistration Register(Lifestyle lifestyle) - { - return new SingleTypeRegistration(typeof(T), lifestyle); - } + public ISingleTypeRegistration Register(Lifestyle lifestyle) => new SingleTypeRegistration(typeof(T), lifestyle); /// /// Register an Interface with a Type that implements it as a multiton and create a @@ -114,10 +102,8 @@ namespace LightweightIocContainer.Registrations /// The Type that implements the interface /// The Type of the multiton scope /// A new created with the given parameters - public IMultitonRegistration RegisterMultiton() where TImplementation : TInterface - { - return new MultitonRegistration(typeof(TInterface), typeof(TImplementation), typeof(TScope)); - } + public IMultitonRegistration RegisterMultiton() where TImplementation : TInterface => + new MultitonRegistration(typeof(TInterface), typeof(TImplementation), typeof(TScope)); /// /// Register multiple interfaces for a that implements them as a multiton @@ -127,19 +113,14 @@ namespace LightweightIocContainer.Registrations /// The Type that implements the interface /// The Type of the multiton scope /// A new created with the given parameters - public IMultipleMultitonRegistration RegisterMultiton() where TImplementation : TInterface1, TInterface2 - { - return new MultipleMultitonRegistration(typeof(TInterface1), typeof(TInterface2), typeof(TImplementation), typeof(TScope)); - } + public IMultipleMultitonRegistration RegisterMultiton() where TImplementation : TInterface1, TInterface2 => + new MultipleMultitonRegistration(typeof(TInterface1), typeof(TInterface2), typeof(TImplementation), typeof(TScope)); /// /// Register an Interface as an abstract typed factory and create a /// /// The abstract typed factory to register /// A new created with the given parameters - public ITypedFactoryRegistration RegisterFactory() - { - return new TypedFactoryRegistration(typeof(TFactory), _iocContainer); - } + public ITypedFactoryRegistration RegisterFactory() => new TypedFactoryRegistration(typeof(TFactory), _iocContainer); } } \ No newline at end of file diff --git a/LightweightIocContainer/Registrations/SingleTypeRegistration.cs b/LightweightIocContainer/Registrations/SingleTypeRegistration.cs index 7a961c3..ee7da72 100644 --- a/LightweightIocContainer/Registrations/SingleTypeRegistration.cs +++ b/LightweightIocContainer/Registrations/SingleTypeRegistration.cs @@ -20,10 +20,8 @@ namespace LightweightIocContainer.Registrations /// The of the interface or /// The of the public SingleTypeRegistration(Type interfaceType, Lifestyle lifestyle) - : base(interfaceType, lifestyle) - { + : base(interfaceType, lifestyle) => Name = $"{InterfaceType.Name}, Lifestyle: {Lifestyle.ToString()}"; - } /// /// that is invoked instead of creating an instance of this the default way diff --git a/LightweightIocContainer/Registrations/TypedRegistrationBase.cs b/LightweightIocContainer/Registrations/TypedRegistrationBase.cs index 68d359c..4bd1a9d 100644 --- a/LightweightIocContainer/Registrations/TypedRegistrationBase.cs +++ b/LightweightIocContainer/Registrations/TypedRegistrationBase.cs @@ -21,10 +21,8 @@ namespace LightweightIocContainer.Registrations /// The of the implementation type /// The of this protected TypedRegistrationBase(Type interfaceType, Type implementationType, Lifestyle lifestyle) - : base(interfaceType, lifestyle) - { + : base(interfaceType, lifestyle) => ImplementationType = implementationType; - } /// /// The that implements the that is registered with this diff --git a/Test.LightweightIocContainer/ActionExtensionTest.cs b/Test.LightweightIocContainer/ActionExtensionTest.cs index 3ebce77..7c358cc 100644 --- a/Test.LightweightIocContainer/ActionExtensionTest.cs +++ b/Test.LightweightIocContainer/ActionExtensionTest.cs @@ -11,8 +11,6 @@ namespace Test.LightweightIocContainer [TestFixture] public class ActionExtensionTest { - #region TestClasses - private interface IBar { void Throw(); @@ -25,13 +23,9 @@ namespace Test.LightweightIocContainer private class Foo : IFoo { - public void Throw() - { - throw new Exception(); - } + public void Throw() => throw new Exception(); } - - #endregion TestClasses + [Test] public void TestConvert() diff --git a/Test.LightweightIocContainer/AssemblyInstallerTest.cs b/Test.LightweightIocContainer/AssemblyInstallerTest.cs index c605328..09f005a 100644 --- a/Test.LightweightIocContainer/AssemblyInstallerTest.cs +++ b/Test.LightweightIocContainer/AssemblyInstallerTest.cs @@ -19,14 +19,9 @@ namespace Test.LightweightIocContainer [TestFixture] public class AssemblyInstallerTest { - #region TestClasses - private class TestInstaller : IIocInstaller { - public void Install(IIocContainer container) - { - container.Register>(); - } + public void Install(IIocContainer container) => container.Register>(); } [UsedImplicitly] @@ -35,8 +30,7 @@ namespace Test.LightweightIocContainer } - #endregion TestClasses - + [Test] public void TestInstall() { diff --git a/Test.LightweightIocContainer/EnumerableExtensionTest.cs b/Test.LightweightIocContainer/EnumerableExtensionTest.cs index 0540ac2..29dca2b 100644 --- a/Test.LightweightIocContainer/EnumerableExtensionTest.cs +++ b/Test.LightweightIocContainer/EnumerableExtensionTest.cs @@ -12,8 +12,6 @@ namespace Test.LightweightIocContainer [TestFixture] public class EnumerableExtensionTest { - #region TestClasses - private class ListObject { public int Index { get; set; } @@ -24,8 +22,6 @@ namespace Test.LightweightIocContainer } - #endregion TestClasses - [Test] [SuppressMessage("ReSharper", "CollectionNeverUpdated.Local")] diff --git a/Test.LightweightIocContainer/IocContainerInterfaceSegregationTest.cs b/Test.LightweightIocContainer/IocContainerInterfaceSegregationTest.cs index 4f57d01..485002a 100644 --- a/Test.LightweightIocContainer/IocContainerInterfaceSegregationTest.cs +++ b/Test.LightweightIocContainer/IocContainerInterfaceSegregationTest.cs @@ -3,6 +3,7 @@ // Copyright(c) 2019 SimonG. All Rights Reserved. using System; +using JetBrains.Annotations; using LightweightIocContainer; using LightweightIocContainer.Interfaces; using NUnit.Framework; @@ -12,10 +13,9 @@ namespace Test.LightweightIocContainer [TestFixture] public class IocContainerInterfaceSegregationTest { - #region TestClasses - private interface IBar { + } private interface IFoo @@ -24,39 +24,33 @@ namespace Test.LightweightIocContainer } private interface IAnotherBar { + } private interface IAnotherFoo { + } private interface IAnotherOne { + } + [UsedImplicitly] private class Foo : IFoo, IBar, IAnotherFoo, IAnotherBar, IAnotherOne { - public void ThrowFoo() - { - throw new Exception("Foo"); - } + public void ThrowFoo() => throw new Exception("Foo"); } - #endregion TestClasses private IIocContainer _container; [SetUp] - public void SetUp() - { - _container = new IocContainer(); - } + public void SetUp() => _container = new IocContainer(); [TearDown] - public void TearDown() - { - _container.Dispose(); - } + public void TearDown() => _container.Dispose(); [Test] public void TestRegistrationOnCreate2() diff --git a/Test.LightweightIocContainer/IocContainerParameterRegistrationTest.cs b/Test.LightweightIocContainer/IocContainerParameterRegistrationTest.cs index be23d2e..88b700c 100644 --- a/Test.LightweightIocContainer/IocContainerParameterRegistrationTest.cs +++ b/Test.LightweightIocContainer/IocContainerParameterRegistrationTest.cs @@ -13,8 +13,6 @@ namespace Test.LightweightIocContainer // ReSharper disable MemberHidesStaticFromOuterClass public class IocContainerParameterRegistrationTest { - #region TestClasses - [UsedImplicitly] public interface IA { @@ -61,6 +59,7 @@ namespace Test.LightweightIocContainer { public B(IC c) { + } } @@ -87,22 +86,14 @@ namespace Test.LightweightIocContainer public IC C { get; } } - #endregion TestClasses - + private IIocContainer _iocContainer; [SetUp] - public void SetUp() - { - _iocContainer = new IocContainer(); - } - + public void SetUp() => _iocContainer = new IocContainer(); [TearDown] - public void TearDown() - { - _iocContainer.Dispose(); - } + public void TearDown() => _iocContainer.Dispose(); [Test] diff --git a/Test.LightweightIocContainer/IocContainerRecursionTest.cs b/Test.LightweightIocContainer/IocContainerRecursionTest.cs index 0e3e772..d34d3b4 100644 --- a/Test.LightweightIocContainer/IocContainerRecursionTest.cs +++ b/Test.LightweightIocContainer/IocContainerRecursionTest.cs @@ -14,8 +14,6 @@ namespace Test.LightweightIocContainer [TestFixture] public class IocContainerRecursionTest { - #region TestClassesCircularDependency - [UsedImplicitly] public interface IFoo { @@ -44,10 +42,6 @@ namespace Test.LightweightIocContainer } } - #endregion TestClassesCircularDependency - - #region TestClassesNonCircularDependency - [UsedImplicitly] public interface IA { @@ -71,6 +65,7 @@ namespace Test.LightweightIocContainer { public A(IB b, IC c) { + } } @@ -79,6 +74,7 @@ namespace Test.LightweightIocContainer { public B(IC c) { + } } @@ -88,23 +84,14 @@ namespace Test.LightweightIocContainer } - #endregion TestClassesNonCircularDependency - - private IIocContainer _iocContainer; [SetUp] - public void SetUp() - { - _iocContainer = new IocContainer(); - } + public void SetUp() => _iocContainer = new IocContainer(); [TearDown] - public void TearDown() - { - _iocContainer.Dispose(); - } + public void TearDown() => _iocContainer.Dispose(); [Test] public void TestCircularDependencies() diff --git a/Test.LightweightIocContainer/IocContainerTest.cs b/Test.LightweightIocContainer/IocContainerTest.cs index 3812233..19c22a0 100644 --- a/Test.LightweightIocContainer/IocContainerTest.cs +++ b/Test.LightweightIocContainer/IocContainerTest.cs @@ -11,9 +11,6 @@ namespace Test.LightweightIocContainer [TestFixture] public class IocContainerTest { - #region TestClasses - //some of the test classes have to be public to allow the implementation of the factory - public interface ITest { @@ -101,10 +98,7 @@ namespace Test.LightweightIocContainer [UsedImplicitly] private readonly byte _id; - public TestByte(byte id) - { - _id = id; - } + public TestByte(byte id) => _id = id; } [UsedImplicitly] @@ -118,23 +112,14 @@ namespace Test.LightweightIocContainer } - #endregion TestClasses - private IIocContainer _iocContainer; [SetUp] - public void SetUp() - { - _iocContainer = new IocContainer(); - } - + public void SetUp() => _iocContainer = new IocContainer(); [TearDown] - public void TearDown() - { - _iocContainer.Dispose(); - } + public void TearDown() => _iocContainer.Dispose(); [Test] @@ -165,34 +150,19 @@ namespace Test.LightweightIocContainer } [Test] - public void TestRegister() - { - Assert.DoesNotThrow(() => _iocContainer.Register()); - } + public void TestRegister() => Assert.DoesNotThrow(() => _iocContainer.Register()); [Test] - public void TestRegisterTypeWithoutInterface() - { - Assert.DoesNotThrow(() => _iocContainer.Register()); - } + public void TestRegisterTypeWithoutInterface() => Assert.DoesNotThrow(() => _iocContainer.Register()); [Test] - public void TestRegisterMultiton() - { - Assert.DoesNotThrow(() => _iocContainer.RegisterMultiton()); - } + public void TestRegisterMultiton() => Assert.DoesNotThrow(() => _iocContainer.RegisterMultiton()); [Test] - public void TestInvalidMultitonRegistration() - { - Assert.Throws(() => _iocContainer.Register(Lifestyle.Multiton)); - } + public void TestInvalidMultitonRegistration() => Assert.Throws(() => _iocContainer.Register(Lifestyle.Multiton)); [Test] - public void TestRegisterFactory() - { - Assert.DoesNotThrow(() => _iocContainer.RegisterFactory()); - } + public void TestRegisterFactory() => Assert.DoesNotThrow(() => _iocContainer.RegisterFactory()); [Test] public void TestRegisterMultiple() @@ -203,16 +173,10 @@ namespace Test.LightweightIocContainer } [Test] - public void TestRegisterFactoryWithoutCreate() - { - Assert.Throws(() => _iocContainer.RegisterFactory()); - } + public void TestRegisterFactoryWithoutCreate() => Assert.Throws(() => _iocContainer.RegisterFactory()); [Test] - public void TestRegisterFactoryClearMultitonsNonGeneric() - { - Assert.Throws(() => _iocContainer.RegisterFactory()); - } + public void TestRegisterFactoryClearMultitonsNonGeneric() => Assert.Throws(() => _iocContainer.RegisterFactory()); [Test] public void TestResolveNotRegistered() diff --git a/Test.LightweightIocContainer/OnCreateTest.cs b/Test.LightweightIocContainer/OnCreateTest.cs index 6869986..12c197b 100644 --- a/Test.LightweightIocContainer/OnCreateTest.cs +++ b/Test.LightweightIocContainer/OnCreateTest.cs @@ -15,8 +15,6 @@ namespace Test.LightweightIocContainer [TestFixture] public class OnCreateTest { - #region TestClasses - private interface ITest { void DoSomething(); @@ -24,14 +22,10 @@ namespace Test.LightweightIocContainer private class Test : ITest { - public void DoSomething() - { - throw new Exception(); - } + public void DoSomething() => throw new Exception(); } - #endregion - + [Test] public void TestOnCreate() { diff --git a/Test.LightweightIocContainer/OpenGenericRegistrationTest.cs b/Test.LightweightIocContainer/OpenGenericRegistrationTest.cs index e1b87d7..84d6b74 100644 --- a/Test.LightweightIocContainer/OpenGenericRegistrationTest.cs +++ b/Test.LightweightIocContainer/OpenGenericRegistrationTest.cs @@ -60,11 +60,11 @@ namespace Test.LightweightIocContainer } [Test] - public void TestRegisterOpenGenericTypeAsMultitonThrowsException() - => Assert.Throws(() => _iocContainer.RegisterOpenGenerics(typeof(ITest<>), typeof(Test<>), Lifestyle.Multiton)); + public void TestRegisterOpenGenericTypeAsMultitonThrowsException() => + Assert.Throws(() => _iocContainer.RegisterOpenGenerics(typeof(ITest<>), typeof(Test<>), Lifestyle.Multiton)); [Test] - public void TestRegisterNonOpenGenericTypeWithOpenGenericsFunctionThrowsException() - => Assert.Throws(() => _iocContainer.RegisterOpenGenerics(typeof(int), typeof(int))); + public void TestRegisterNonOpenGenericTypeWithOpenGenericsFunctionThrowsException() => + Assert.Throws(() => _iocContainer.RegisterOpenGenerics(typeof(int), typeof(int))); } } \ No newline at end of file diff --git a/Test.LightweightIocContainer/RegistrationBaseTest.cs b/Test.LightweightIocContainer/RegistrationBaseTest.cs index fcf6c4f..2169223 100644 --- a/Test.LightweightIocContainer/RegistrationBaseTest.cs +++ b/Test.LightweightIocContainer/RegistrationBaseTest.cs @@ -16,8 +16,6 @@ namespace Test.LightweightIocContainer [TestFixture] public class RegistrationBaseTest { - #region TestClasses - private interface ITest { @@ -52,8 +50,6 @@ namespace Test.LightweightIocContainer } - #endregion - [Test] public void TestWithParameters() diff --git a/Test.LightweightIocContainer/SingleTypeRegistrationTest.cs b/Test.LightweightIocContainer/SingleTypeRegistrationTest.cs index 94e4292..1b02035 100644 --- a/Test.LightweightIocContainer/SingleTypeRegistrationTest.cs +++ b/Test.LightweightIocContainer/SingleTypeRegistrationTest.cs @@ -29,10 +29,7 @@ namespace Test.LightweightIocContainer [UsedImplicitly] private class Foo : IFoo { - public Foo(IBar bar) - { - Bar = bar; - } + public Foo(IBar bar) => Bar = bar; public IBar Bar { get; } }