##// END OF EJS Templates
addded ServiceHost tests, updated project targets
cin -
r299:d54174bbd6c4 tip default
parent child
Show More
@@ -0,0 +1,64
1 <?xml version="1.0"?>
2 <container xmlns="http://implab.org/schemas/servicehost/unity.v1.xsd">
3 <namespace name="System"/>
4 <namespace name="System.Collections.Generic"/>
5 <namespace name="Implab.Components"/>
6 <namespace name="Implab.ServiceHost.Test.Mock"/>
7
8 <register type="Baz">
9 <property name="Nuts">
10 <!-- should resolve to all registered named dependencies (THIS IS A UNITY FEATURE) -->
11 <dependency />
12 </property>
13 </register>
14
15 <register name="baz2" type="Baz">
16 <property name="Nuts">
17 <!-- should resolve as is -->
18 <array>
19 <dependency/>
20 <dependency name="Big"/>
21 <dependency name="Big"/>
22 <dependency name="Small"/>
23 <dependency name="Mid"/>
24 </array>
25 </property>
26 </register>
27
28 <!-- useless -->
29 <array>
30 <dependency name="Big"/>
31 <dependency name="Big"/>
32 <dependency name="Big"/>
33 </array>
34
35 <array name="a1">
36 <dependency name="Big"/>
37 <dependency name="Big"/>
38 <dependency name="Big"/>
39 </array>
40
41 <register name="Big" type="Baz+Nut">
42 <property name="Size">
43 <value>5</value>
44 </property>
45 </register>
46 <register name="Mid" type="Baz+Nut">
47 <property name="Size">
48 <value>3</value>
49 </property>
50 </register>
51
52 <register name="Small" type="Baz+Nut">
53 <property name="Size">
54 <value>1</value>
55 </property>
56 </register>
57
58 <register type="Baz+Nut">
59 <property name="Size">
60 <value>2</value>
61 </property>
62 </register>
63
64 </container> No newline at end of file
@@ -1,37 +1,37
1 1 {
2 2 // See https://go.microsoft.com/fwlink/?LinkId=733558
3 3 // for the documentation about the tasks.json format
4 "version": "0.1.0",
4 "version": "2.0.0",
5 5 "command": "dotnet",
6 6 "args": [
7 7 ],
8 "showOutput": "silent",
9 8 "tasks": [
10 9 {
11 "taskName": "build",
12 // Show the output window only if unrecognized errors occur.
13 "showOutput": "always",
14 // Use the standard MS compiler pattern to detect errors, warnings and infos
10 "label": "build",
11 "command": "dotnet",
12 "args": [
13 "build",
14 "/p:Configuration=Debug"
15 ],
15 16 "problemMatcher": "$msCompile",
16
17 "args" : [
18 "/p:Configuration=Debug"
19 ]
17 "group": "build"
20 18 },
21 19 {
22 "taskName": "clean",
23 // Show the output window only if unrecognized errors occur.
24 "showOutput": "always",
25 // Use the standard MS compiler pattern to detect errors, warnings and infos
20 "label": "clean",
21 "command": "dotnet",
22 "args": [
23 "clean"
24 ],
26 25 "problemMatcher": "$msCompile"
27 26 },
28 27 {
29 "taskName": "test",
30 "isTestCommand": true,
31 // Show the output window only if unrecognized errors occur.
32 "showOutput": "always",
33 // Use the standard MS compiler pattern to detect errors, warnings and infos
34 "problemMatcher": "$msCompile"
28 "label": "test",
29 "command": "dotnet",
30 "args": [
31 "test"
32 ],
33 "problemMatcher": "$msCompile",
34 "group": "test"
35 35 }
36 36 ]
37 37 } No newline at end of file
@@ -1,6 +1,6
1 1 <Project Sdk="Microsoft.NET.Sdk">
2 2 <PropertyGroup Condition="'$(OSTYPE)'=='linux'">
3 <TargetFrameworks>netcoreapp2.0;;net46</TargetFrameworks>
3 <TargetFrameworks>netcoreapp3.1;net46</TargetFrameworks>
4 4 <FrameworkPathOverride Condition="'$(TargetFramework)'=='net46'">/usr/lib/mono/4.6-api/</FrameworkPathOverride>
5 5 </PropertyGroup>
6 6
@@ -90,5 +90,36 namespace Implab.Test {
90 90 Assert.Equal(88, p2.Age);
91 91 }
92 92
93 [Fact]
94 public void ArrayDependency() {
95 var container = new UnityContainer();
96
97 container.LoadXmlConfiguration(Path.Combine("data","container","array.dependency.xml"));
98
99 // IEnumerable<T> and T[] are special cases:
100 // - T[] resolves to an array of all named registrations
101 // - IEnumerable<T> resolves to all registrations (including the default one)
102 //
103 // This rule works always regardless explicit registrations were provided
104
105 var arr = container.Resolve<Baz.Nut[]>();
106 Assert.Equal(new [] {5,3,1}, arr?.Select(x => x.Size));
107
108 var a1 = container.Resolve<Baz.Nut[]>("a1");
109 Assert.Equal(new [] {5,3,1}, a1?.Select(x => x.Size));
110
111 var enm = container.Resolve<IEnumerable<Baz.Nut>>();
112 Assert.Equal(new [] {5,3,1,2}, enm?.Select(x => x.Size));
113
114 // default service registration
115 var baz = container.Resolve<Baz>();
116
117 Assert.Equal(new [] {5,3,1}, baz.Nuts.Select(x => x.Size));
118
119 var baz2 = container.Resolve<Baz>("baz2");
120
121 Assert.Equal(new [] {2,5,5,1,3}, baz2.Nuts.Select(x => x.Size));
122 }
123
93 124 }
94 125 } No newline at end of file
@@ -13,16 +13,7
13 13 <RepositoryUrl>https://code.implab.org/implab/ImplabNet/</RepositoryUrl>
14 14 <RepositoryType>mercurial</RepositoryType>
15 15 <PackageTags>Implab;Xml configuration;IoC;Unity container</PackageTags>
16 </PropertyGroup>
17
18
19 <PropertyGroup Condition="'$(OSTYPE)'=='linux'">
20 <TargetFrameworks>netcoreapp2.0;net46</TargetFrameworks>
21 <FrameworkPathOverride Condition="'$(TargetFramework)'=='net46'">/usr/lib/mono/4.5/</FrameworkPathOverride>
22 </PropertyGroup>
23
24 <PropertyGroup Condition="'$(OSTYPE)'=='windows'">
25 <TargetFrameworks>netcoreapp2.0;net46</TargetFrameworks>
16 <TargetFrameworks>netcoreapp3.1;net46</TargetFrameworks>
26 17 </PropertyGroup>
27 18
28 19 <ItemGroup>
General Comments 0
You need to be logged in to leave comments. Login now