diff options
Diffstat (limited to 'mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel')
16 files changed, 0 insertions, 1159 deletions
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/.gitattributes b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/.gitattributes deleted file mode 100644 index 8946265321a..00000000000 --- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -/ConstraintParser.cs -crlf diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/ConstraintParser.cs b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/ConstraintParser.cs deleted file mode 100644 index 2a0a0d3e665..00000000000 --- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/ConstraintParser.cs +++ /dev/null @@ -1,225 +0,0 @@ -// -----------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// -----------------------------------------------------------------------
-using System;
-using System.Collections.Generic;
-using System.Linq.Expressions;
-using System.Reflection;
-using Microsoft.Internal;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System.ComponentModel.Composition.Primitives;
-
-namespace System.ComponentModel.Composition
-{
- public class ContraintParser
- {
- private static readonly PropertyInfo _exportDefinitionContractNameProperty = typeof(ExportDefinition).GetProperty("ContractName");
- private static readonly PropertyInfo _exportDefinitionMetadataProperty = typeof(ExportDefinition).GetProperty("Metadata");
- private static readonly MethodInfo _metadataContainsKeyMethod = typeof(IDictionary<string, object>).GetMethod("ContainsKey");
- private static readonly MethodInfo _metadataItemMethod = typeof(IDictionary<string, object>).GetMethod("get_Item");
- private static readonly MethodInfo _typeIsInstanceOfTypeMethod = typeof(Type).GetMethod("IsInstanceOfType");
-
- public static bool TryParseConstraint(Expression<Func<ExportDefinition, bool>> constraint, out string contractName, out IEnumerable<KeyValuePair<string, Type>> requiredMetadata)
- {
- contractName = null;
- requiredMetadata = null;
-
- List<KeyValuePair<string, Type>> requiredMetadataList = new List<KeyValuePair<string, Type>>();
- foreach (Expression expression in SplitConstraintBody(constraint.Body))
- {
- // First try to parse as a contract, if we don't have one already
- if (contractName == null && TryParseExpressionAsContractConstraintBody(expression, constraint.Parameters[0], out contractName))
- {
- continue;
- }
-
- // Then try to parse as a required metadata item name
- string requiredMetadataItemName = null;
- Type requiredMetadataItemType = null;
- if (TryParseExpressionAsMetadataConstraintBody(expression, constraint.Parameters[0], out requiredMetadataItemName, out requiredMetadataItemType))
- {
- requiredMetadataList.Add(new KeyValuePair<string, Type>(requiredMetadataItemName, requiredMetadataItemType));
- }
-
- // Just skip the expressions we don't understand
- }
-
- // ContractName should have been set already, just need to set metadata
- requiredMetadata = requiredMetadataList;
- return true;
- }
-
-
- private static IEnumerable<Expression> SplitConstraintBody(Expression expression)
- {
- Assert.IsNotNull(expression);
-
- // The expression we know about should be a set of nested AndAlso's, we
- // need to flatten them into one list. we do this iteratively, as
- // recursion will create too much of a memory churn.
- Stack<Expression> expressions = new Stack<Expression>();
- expressions.Push(expression);
-
- while (expressions.Count > 0)
- {
- Expression current = expressions.Pop();
- if (current.NodeType == ExpressionType.AndAlso)
- {
- BinaryExpression andAlso = (BinaryExpression)current;
- // Push right first - this preserves the ordering of the expression, which will force
- // the contract constraint to come up first as the callers are optimized for this form
- expressions.Push(andAlso.Right);
- expressions.Push(andAlso.Left);
- continue;
- }
-
- yield return current;
- }
- }
-
- private static bool TryParseExpressionAsContractConstraintBody(Expression expression, Expression parameter, out string contractName)
- {
- contractName = null;
-
- // The expression should be an '==' expression
- if (expression.NodeType != ExpressionType.Equal)
- {
- return false;
- }
-
- BinaryExpression contractConstraintExpression = (BinaryExpression)expression;
-
- // First try item.ContractName == "Value"
- if (TryParseContractNameFromEqualsExpression(contractConstraintExpression.Left, contractConstraintExpression.Right, parameter, out contractName))
- {
- return true;
- }
-
- // Then try "Value == item.ContractName
- if (TryParseContractNameFromEqualsExpression(contractConstraintExpression.Right, contractConstraintExpression.Left, parameter, out contractName))
- {
- return true;
- }
-
- return false;
- }
-
- private static bool TryParseContractNameFromEqualsExpression(Expression left, Expression right, Expression parameter, out string contractName)
- {
- contractName = null;
-
- // The left should be access to property "Contract" applied to the parameter
- MemberExpression targetMember = left as MemberExpression;
- if (targetMember == null)
- {
- return false;
- }
-
- if ((targetMember.Member != _exportDefinitionContractNameProperty) || (targetMember.Expression != parameter))
- {
- return false;
- }
-
- // Right should a constant expression containing the contract name
- ConstantExpression contractNameConstant = right as ConstantExpression;
- if (contractNameConstant == null)
- {
- return false;
- }
-
- if (!TryParseConstant<string>(contractNameConstant, out contractName))
- {
- return false;
- }
-
- return true;
- }
-
- private static bool TryParseExpressionAsMetadataConstraintBody(Expression expression, Expression parameter, out string requiredMetadataKey, out Type requiredMetadataType)
- {
- Assumes.NotNull(expression, parameter);
-
- requiredMetadataKey = null;
- requiredMetadataType = null;
-
- // Should be a call to Type.IsInstanceofType on definition.Metadata[key]
- MethodCallExpression outerMethodCall = expression as MethodCallExpression;
- if (outerMethodCall == null)
- {
- return false;
- }
-
- // Make sure that the right method ie being called
- if (outerMethodCall.Method != _typeIsInstanceOfTypeMethod)
- {
- return false;
- }
- Assumes.IsTrue(outerMethodCall.Arguments.Count == 1);
-
-
- // 'this' should be a constant expression pointing at a Type object
- ConstantExpression targetType = outerMethodCall.Object as ConstantExpression;
- if(!TryParseConstant<Type>(targetType, out requiredMetadataType))
- {
- return false;
- }
-
- // SHould be a call to get_Item
- MethodCallExpression methodCall = outerMethodCall.Arguments[0] as MethodCallExpression;
- if (methodCall == null)
- {
- return false;
- }
-
- if (methodCall.Method != _metadataItemMethod)
- {
- return false;
- }
-
- // Make sure the method is being called on the right object
- MemberExpression targetMember = methodCall.Object as MemberExpression;
- if (targetMember == null)
- {
- return false;
- }
-
- if ((targetMember.Expression != parameter) || (targetMember.Member != _exportDefinitionMetadataProperty))
- {
- return false;
- }
-
- // There should only ever be one argument; otherwise,
- // we've got the wrong IDictionary.get_Item method.
- Assumes.IsTrue(methodCall.Arguments.Count == 1);
-
- // Argument should a constant expression containing the metadata key
- ConstantExpression requiredMetadataKeyConstant = methodCall.Arguments[0] as ConstantExpression;
- if (requiredMetadataKeyConstant == null)
- {
- return false;
- }
-
- if (!TryParseConstant<string>(requiredMetadataKeyConstant, out requiredMetadataKey))
- {
- return false;
- }
-
- return true;
- }
-
- private static bool TryParseConstant<T>(ConstantExpression constant, out T result)
- where T : class
- {
- Assumes.NotNull(constant);
-
- if (constant.Type == typeof(T) && constant.Value != null)
- {
- result = (T)constant.Value;
- return true;
- }
-
- result = default(T);
- return false;
- }
- }
-}
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/Diagnostics/.gitattributes b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/Diagnostics/.gitattributes deleted file mode 100644 index 2d87a8bf956..00000000000 --- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/Diagnostics/.gitattributes +++ /dev/null @@ -1,4 +0,0 @@ -/TraceContext.TraceContextTraceListener.cs -crlf -/TraceContext.cs -crlf -/TraceEventDetails.cs -crlf -/TraceId.cs -crlf diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/Diagnostics/TraceContext.TraceContextTraceListener.cs b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/Diagnostics/TraceContext.TraceContextTraceListener.cs deleted file mode 100644 index aa47b32ed10..00000000000 --- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/Diagnostics/TraceContext.TraceContextTraceListener.cs +++ /dev/null @@ -1,42 +0,0 @@ -// -----------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// -----------------------------------------------------------------------
-#if !SILVERLIGHT
-
-using System;
-using System.Diagnostics;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-
-namespace System.ComponentModel.Composition.Diagnostics
-{
- partial class TraceContext : IDisposable
- {
- private class TraceContextTraceListener : TraceListener
- {
- private readonly Collection<TraceEventDetails> _traceEvents = new Collection<TraceEventDetails>();
-
- public IList<TraceEventDetails> TraceEvents
- {
- get { return _traceEvents; }
- }
-
- public override void TraceEvent(TraceEventCache eventCache, string source, TraceEventType eventType, int id, string format, params object[] args)
- {
- _traceEvents.Add(new TraceEventDetails(eventCache, source, eventType, (TraceId)id, format, args));
- }
-
- public override void Write(string message)
- {
- throw new NotImplementedException();
- }
-
- public override void WriteLine(string message)
- {
- throw new NotImplementedException();
- }
- }
- }
-}
-
-#endif
\ No newline at end of file diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/Diagnostics/TraceContext.cs b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/Diagnostics/TraceContext.cs deleted file mode 100644 index 57486c71b29..00000000000 --- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/Diagnostics/TraceContext.cs +++ /dev/null @@ -1,44 +0,0 @@ -// -----------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// -----------------------------------------------------------------------
-#if !SILVERLIGHT
-
-using System;
-using System.Linq;
-using System.Diagnostics;
-using System.Collections.Generic;
-
-namespace System.ComponentModel.Composition.Diagnostics
-{
- public partial class TraceContext : IDisposable
- {
- private readonly SourceLevels _previousLevel = TraceSourceTraceWriter.Source.Switch.Level;
- private readonly TraceContextTraceListener _listener = new TraceContextTraceListener();
-
- public TraceContext(SourceLevels level)
- {
- TraceSourceTraceWriter.Source.Switch.Level = level;
- TraceSourceTraceWriter.Source.Listeners.Add(_listener);
- }
-
- [CLSCompliant(false)]
- public TraceEventDetails LastTraceEvent
- {
- get { return _listener.TraceEvents.LastOrDefault(); }
- }
-
- [CLSCompliant(false)]
- public IList<TraceEventDetails> TraceEvents
- {
- get { return _listener.TraceEvents; }
- }
-
- public void Dispose()
- {
- TraceSourceTraceWriter.Source.Listeners.Remove(_listener);
- TraceSourceTraceWriter.Source.Switch.Level = _previousLevel;
- }
- }
-}
-
-#endif
\ No newline at end of file diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/Diagnostics/TraceEventDetails.cs b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/Diagnostics/TraceEventDetails.cs deleted file mode 100644 index 8883b0f526a..00000000000 --- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/Diagnostics/TraceEventDetails.cs +++ /dev/null @@ -1,62 +0,0 @@ -// -----------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// -----------------------------------------------------------------------
-#if !SILVERLIGHT
-
-using System;
-using System.Diagnostics;
-
-namespace System.ComponentModel.Composition.Diagnostics
-{
- [CLSCompliant(false)]
- public class TraceEventDetails
- {
- public TraceEventDetails(TraceEventCache eventCache, string source, TraceEventType eventType, TraceId id, string format, params object[] args)
- {
- EventCache = eventCache;
- Source = source;
- EventType = eventType;
- Id = id;
- Format = format;
- Args = args;
- }
-
- public TraceEventCache EventCache
- {
- get;
- private set;
- }
-
- public string Source
- {
- get;
- private set;
- }
-
- public TraceEventType EventType
- {
- get;
- private set;
- }
-
- public TraceId Id
- {
- get;
- private set;
- }
-
- public string Format
- {
- get;
- private set;
- }
-
- public object[] Args
- {
- get;
- private set;
- }
- }
-}
-
-#endif
\ No newline at end of file diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/Diagnostics/TraceId.cs b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/Diagnostics/TraceId.cs deleted file mode 100644 index 7d07532394f..00000000000 --- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/Diagnostics/TraceId.cs +++ /dev/null @@ -1,21 +0,0 @@ -// -----------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// -----------------------------------------------------------------------
-using System;
-
-namespace System.ComponentModel.Composition.Diagnostics
-{
- // We need a public version of CompositionTraceId, so that the QA tests can access and verify the trace.
- [CLSCompliant(false)]
- public enum TraceId : ushort
- {
- Rejection_DefinitionRejected = CompositionTraceId.Rejection_DefinitionRejected,
- Rejection_DefinitionResurrected = CompositionTraceId.Rejection_DefinitionResurrected,
-
- Discovery_AssemblyLoadFailed = CompositionTraceId.Discovery_AssemblyLoadFailed,
- Discovery_DefinitionMarkedWithPartNotDiscoverableAttribute = CompositionTraceId.Discovery_DefinitionMarkedWithPartNotDiscoverableAttribute,
- Discovery_DefinitionContainsGenericParameters = CompositionTraceId.Discovery_DefinitionContainsGenericParameters,
- Discovery_DefinitionContainsNoExports = CompositionTraceId.Discovery_DefinitionContainsNoExports,
- Discovery_MemberMarkedWithMultipleImportAndImportMany = CompositionTraceId.Discovery_MemberMarkedWithMultipleImportAndImportMany,
- }
-}
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/Hosting/.gitattributes b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/Hosting/.gitattributes deleted file mode 100644 index 4a9c9034149..00000000000 --- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/Hosting/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -/CompositionHostTestService.cs -crlf diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/Hosting/CompositionHostTestService.cs b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/Hosting/CompositionHostTestService.cs deleted file mode 100644 index fc9606310f4..00000000000 --- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/Hosting/CompositionHostTestService.cs +++ /dev/null @@ -1,46 +0,0 @@ -#if SILVERLIGHT
-using System;
-using System.Net;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System.ComponentModel.Composition;
-using System.ComponentModel.Composition.Hosting;
-using System.ComponentModel.Composition.Primitives;
-
-namespace System.ComponentModel.Composition.Hosting
-{
- public static class CompositionHostTestService
- {
- public static void SetupTestGlobalContainer(CompositionContainer container)
- {
- CompositionHost._container = null;
- CompositionHost.Initialize(container);
- }
-
- public static void SetupTestGlobalContainer(ComposablePartCatalog catalog)
- {
- CompositionHost._container = null;
- CompositionHost.Initialize(catalog);
- }
-
- public static void ClearGlobalContainer()
- {
- CompositionHost._container = null;
- }
-
- public static void ResetGlobalContainer()
- {
- ClearGlobalContainer();
-#if !BUILDING_IN_VS
- // We can only use the default SL Deployment option while building in VS otherwise we
- // will not have a proper Application/Deployment object setup.
- SetupTestGlobalContainer(new AssemblyCatalog(typeof(CompositionHostTestService).Assembly));
-#endif
- }
-
- public static CompositionContainer GlobalContainer
- {
- get { return CompositionHost._container; }
- }
- }
-}
-#endif
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/ReflectionModel/.gitattributes b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/ReflectionModel/.gitattributes deleted file mode 100644 index 8e8fec9cec1..00000000000 --- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/ReflectionModel/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -/ReflectionModelServicesEx.cs -crlf diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/ReflectionModel/ReflectionModelServicesEx.cs b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/ReflectionModel/ReflectionModelServicesEx.cs deleted file mode 100644 index 75b483e163b..00000000000 --- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/ReflectionModel/ReflectionModelServicesEx.cs +++ /dev/null @@ -1,155 +0,0 @@ -// -----------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// -----------------------------------------------------------------------
-using System;
-using System.ComponentModel.Composition;
-using System.Linq;
-using System.Linq.Expressions;
-using System.UnitTesting;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System.Reflection;
-using System.ComponentModel.Composition.Hosting;
-using System.Collections.Generic;
-using System.ComponentModel.Composition.Primitives;
-
-// NOTE : this is a helper class for exosig the EditorFactory functionality to tests until ExportFactory can be moved where it belongs
-namespace System.ComponentModel.Composition.ReflectionModel
-{
- public static class ReflectionModelServicesEx
- {
- public static ContractBasedImportDefinition CreateImportDefinition(
- Lazy<ParameterInfo> parameter,
- string contractName,
- string requiredTypeIdentity,
- IEnumerable<KeyValuePair<string, Type>> requiredMetadata,
- ImportCardinality cardinality,
- CreationPolicy requiredCreationPolicy,
- bool isExportFactory,
- ICompositionElement origin)
- {
- return ReflectionModelServices.CreateImportDefinition(parameter, contractName, requiredTypeIdentity, requiredMetadata, cardinality, requiredCreationPolicy, isExportFactory, origin);
- }
-
- public static ContractBasedImportDefinition CreateImportDefinition(
- LazyMemberInfo importingMember,
- string contractName,
- string requiredTypeIdentity,
- IEnumerable<KeyValuePair<string, Type>> requiredMetadata,
- ImportCardinality cardinality,
- bool isRecomposable,
- CreationPolicy requiredCreationPolicy,
- bool isExportFactory,
- ICompositionElement origin)
- {
- return ReflectionModelServices.CreateImportDefinition(importingMember, contractName, requiredTypeIdentity, requiredMetadata, cardinality, isRecomposable, requiredCreationPolicy, isExportFactory, origin);
- }
-
- public static bool IsExportFactoryImportDefinition(ImportDefinition importDefinition)
- {
- return ReflectionModelServices.IsExportFactoryImportDefinition(importDefinition);
- }
-
- public static ContractBasedImportDefinition CreateExportFactoryImportDefinition(ContractBasedImportDefinition productImportDefinition)
- {
- return new ExportFactoryImportDefinition(productImportDefinition);
- }
-
- private class ExportFactoryImportDefinition : ContractBasedImportDefinition, IPartCreatorImportDefinition
- {
- private readonly ContractBasedImportDefinition _productImportDefinition;
-
- public ExportFactoryImportDefinition(ContractBasedImportDefinition productImportDefinition)
- : base(CompositionConstants.PartCreatorContractName, CompositionConstants.PartCreatorTypeIdentity, productImportDefinition.RequiredMetadata,
- productImportDefinition.Cardinality, productImportDefinition.IsRecomposable, false, CreationPolicy.Any)
- {
- _productImportDefinition = productImportDefinition;
- }
-
- public ContractBasedImportDefinition ProductImportDefinition
- {
- get
- {
- return _productImportDefinition;
- }
- }
-
- public override Expression<Func<ExportDefinition, bool>> Constraint
- {
- get
- {
- return CreateExportFactoryConstraint(base.Constraint, this._productImportDefinition);
- }
- }
-
- public override bool IsConstraintSatisfiedBy(ExportDefinition exportDefinition)
- {
- if (!base.IsConstraintSatisfiedBy(exportDefinition))
- {
- return false;
- }
-
- return IsProductConstraintSatisfiedBy(this._productImportDefinition, exportDefinition);
- }
-
- private static bool IsProductConstraintSatisfiedBy(ImportDefinition productImportDefinition, ExportDefinition exportDefinition)
- {
- object productValue = null;
- if (exportDefinition.Metadata.TryGetValue(CompositionConstants.ProductDefinitionMetadataName, out productValue))
- {
- ExportDefinition productDefinition = productValue as ExportDefinition;
-
- if (productDefinition != null)
- {
- return productImportDefinition.IsConstraintSatisfiedBy(productDefinition);
- }
- }
-
- return false;
- }
-
- private static readonly PropertyInfo _exportDefinitionMetadataProperty = typeof(ExportDefinition).GetProperty("Metadata");
- private static readonly MethodInfo _metadataContainsKeyMethod = typeof(IDictionary<string, object>).GetMethod("ContainsKey");
- private static readonly MethodInfo _metadataItemMethod = typeof(IDictionary<string, object>).GetMethod("get_Item");
-
- private static Expression<Func<ExportDefinition, bool>> CreateExportFactoryConstraint(Expression<Func<ExportDefinition, bool>> baseConstraint, ImportDefinition productImportDefinition)
- {
- ParameterExpression exportDefinitionParameter = baseConstraint.Parameters[0];
-
- // exportDefinition.Metadata
- Expression metadataExpression = Expression.Property(exportDefinitionParameter, _exportDefinitionMetadataProperty);
-
- // exportDefinition.Metadata.ContainsKey("ProductDefinition")
- Expression containsProductExpression = Expression.Call(
- metadataExpression,
- _metadataContainsKeyMethod,
- Expression.Constant(CompositionConstants.ProductDefinitionMetadataName));
-
- // exportDefinition.Metadata["ProductDefinition"]
- Expression productExportDefinitionExpression = Expression.Call(
- metadataExpression,
- _metadataItemMethod,
- Expression.Constant(CompositionConstants.ProductDefinitionMetadataName));
-
- // ProductImportDefinition.Contraint((ExportDefinition)exportDefinition.Metadata["ProductDefinition"])
- Expression productMatchExpression =
- Expression.Invoke(productImportDefinition.Constraint,
- Expression.Convert(productExportDefinitionExpression, typeof(ExportDefinition)));
-
- // baseContraint(exportDefinition) &&
- // exportDefinition.Metadata.ContainsKey("ProductDefinition") &&
- // ProductImportDefinition.Contraint((ExportDefinition)exportDefinition.Metadata["ProductDefinition"])
- Expression<Func<ExportDefinition, bool>> constraint =
- Expression.Lambda<Func<ExportDefinition, bool>>(
- Expression.AndAlso(
- baseConstraint.Body,
- Expression.AndAlso(
- containsProductExpression,
- productMatchExpression)),
- exportDefinitionParameter);
-
- return constraint;
- }
- }
-
- }
-}
\ No newline at end of file diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/UnitTesting/.gitattributes b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/UnitTesting/.gitattributes deleted file mode 100644 index 54538e6d2f4..00000000000 --- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/UnitTesting/.gitattributes +++ /dev/null @@ -1,4 +0,0 @@ -/CompositionAssert.cs -crlf -/ElementAssert.cs -crlf -/ErrorId.cs -crlf -/ExportsAssert.cs -crlf diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/UnitTesting/CompositionAssert.cs b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/UnitTesting/CompositionAssert.cs deleted file mode 100644 index 8039a825934..00000000000 --- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/UnitTesting/CompositionAssert.cs +++ /dev/null @@ -1,439 +0,0 @@ -// -----------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// -----------------------------------------------------------------------
-using System;
-using System.ComponentModel.Composition;
-using System.Linq;
-using System.UnitTesting;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System.Reflection;
-using System.ComponentModel.Composition.Hosting;
-using System.Collections.Generic;
-using System.ComponentModel.Composition.Primitives;
-
-namespace System.ComponentModel.Composition.UnitTesting
-{
- public static class CompositionAssert
- {
- internal static void AreEqual(CompositionResult expected, CompositionResult actual)
- {
- Assert.AreEqual(expected.Succeeded, actual.Succeeded);
-
- EnumerableAssert.AreSequenceEqual(expected.Errors, actual.Errors, (index, expectedError, actualError) =>
- {
- AreEqual(expectedError, actualError);
- });
- }
-
- internal static void AreEqual(CompositionError expected, CompositionError actual)
- {
- Assert.AreEqual(((ICompositionError)expected).Id, ((ICompositionError)actual).Id);
- Assert.AreEqual(expected.Description, actual.Description);
- ExtendedAssert.IsInstanceOfSameType(expected.Exception, actual.Exception);
- }
-
- public static void ThrowsPart(ErrorId id, Action action)
- {
- ThrowsPart(id, RetryMode.Retry, action);
- }
-
- public static void ThrowsPart(ErrorId id, RetryMode retry, Action action)
- {
- ThrowsPart(new CompositionErrorExpectation { Id = id }, retry, action);
- }
-
- public static void ThrowsPart(ErrorId id, ICompositionElement element, Action action)
- {
- ThrowsPart(id, element, RetryMode.Retry, action);
- }
-
- public static void ThrowsPart(ErrorId id, ICompositionElement element, RetryMode retry, Action action)
- {
- ThrowsPart(new CompositionErrorExpectation { Id = id, Element = element }, retry, action);
- }
-
- public static void ThrowsPart<TInner>(ErrorId id, Action action)
- where TInner : Exception
- {
- ThrowsPart<TInner>(id, RetryMode.Retry, action);
- }
-
- public static void ThrowsPart<TInner>(ErrorId id, RetryMode retry, Action action)
- where TInner : Exception
- {
- ThrowsPart(new CompositionErrorExpectation { Id = id, InnerExceptionType = typeof(TInner) }, retry, action);
- }
-
- private static void ThrowsPart(CompositionErrorExpectation expectation, RetryMode retry, Action action)
- {
- ExceptionAssert.Throws<ComposablePartException>(retry, action, (thrownException, retryCount) =>
- {
- AssertCore(retryCount, "ComposablePartException", thrownException, expectation);
- });
- }
-
- public static void ThrowsRootError(ErrorId rootId, RetryMode retry, Action action)
- {
- var exception = ExceptionAssert.Throws<CompositionException>(retry, action, (thrownException, retryCount) =>
- {
- ErrorId actualId = GetRootErrorId(thrownException);
-
- Assert.AreEqual(rootId, actualId, "Retry Count {0}: Expected '{1}' to be the root ErrorId, however, '{2}' is.", retryCount, rootId, actualId);
- });
- }
-
- public static void ThrowsError<TInner>(ErrorId id, RetryMode retry, Action action)
- {
- ThrowsError(new CompositionErrorExpectation { Id = id, InnerExceptionType = typeof(TInner) }, RetryMode.Retry, action);
- }
-
- public static void ThrowsError(ErrorId id, Action action)
- {
- ThrowsError(new CompositionErrorExpectation { Id = id}, RetryMode.Retry, action);
- }
-
- public static void ThrowsError(ErrorId id, ErrorId innerId, Action action)
- {
- ThrowsError(id, innerId, RetryMode.Retry, action);
- }
-
- public static void ThrowsError(ErrorId id, ErrorId innerId, RetryMode retry, Action action)
- {
- ThrowsError(GetExpectation(id, innerId), retry, action);
- }
-
- public static void ThrowsError(ErrorId id, ErrorId innerId, ErrorId innerInnerId, Action action)
- {
- ThrowsError(id, innerId, innerInnerId, RetryMode.Retry, action);
- }
-
- public static void ThrowsError(ErrorId id, ErrorId innerId, ErrorId innerInnerId, RetryMode retry, Action action)
- {
- ThrowsError(GetExpectation(id, innerId, innerInnerId), retry, action);
- }
-
- public static void ThrowsError(ErrorId id, RetryMode retry, Action action)
- {
- ThrowsError(new CompositionErrorExpectation { Id = id, }, retry, action);
- }
-
- public static void ThrowsError(ErrorId id, ICompositionElement element, Action action)
- {
- ThrowsError(new CompositionErrorExpectation { Id = id, Element = element}, RetryMode.Retry, action);
- }
-
- public static void ThrowsError(ErrorId id, ICompositionElement element, RetryMode retry, Action action)
- {
- ThrowsError(new CompositionErrorExpectation { Id = id, Element = element }, retry, action);
- }
-
- public static void ThrowsError(ErrorId id, Exception exception, Action action)
- {
- ThrowsError(new CompositionErrorExpectation { Id = id, InnerException = exception }, RetryMode.Retry, action);
- }
-
- public static void ThrowsError(ErrorId id, Exception exception, RetryMode retry, Action action)
- {
- ThrowsError(new CompositionErrorExpectation { Id = id, InnerException = exception }, retry, action);
- }
-
- public static void ThrowsError(ErrorId id, ICompositionElement element, Exception exception, Action action)
- {
- ThrowsError(new CompositionErrorExpectation { Id = id, Element = element, InnerException = exception }, RetryMode.Retry, action);
- }
-
- public static void ThrowsError(ErrorId id, ICompositionElement element, Exception exception, RetryMode retry, Action action)
- {
- ThrowsError(new CompositionErrorExpectation { Id = id, Element = element, InnerException = exception }, retry, action);
- }
-
- private static void ThrowsError(CompositionErrorExpectation expectation, RetryMode retry, Action action)
- {
- ThrowsErrors(new CompositionErrorExpectation[] { expectation }, retry, action);
- }
-
- public static void ThrowsErrors(ErrorId id1, ErrorId id2, Action action)
- {
- ThrowsErrors(id1, id2, RetryMode.Retry, action);
- }
-
- public static void ThrowsErrors(ErrorId id1, ErrorId id2, RetryMode retry, Action action)
- {
- ThrowsErrors(new ErrorId[] { id1, id2 }, retry, action);
- }
-
- public static void ThrowsErrors(ErrorId[] ids, RetryMode retry, Action action)
- {
- CompositionErrorExpectation[] expectations = new CompositionErrorExpectation[ids.Length];
- for (int i = 0; i < expectations.Length; i++)
- {
- expectations[i] = new CompositionErrorExpectation { Id = ids[i] };
- }
-
- ThrowsErrors(expectations, retry, action);
- }
-
- private static void ThrowsErrors(CompositionErrorExpectation[] expectations, RetryMode retry, Action action)
- {
- ExceptionAssert.Throws<CompositionException>(retry, action, (thrownException, retryCount) =>
- {
- AssertCore(retryCount, "CompositionException", thrownException, expectations);
- });
- }
-
- public static void ThrowsChangeRejectedRootError(ErrorId rootId, RetryMode retry, Action action)
- {
- var exception = ExceptionAssert.Throws<ChangeRejectedException>(retry, action, (thrownException, retryCount) =>
- {
- ErrorId actualId = GetRootErrorId(thrownException);
-
- Assert.AreEqual(rootId, actualId, "Retry Count {0}: Expected '{1}' to be the root ErrorId, however, '{2}' is.", retryCount, rootId, actualId);
- });
- }
-
- public static void ThrowsChangeRejectedError(ErrorId id, Action action)
- {
- ThrowsChangeRejectedError(new CompositionErrorExpectation { Id = id }, RetryMode.Retry, action);
- }
-
- public static void ThrowsChangeRejectedError(ErrorId id, RetryMode retry, Action action)
- {
- ThrowsChangeRejectedError(new CompositionErrorExpectation { Id = id, }, retry, action);
- }
-
- public static void ThrowsChangeRejectedError(ErrorId id, ICompositionElement element, Action action)
- {
- ThrowsChangeRejectedError(new CompositionErrorExpectation { Id = id, Element = element }, RetryMode.Retry, action);
- }
-
- public static void ThrowsChangeRejectedError(ErrorId id, ErrorId innerId, RetryMode retry, Action action)
- {
- ThrowsChangeRejectedError(GetExpectation(id, innerId), retry, action);
- }
-
- public static void ThrowsChangeRejectedError(ErrorId id, ErrorId innerId, ErrorId innerInnerId, Action action)
- {
- ThrowsChangeRejectedError(id, innerId, innerInnerId, RetryMode.Retry, action);
- }
-
- public static void ThrowsChangeRejectedError(ErrorId id, ErrorId innerId, ErrorId innerInnerId, RetryMode retry, Action action)
- {
- ThrowsChangeRejectedError(GetExpectation(id, innerId, innerInnerId), retry, action);
- }
-
- private static void ThrowsChangeRejectedError(CompositionErrorExpectation expectation, RetryMode retry, Action action)
- {
- ThrowsChangeRejectedErrors(new CompositionErrorExpectation[] { expectation }, retry, action);
- }
-
- public static void ThrowsChangeRejectedError(ErrorId id, ICompositionElement element, Exception exception, Action action)
- {
- ThrowsChangeRejectedError(new CompositionErrorExpectation { Id = id, Element = element, InnerException = exception }, RetryMode.Retry, action);
- }
-
- public static void ThrowsChangeRejectedErrors(ErrorId id1, ErrorId id2, RetryMode retry, Action action)
- {
- ThrowsChangeRejectedErrors(new ErrorId[] { id1, id2 }, retry, action);
- }
-
- public static void ThrowsChangeRejectedErrors(ErrorId[] ids, RetryMode retry, Action action)
- {
- CompositionErrorExpectation[] expectations = new CompositionErrorExpectation[ids.Length];
- for (int i = 0; i < expectations.Length; i++)
- {
- expectations[i] = new CompositionErrorExpectation { Id = ids[i] };
- }
-
- ThrowsChangeRejectedErrors(expectations, retry, action);
- }
-
- private static void ThrowsChangeRejectedErrors(CompositionErrorExpectation[] expectations, RetryMode retry, Action action)
- {
- ExceptionAssert.Throws<ChangeRejectedException>(retry, action, (thrownException, retryCount) =>
- {
- AssertCore(retryCount, "CompositionException", thrownException, expectations);
- });
- }
-
- private static void AssertCore(int retryCount, string prefix, CompositionException exception, CompositionErrorExpectation[] expectations)
- {
- Assert.AreEqual(exception.Errors.Count, expectations.Length);
-
- for (int i = 0; i < exception.Errors.Count; i++)
- {
- AssertCore(retryCount, prefix + ".Errors[" + i + "]", exception.Errors[i], expectations[i]);
- }
- }
-
- private static void AssertCore(int retryCount, string prefix, ICompositionError error, CompositionErrorExpectation expectation)
- {
- if (expectation.IdSpecified)
- {
- AssertCore(retryCount, prefix, "Id", expectation.Id, (ErrorId)error.Id);
- }
-
- if (expectation.ElementSpecified)
- {
- AssertCore(retryCount, prefix, "Element", expectation.Element, error.Element);
- }
-
- if (expectation.InnerExceptionSpecified)
- {
- AssertCore(retryCount, prefix, "InnerException", expectation.InnerException, error.InnerException);
- }
-
- if (expectation.InnerExceptionTypeSpecified)
- {
- AssertCore(retryCount, prefix, "InnerException.GetType()", expectation.InnerExceptionType, error.InnerException == null ? null : error.InnerException.GetType());
- }
-
- if (expectation.InnerExpectationsSpecified)
- {
- ICompositionError innerError = error.InnerException as ICompositionError;
- if (innerError != null)
- {
- Assert.AreEqual(1, expectation.InnerExpectations.Length);
- AssertCore(retryCount, prefix + ".InnerException", innerError, expectation.InnerExpectations[0]);
- }
- else
- {
- AssertCore(retryCount, prefix + ".InnerException", (CompositionException)error.InnerException, expectation.InnerExpectations);
- }
- }
- }
-
- private static void AssertCore<T>(int retryCount, string prefix, string propertyName, T expected, T actual)
- {
- Assert.AreEqual(expected, actual, "Retry Count {0}: Expected '{1}' to be {3}.{4}, however, '{2}' is.", retryCount, expected, actual, prefix, propertyName);
- }
-
- private static CompositionErrorExpectation GetExpectation(params ErrorId[] ids)
- {
- var parent = new CompositionErrorExpectation() { Id = ids[0] };
- var expectation = parent;
-
- for (int i = 1; i < ids.Length; i++)
- {
- expectation.InnerExpectations = new CompositionErrorExpectation[] { new CompositionErrorExpectation() { Id = ids[i] } };
- expectation = expectation.InnerExpectations[0];
- }
-
- return parent;
- }
-
- private static ErrorId GetRootErrorId(CompositionException exception)
- {
- Assert.IsTrue(exception.Errors.Count == 1);
-
- return GetRootErrorId(exception.Errors[0]);
- }
-
- private static ErrorId GetRootErrorId(ICompositionError error)
- {
- Exception exception = error.InnerException;
-
- var childError = exception as ICompositionError;
- if (childError != null)
- {
- return GetRootErrorId(childError);
- }
-
- CompositionException composition = exception as CompositionException;
- if (composition != null)
- {
- return GetRootErrorId(composition);
- }
-
- return (ErrorId)error.Id;
- }
-
- private class CompositionErrorExpectation
- {
- private ErrorId _id;
- private Exception _innerException;
- private Type _innerExceptionType;
- private ICompositionElement _element;
- private CompositionErrorExpectation[] _innerExpectations;
-
- public ErrorId Id
- {
- get { return _id; }
- set
- {
- _id = value;
- IdSpecified = true;
- }
- }
-
- public Exception InnerException
- {
- get { return _innerException; }
- set
- {
- _innerException = value;
- InnerExceptionSpecified = true;
- }
- }
-
- public Type InnerExceptionType
- {
- get { return _innerExceptionType; }
- set
- {
- _innerExceptionType = value;
- InnerExceptionTypeSpecified = true;
- }
- }
-
- public ICompositionElement Element
- {
- get { return _element; }
- set
- {
- _element = value;
- ElementSpecified = true;
- }
- }
-
- public CompositionErrorExpectation[] InnerExpectations
- {
- get { return _innerExpectations; }
- set
- {
- _innerExpectations = value;
- InnerExpectationsSpecified = true;
- }
- }
-
- public bool IdSpecified
- {
- get;
- private set;
- }
-
- public bool InnerExceptionSpecified
- {
- get;
- private set;
- }
-
- public bool InnerExceptionTypeSpecified
- {
- get;
- private set;
- }
-
- public bool ElementSpecified
- {
- get;
- private set;
- }
-
- public bool InnerExpectationsSpecified
- {
- get;
- private set;
- }
- }
- }
-}
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/UnitTesting/ElementAssert.cs b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/UnitTesting/ElementAssert.cs deleted file mode 100644 index 8a9a4194475..00000000000 --- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/UnitTesting/ElementAssert.cs +++ /dev/null @@ -1,42 +0,0 @@ -// -----------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// -----------------------------------------------------------------------
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.Composition.Hosting;
-using System.ComponentModel.Composition.Primitives;
-using System.Linq;
-using System.Linq.Expressions;
-using System.UnitTesting;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace System.ComponentModel.Composition.UnitTesting
-{
- internal static class ElementAssert
- {
- public static void AreEqual(ICompositionElement expected, ICompositionElement actual)
- {
- if (expected == null || actual == null)
- {
- Assert.AreEqual(expected, actual);
- return;
- }
-
- Assert.AreEqual(expected.DisplayName, actual.DisplayName);
- ElementAssert.AreEqual(expected.Origin, actual.Origin);
- }
-
- public static void AreEqual(IEnumerable<ICompositionElement> expected, IEnumerable<ICompositionElement> actual)
- {
- Assert.AreEqual(expected.Count(), actual.Count());
-
- int index = 0;
- foreach (var element in expected)
- {
- AreEqual(element, actual.ElementAt(index));
-
- index++;
- }
- }
- }
-}
\ No newline at end of file diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/UnitTesting/ErrorId.cs b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/UnitTesting/ErrorId.cs deleted file mode 100644 index 4ed1d2cbecc..00000000000 --- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/UnitTesting/ErrorId.cs +++ /dev/null @@ -1,42 +0,0 @@ -// -----------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// -----------------------------------------------------------------------
-using System;
-
-namespace System.ComponentModel.Composition
-{
- // We need a public version of CompositionErrorId, so that the QA tests can access and verify the errors.
- public enum ErrorId : int
- {
- Unknown = CompositionErrorId.Unknown,
- InvalidExportMetadata = CompositionErrorId.InvalidExportMetadata,
- RequiredMetadataNotFound = CompositionErrorId.RequiredMetadataNotFound,
- UnsupportedExportType = CompositionErrorId.UnsupportedExportType,
- ImportNotSetOnPart = CompositionErrorId.ImportNotSetOnPart,
- ImportEngine_ComposeTookTooManyIterations = CompositionErrorId.ImportEngine_ComposeTookTooManyIterations,
- ImportEngine_ImportCardinalityMismatch = CompositionErrorId.ImportEngine_ImportCardinalityMismatch,
- ImportEngine_PartCycle = CompositionErrorId.ImportEngine_PartCycle,
- ImportEngine_PartCannotSetImport = CompositionErrorId.ImportEngine_PartCannotSetImport,
- ImportEngine_PartCannotGetExportedValue = CompositionErrorId.ImportEngine_PartCannotGetExportedValue,
- ImportEngine_PartCannotActivate = CompositionErrorId.ImportEngine_PartCannotActivate,
- ImportEngine_PreventedByExistingImport = CompositionErrorId.ImportEngine_PreventedByExistingImport,
- ImportEngine_InvalidStateForRecomposition = CompositionErrorId.ImportEngine_InvalidStateForRecomposition,
- ReflectionModel_PartConstructorMissing = CompositionErrorId.ReflectionModel_PartConstructorMissing,
- ReflectionModel_PartConstructorThrewException = CompositionErrorId.ReflectionModel_PartConstructorThrewException,
- ReflectionModel_PartOnImportsSatisfiedThrewException = CompositionErrorId.ReflectionModel_PartOnImportsSatisfiedThrewException,
- ReflectionModel_ExportNotReadable = CompositionErrorId.ReflectionModel_ExportNotReadable,
- ReflectionModel_ExportThrewException = CompositionErrorId.ReflectionModel_ExportThrewException,
- ReflectionModel_ExportMethodTooManyParameters = CompositionErrorId.ReflectionModel_ExportMethodTooManyParameters,
- ReflectionModel_ImportNotWritable = CompositionErrorId.ReflectionModel_ImportNotWritable,
- ReflectionModel_ImportThrewException = CompositionErrorId.ReflectionModel_ImportThrewException,
- ReflectionModel_ImportNotAssignableFromExport = CompositionErrorId.ReflectionModel_ImportNotAssignableFromExport,
- ReflectionModel_ImportCollectionNull = CompositionErrorId.ReflectionModel_ImportCollectionNull,
- ReflectionModel_ImportCollectionNotWritable = CompositionErrorId.ReflectionModel_ImportCollectionNotWritable,
- ReflectionModel_ImportCollectionConstructionThrewException = CompositionErrorId.ReflectionModel_ImportCollectionConstructionThrewException,
- ReflectionModel_ImportCollectionGetThrewException = CompositionErrorId.ReflectionModel_ImportCollectionGetThrewException,
- ReflectionModel_ImportCollectionIsReadOnlyThrewException = CompositionErrorId.ReflectionModel_ImportCollectionIsReadOnlyThrewException,
- ReflectionModel_ImportCollectionClearThrewException = CompositionErrorId.ReflectionModel_ImportCollectionClearThrewException,
- ReflectionModel_ImportCollectionAddThrewException = CompositionErrorId.ReflectionModel_ImportCollectionAddThrewException,
- ReflectionModel_ImportManyOnParameterCanOnlyBeAssigned = CompositionErrorId.ReflectionModel_ImportManyOnParameterCanOnlyBeAssigned,
- }
-}
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/UnitTesting/ExportsAssert.cs b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/UnitTesting/ExportsAssert.cs deleted file mode 100644 index d68a4ba1505..00000000000 --- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/UnitTesting/ExportsAssert.cs +++ /dev/null @@ -1,30 +0,0 @@ -// -----------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// -----------------------------------------------------------------------
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-using System.UnitTesting;
-using System.ComponentModel.Composition.Primitives;
-
-namespace System.ComponentModel.Composition.UnitTesting
-{
- public static class ExportsAssert
- {
- public static void AreEqual<T>(IEnumerable<Export> actual, params T[] expected)
- {
- EnumerableAssert.AreEqual((IEnumerable)expected, (IEnumerable)actual.Select(export => export.Value));
- }
-
- public static void AreEqual<T>(IEnumerable<Lazy<T>> actual, params T[] expected)
- {
- EnumerableAssert.AreEqual((IEnumerable<T>)expected, (IEnumerable<T>)actual.Select(export => export.Value));
- }
-
- public static void AreEqual<T, TMetadataView>(IEnumerable<Lazy<T, TMetadataView>> actual, params T[] expected)
- {
- EnumerableAssert.AreEqual((IEnumerable<T>)expected, (IEnumerable<T>)actual.Select(export => export.Value));
- }
- }
-}
|