forked from dotnet/corefx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImportManyTests.cs
More file actions
59 lines (52 loc) · 1.53 KB
/
ImportManyTests.cs
File metadata and controls
59 lines (52 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;
namespace System.Composition.UnitTests
{
public class ImportManyTests : ContainerTests
{
public interface IA { }
[Export(typeof(IA))]
public class A : IA { }
[Export(typeof(IA))]
public class A2 : IA { }
[Export]
public class ImportManyIA
{
public IEnumerable<IA> Items;
[ImportingConstructor]
public ImportManyIA([ImportMany] IEnumerable<IA> items)
{
Items = items;
}
}
[Export]
public class ImportManyPropsOfA
{
[ImportMany]
public IEnumerable<IA> AllA { get; set; }
public ImportManyPropsOfA()
{
}
}
[Fact]
public void ImportsMany()
{
var cc = CreateContainer(typeof(A), typeof(A2), typeof(ImportManyIA));
var im = cc.GetExport<ImportManyIA>();
Assert.Equal(2, im.Items.Count());
}
[Fact]
public void ImportsManyProperties()
{
var cc = CreateContainer(typeof(A), typeof(A2), typeof(ImportManyPropsOfA));
var im = cc.GetExport<ImportManyPropsOfA>();
Assert.Equal(2, im.AllA.Count());
}
}
}