1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4 
5 using System;
6 using System.Collections.Generic;
7 using System.Composition.Hosting;
8 using System.Linq;
9 using System.Text;
10 using System.Threading.Tasks;
11 using Xunit;
12 
13 namespace System.Composition.Lightweight.UnitTests
14 {
15     public class CustomerReportedMetadataBug
16     {
17         public class ServiceMetadata
18         {
19             public string Name { get; set; }
20         }
21 
22         public interface IService
23         {
24         }
25 
26         [Export(typeof(IService)), ExportMetadata("Name", "1")]
27         public class SampleService1 : IService
28         {
SampleService1()29             public SampleService1()
30             {
31             }
32         }
33 
34         public class LooseImporter
35         {
36             [ImportMany]
37             public IList<Lazy<IService, ServiceMetadata>> Services { get; set; }
38         }
39 
40         [Fact]
41         [ActiveIssue(24903, TargetFrameworkMonikers.NetFramework)]
SampleServicesCorrectlyImported()42         public void SampleServicesCorrectlyImported()
43         {
44             var container = new ContainerConfiguration()
45                 .WithPart<SampleService1>()
46                 .CreateContainer();
47 
48             var importer = new LooseImporter();
49             container.SatisfyImports(importer);
50 
51             Assert.Equal(1, importer.Services.Count);
52         }
53     }
54 }
55