diff --git a/Jerry.UnitTests/FrozenDependencyCollectionTests.cs b/Jerry.UnitTests/FrozenDependencyCollectionTests.cs deleted file mode 100644 index 882ba0d..0000000 --- a/Jerry.UnitTests/FrozenDependencyCollectionTests.cs +++ /dev/null @@ -1,96 +0,0 @@ -using System.Diagnostics; -using Jerry.Utilities; -using Jerry.Utilities.Examples.IoCExample; -using Jerry.Utilities.IoC.Frozen; -using Jerry.Utilities.IoC.General; - -namespace Jerry.UnitTests; - -public class FrozenDependencyCollectionTests -{ - private FrozenDependencyCollection _frozenCollection; - - class DependencyTestClass1 - { - - } - class DependencyTestClass2 - { - - } - class DependencyTestClass1Unreg - { - - } - class DependencyTestClass2Unreg - { - - } - [SetUp] - public void Setup() - { - var dict = new Dictionary() - { - { typeof(DependencyTestClass1), new DependencyTestClass1() }, - }; - _frozenCollection = (FrozenDependencyCollection)FrozenDependencyCollection.InitializeDependencies(dict); - } - - [Test] - public void InjectMultiple() - { - var dict = new Dictionary() - { - {typeof(DependencyTestClass1Unreg), new DependencyTestClass1Unreg()}, - {typeof(DependencyTestClass2Unreg), new DependencyTestClass2Unreg()}, - }; - _frozenCollection.InjectDependencies(dict); - var deps = _frozenCollection.EnumerateDependencies(); - Debug.Assert(deps.Count() == 3); - } - - [Test] - public void InjectDependencyType() - { - var type = typeof(DependencyTestClass2); - var dependency = new DependencyTestClass2(); - - var rt = Stopwatch.StartNew(); - _frozenCollection.InjectDependency(type, dependency); - rt.Stop(); - Debug.WriteLine($"Froze dictionary in {rt.Elapsed}"); - } - - [Test] - public void InjectDependency() - { - var dep = new DependencyTestClass2(); - var rt = Stopwatch.StartNew(); - _frozenCollection.InjectDependency(dep); - rt.Stop(); - Debug.WriteLine($"Froze dictionary in {rt.Elapsed}"); - } - - [Test] - public void ResolveDependency() - { - var result = _frozenCollection.TryGetDependency(out var instance); - Debug.Assert(result, "Unable to get registered type"); - Debug.Assert(instance != null, "Method said it was resolved, but value was null"); - Debug.Assert(instance.GetType().IsAssignableTo(typeof(DependencyTestClass1)), "Returned instance was not assignable to its type"); - } - - [Test] - public void GetDependency() - { - var instance = _frozenCollection.GetDependency(); - Debug.Assert(instance != null, "Instance was null"); - } - - [Test] - public void EnumerateDependencies() - { - var count = _frozenCollection.EnumerateDependencies(); - Debug.Assert(count.Count() == 1, "Returned count was not 1"); - } -} \ No newline at end of file diff --git a/Jerry.UnitTests/GlobalUsings.cs b/Jerry.UnitTests/GlobalUsings.cs deleted file mode 100644 index cefced4..0000000 --- a/Jerry.UnitTests/GlobalUsings.cs +++ /dev/null @@ -1 +0,0 @@ -global using NUnit.Framework; \ No newline at end of file diff --git a/Jerry.UnitTests/IoCManagerFrozenTestsAll.cs b/Jerry.UnitTests/IoCManagerFrozenTestsAll.cs deleted file mode 100644 index 962b69d..0000000 --- a/Jerry.UnitTests/IoCManagerFrozenTestsAll.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System.Diagnostics; -using System.Reflection; -using Jerry.Utilities.Examples.IoCExample; -using Jerry.Utilities.IoC.Frozen; -using Jerry.Utilities.IoC.General; -using Jerry.Utilities.Reflection; - -namespace Jerry.UnitTests; - -public class IoCManagerFrozenTestsAll -{ - [SetUp] - public void SetUp() - { - ReflectionManager.Instance.LoadAssemblies([Assembly.GetExecutingAssembly()]); - var settings = new IoCManagerBuilder() - .WithMode(IoCMode.All) - .WithAttribute() - .WithInheritor() - .WithRegisterInheritor(true) - .Build(); - IoCManager.InitializeDependencies(settings); - } - - [Test] - public void Resolve() - { - var resolved1 = IoCManager.Resolve(); - Debug.Assert(resolved1 != null); - } - - [Test] - public void TryResolve() - { - var resolved1 = IoCManager.TryResolve(out var instance); - var resolved2 = IoCManager.TryResolve(out var instance2); - Debug.Assert(resolved1, "Unable to resolve registered class"); - Debug.Assert(!resolved2, "Resolved unregistered type"); - Debug.Assert(instance != null); - Debug.Assert(instance2 == null); - } - - [Test] - public void InjectEachOther() - { - IoCManager.InjectDependencies(); - var dependency1 = IoCManager.Resolve(); - var dependency2 = IoCManager.Resolve(); - Debug.Assert(dependency1._inner2 != null); - Debug.Assert(dependency2._inner != null); - } - - [Test] - public void InjectDirectly() - { - var instance = new DependencyTestClass1(); - IoCManager.InjectDependency(instance); - Debug.Assert(instance._inner2 != null); - } -} -[RegisterDependency] -class DependencyTestClass1 -{ - [Dependency] public DependencyTestClass2 _inner2 = default!; -} -class DependencyTestClass2 : InheritorDependency -{ - [Dependency] public readonly DependencyInnerTestClass _inner = default!; -} -[RegisterDependency] -class DependencyInnerTestClass -{ -} - -class DependencyUnregistered -{ - -} \ No newline at end of file diff --git a/Jerry.UnitTests/Jerry.UnitTests.csproj b/Jerry.UnitTests/Jerry.UnitTests.csproj deleted file mode 100644 index a86228b..0000000 --- a/Jerry.UnitTests/Jerry.UnitTests.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - net8.0 - enable - enable - - false - true - - - - - - - - - - - - - - - diff --git a/Jerry.UnitTests/ReferencedDependencyCollectionTests.cs b/Jerry.UnitTests/ReferencedDependencyCollectionTests.cs deleted file mode 100644 index 00f731d..0000000 --- a/Jerry.UnitTests/ReferencedDependencyCollectionTests.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System.Diagnostics; -using Jerry.Utilities.IoC.General; -using Jerry.Utilities.IoC.Referenced; - -namespace Jerry.UnitTests; - -public class ReferencedDependencyCollectionTests -{ - private ReferencedDependencyCollection _dependencies = default!; - [SetUp] - public void Setup() - { - var dict = new Dictionary() - { - { typeof(Dep1), new Dep1() }, - { typeof(Dep2), new Dep2() } - }; - _dependencies = (ReferencedDependencyCollection)ReferencedDependencyCollection.InitializeDependencies(dict); - } - - - [Test] - public void GetDependency() - { - var instance = _dependencies.GetDependency(); - Debug.Assert(instance != null); - Debug.Assert(instance.GetType() == typeof(Dep1)); - } - - [Test] - public void TryGetDependency() - { - var result = _dependencies.TryGetDependency(out var instance); - var result2 = _dependencies.TryGetDependency(out var instance2); - Debug.Assert(result, "result was not true"); - Debug.Assert(!result2, "result2 was true"); - Debug.Assert(instance != null, "instance was null"); - Debug.Assert(instance2 == null, "instance2 was not null"); - Debug.Assert(instance.GetType() == typeof(Dep2), "instance.GetType() == typeof(Dep2)"); - } - - [Test] - public void InjectDependency() - { - var unreg = new Dep3Unreg(); - _dependencies.InjectDependency(unreg); - var instance = _dependencies.GetDependency(); - Debug.Assert(instance != null); - Debug.Assert(instance.GetType() == typeof(Dep3Unreg)); - } -} - -public class Dep1 -{ -} - -public class Dep2 -{ -} - -public class Dep3Unreg -{ -} \ No newline at end of file diff --git a/Jerry.Utilities/Jerry.Utilities.csproj b/Jerry.Utilities/Jerry.Utilities.csproj index 1ebd57a..ce3191c 100644 --- a/Jerry.Utilities/Jerry.Utilities.csproj +++ b/Jerry.Utilities/Jerry.Utilities.csproj @@ -6,7 +6,7 @@ enable true JerryImMouse.Project.Utilities - 0.0.2 + 0.0.5 JerryImMouse JerryImMouse