# HG changeset patch # User cin # Date 2021-06-01 11:38:49 # Node ID d54174bbd6c4aa6f2493747104495bda122ace58 # Parent a7c3390f6ac889a2f5e66f99095050405017cb44 addded ServiceHost tests, updated project targets diff --git a/.vscode/tasks.json b/.vscode/tasks.json --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,37 +1,37 @@ { // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format - "version": "0.1.0", + "version": "2.0.0", "command": "dotnet", "args": [ ], - "showOutput": "silent", "tasks": [ { - "taskName": "build", - // Show the output window only if unrecognized errors occur. - "showOutput": "always", - // Use the standard MS compiler pattern to detect errors, warnings and infos + "label": "build", + "command": "dotnet", + "args": [ + "build", + "/p:Configuration=Debug" + ], "problemMatcher": "$msCompile", - - "args" : [ - "/p:Configuration=Debug" - ] + "group": "build" }, { - "taskName": "clean", - // Show the output window only if unrecognized errors occur. - "showOutput": "always", - // Use the standard MS compiler pattern to detect errors, warnings and infos + "label": "clean", + "command": "dotnet", + "args": [ + "clean" + ], "problemMatcher": "$msCompile" }, { - "taskName": "test", - "isTestCommand": true, - // Show the output window only if unrecognized errors occur. - "showOutput": "always", - // Use the standard MS compiler pattern to detect errors, warnings and infos - "problemMatcher": "$msCompile" + "label": "test", + "command": "dotnet", + "args": [ + "test" + ], + "problemMatcher": "$msCompile", + "group": "test" } ] } \ No newline at end of file diff --git a/Implab.Playground/Implab.Playground.csproj b/Implab.Playground/Implab.Playground.csproj --- a/Implab.Playground/Implab.Playground.csproj +++ b/Implab.Playground/Implab.Playground.csproj @@ -1,6 +1,6 @@  - netcoreapp2.0;;net46 + netcoreapp3.1;net46 /usr/lib/mono/4.6-api/ diff --git a/Implab.ServiceHost.Test/data/container/array.dependency.xml b/Implab.ServiceHost.Test/data/container/array.dependency.xml new file mode 100644 --- /dev/null +++ b/Implab.ServiceHost.Test/data/container/array.dependency.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + + + + + 3 + + + + + + 1 + + + + + + 2 + + + + \ No newline at end of file diff --git a/Implab.ServiceHost.Test/src/UnityConfigTest.cs b/Implab.ServiceHost.Test/src/UnityConfigTest.cs --- a/Implab.ServiceHost.Test/src/UnityConfigTest.cs +++ b/Implab.ServiceHost.Test/src/UnityConfigTest.cs @@ -90,5 +90,36 @@ namespace Implab.Test { Assert.Equal(88, p2.Age); } + [Fact] + public void ArrayDependency() { + var container = new UnityContainer(); + + container.LoadXmlConfiguration(Path.Combine("data","container","array.dependency.xml")); + + // IEnumerable and T[] are special cases: + // - T[] resolves to an array of all named registrations + // - IEnumerable resolves to all registrations (including the default one) + // + // This rule works always regardless explicit registrations were provided + + var arr = container.Resolve(); + Assert.Equal(new [] {5,3,1}, arr?.Select(x => x.Size)); + + var a1 = container.Resolve("a1"); + Assert.Equal(new [] {5,3,1}, a1?.Select(x => x.Size)); + + var enm = container.Resolve>(); + Assert.Equal(new [] {5,3,1,2}, enm?.Select(x => x.Size)); + + // default service registration + var baz = container.Resolve(); + + Assert.Equal(new [] {5,3,1}, baz.Nuts.Select(x => x.Size)); + + var baz2 = container.Resolve("baz2"); + + Assert.Equal(new [] {2,5,5,1,3}, baz2.Nuts.Select(x => x.Size)); + } + } } \ No newline at end of file diff --git a/Implab.ServiceHost/Implab.ServiceHost.csproj b/Implab.ServiceHost/Implab.ServiceHost.csproj --- a/Implab.ServiceHost/Implab.ServiceHost.csproj +++ b/Implab.ServiceHost/Implab.ServiceHost.csproj @@ -13,16 +13,7 @@ https://code.implab.org/implab/ImplabNet/ mercurial Implab;Xml configuration;IoC;Unity container - - - - - netcoreapp2.0;net46 - /usr/lib/mono/4.5/ - - - - netcoreapp2.0;net46 + netcoreapp3.1;net46