You've already forked linux-packaging-mono
Imported Upstream version 5.16.0.100
Former-commit-id: 38faa55fb9669e35e7d8448b15c25dc447f25767
This commit is contained in:
parent
0a9828183b
commit
7d7f676260
@@ -2,6 +2,8 @@
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
|
||||
@@ -10,6 +12,8 @@ namespace System.Composition.UnitTests
|
||||
public class ConstraintTests : ContainerTests
|
||||
{
|
||||
public interface IThing { }
|
||||
public interface IUnrelatedThings<TC, TP> : IList<TC>, IThing { }
|
||||
public interface IInheritedThings<TC, TP> : IList<TC>, IThing where TC : TP { }
|
||||
public interface ICar : IThing { }
|
||||
public interface IBook : IThing { }
|
||||
public interface IHandler<T> where T : IThing { }
|
||||
@@ -26,6 +30,17 @@ namespace System.Composition.UnitTests
|
||||
{
|
||||
}
|
||||
|
||||
[Export(typeof(IInheritedThings<,>))]
|
||||
public class InheritedThings<TC, TP> : ObservableCollection<TC>, IInheritedThings<TC, TP>
|
||||
where TC : TP
|
||||
{
|
||||
}
|
||||
|
||||
[Export(typeof(IUnrelatedThings<,>))]
|
||||
public class UnrelatedThings<TC, TP> : ObservableCollection<TC>, IUnrelatedThings<TC, TP>
|
||||
{
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ActiveIssue(24903, TargetFrameworkMonikers.NetFramework)]
|
||||
public void GenericPartDiscoveryIgnoresAPartAndDoesntThrowAnExceptionWhenItsConstraintOnTypeParameterIsNotAssignableFromTheExportTarget()
|
||||
@@ -50,5 +65,30 @@ namespace System.Composition.UnitTests
|
||||
Assert.Contains<Type>(typeof(ThingHandler<IBook>), handlerTypes);
|
||||
Assert.Contains<Type>(typeof(BookHandler<IBook>), handlerTypes);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ActiveIssue(24903, TargetFrameworkMonikers.NetFramework)]
|
||||
public void GetExport_ComplexConstraint_ExportSuccessful()
|
||||
{
|
||||
CompositionContext container = CreateContainer(typeof(UnrelatedThings<,>));
|
||||
var exports = container.GetExports<IUnrelatedThings<IBook, ICar>>();
|
||||
var types = exports.Select(h => h.GetType());
|
||||
|
||||
Assert.Equal(1, exports.Count());
|
||||
Assert.Contains(typeof(UnrelatedThings<IBook, ICar>), types);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ActiveIssue(23607)]
|
||||
[ActiveIssue(24903, TargetFrameworkMonikers.NetFramework)]
|
||||
public void GetExport_WhereClause_ExportSuccessful()
|
||||
{
|
||||
CompositionContext container = CreateContainer(typeof(InheritedThings<,>));
|
||||
var exports = container.GetExports<IInheritedThings<IBook, IThing>>();
|
||||
var types = exports.Select(h => h.GetType());
|
||||
|
||||
Assert.Equal(1, exports.Count());
|
||||
Assert.Contains(typeof(InheritedThings<IBook, IThing>), types);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user