Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System')
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/.gitattributes4
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Collections/.gitattributes1
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Collections/EnumerableExtensions.cs72
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Collections/Generic/.gitattributes1
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Collections/Generic/DictionaryExtensions.cs60
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/.gitattributes1
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/ConstraintParser.cs225
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/Diagnostics/.gitattributes4
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/Diagnostics/TraceContext.TraceContextTraceListener.cs42
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/Diagnostics/TraceContext.cs44
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/Diagnostics/TraceEventDetails.cs62
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/Diagnostics/TraceId.cs21
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/Hosting/.gitattributes1
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/Hosting/CompositionHostTestService.cs46
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/ReflectionModel/.gitattributes1
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/ReflectionModel/ReflectionModelServicesEx.cs155
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/UnitTesting/.gitattributes4
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/UnitTesting/CompositionAssert.cs439
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/UnitTesting/ElementAssert.cs42
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/UnitTesting/ErrorId.cs42
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ComponentModel/Composition/UnitTesting/ExportsAssert.cs30
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/DisposableObject.cs21
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/EnumExtensions.cs20
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Globalization/.gitattributes1
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Globalization/CurrentCultureContext.cs29
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/IO/.gitattributes4
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/IO/FileIO.cs50
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/IO/TemporaryDirectory.cs43
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/IO/TemporaryFile.cs35
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/IO/TemporaryFileCopier.cs22
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ReferenceTracker.cs43
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Runtime/Serialization/.gitattributes2
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Runtime/Serialization/SerializationTestServices.cs155
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Runtime/Serialization/StrictFormatterConverter.cs106
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/TypeExtensions.cs21
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/.gitattributes10
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/EnumerableAssert.cs204
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/ExceptionAssert.cs326
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/ExpectationCollectionOfI.cs30
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/ExpectationCollectionOfIO.cs16
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/ExpectationOfI.cs16
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/ExpectationOfIO.cs28
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/ExtendedAssert.cs70
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/ReflectionAssert.cs40
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/RetryMode.cs14
-rw-r--r--mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/TestServices.cs30
46 files changed, 0 insertions, 2633 deletions
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/.gitattributes b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/.gitattributes
deleted file mode 100644
index ed47a6216df..00000000000
--- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/.gitattributes
+++ /dev/null
@@ -1,4 +0,0 @@
-/DisposableObject.cs -crlf
-/EnumExtensions.cs -crlf
-/ReferenceTracker.cs -crlf
-/TypeExtensions.cs -crlf
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Collections/.gitattributes b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Collections/.gitattributes
deleted file mode 100644
index e27dae9bcb6..00000000000
--- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Collections/.gitattributes
+++ /dev/null
@@ -1 +0,0 @@
-/EnumerableExtensions.cs -crlf
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Collections/EnumerableExtensions.cs b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Collections/EnumerableExtensions.cs
deleted file mode 100644
index efb9c82994f..00000000000
--- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Collections/EnumerableExtensions.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-// -----------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// -----------------------------------------------------------------------
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace Microsoft.Internal.Collections
-{
- public static class EnumerableExtensions
- {
- public static int Count(this IEnumerable source)
- {
- int count = 0;
-
- foreach (object o in source)
- {
- count++;
- }
-
- return count;
- }
-
- public static IEnumerable<T> ToEnumerable<T>(this IEnumerable source)
- {
- foreach (object value in source)
- {
- yield return (T)value;
- }
- }
-
- public static List<object> ToList(this IEnumerable source)
- {
- var enumerable = source.ToEnumerable<object>();
-
- return System.Linq.Enumerable.ToList(enumerable);
- }
-
- public static T AssertSingle<T>(this IEnumerable<T> source)
- {
- return AssertSingle(source, t => true);
- }
-
- public static T AssertSingle<T>(this IEnumerable<T> source, string message)
- {
- return AssertSingle(source, t => true, message);
- }
-
- public static T AssertSingle<T>(this IEnumerable<T> source, Func<T, bool> predicate)
- {
- return AssertSingle(source, predicate, "Expecting a single item matching the predicate in the collection.");
- }
-
- public static T AssertSingle<T>(this IEnumerable<T> source, Func<T, bool> predicate, string message)
- {
- int count = 0;
- T ret = default(T);
- foreach (T t in source)
- {
- if (predicate(t))
- {
- count++;
- ret = t;
- }
- }
-
- Assert.AreEqual(1, count, message);
- return ret;
- }
- }
-}
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Collections/Generic/.gitattributes b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Collections/Generic/.gitattributes
deleted file mode 100644
index f96646a32c5..00000000000
--- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Collections/Generic/.gitattributes
+++ /dev/null
@@ -1 +0,0 @@
-/DictionaryExtensions.cs -crlf
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Collections/Generic/DictionaryExtensions.cs b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Collections/Generic/DictionaryExtensions.cs
deleted file mode 100644
index c9942406cde..00000000000
--- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Collections/Generic/DictionaryExtensions.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-// -----------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// -----------------------------------------------------------------------
-using System;
-using System.Collections.Generic;
-
-namespace Microsoft.Internal.Collections
-{
- public static class DictionaryExtensions
- {
- public static bool ContainsAllKeys<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, IEnumerable<TKey> keys)
- {
- foreach (TKey key in keys)
- {
- if (!dictionary.ContainsKey(key))
- return false;
- }
-
- return true;
- }
-
- public static bool DictionaryEquals<TKey, TValue>(this IDictionary<TKey, TValue> dictionary1, IDictionary<TKey, TValue> dictionary2)
- {
- if (dictionary1.Keys.Count != dictionary2.Keys.Count)
- {
- return false;
- }
-
- foreach (KeyValuePair<TKey, TValue> kvp in dictionary1)
- {
- TValue value1 = kvp.Value;
- TValue value2 = default(TValue);
- if (!dictionary2.TryGetValue(kvp.Key, out value2))
- {
- return false;
- }
-
- IDictionary<TKey, TValue> nestedDictionary1 = value1 as IDictionary<TKey, TValue>;
- IDictionary<TKey, TValue> nestedDictionary2 = value1 as IDictionary<TKey, TValue>;
-
- if ((nestedDictionary1 != null) && (nestedDictionary2 != null))
- {
- if (!nestedDictionary1.DictionaryEquals(nestedDictionary2))
- {
- return false;
- }
- }
- else
- {
- if (!(value1.Equals(value2)))
- {
- return false;
- }
- }
- }
-
- return true;
- }
- }
-} \ No newline at end of file
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));
- }
- }
-}
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/DisposableObject.cs b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/DisposableObject.cs
deleted file mode 100644
index 5b7ba3cd135..00000000000
--- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/DisposableObject.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// -----------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// -----------------------------------------------------------------------
-using System;
-
-namespace System
-{
- public class DisposableObject : IDisposable
- {
- public int DisposeCount
- {
- get;
- private set;
- }
-
- public void Dispose()
- {
- DisposeCount++;
- }
- }
-} \ No newline at end of file
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/EnumExtensions.cs b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/EnumExtensions.cs
deleted file mode 100644
index f6314786173..00000000000
--- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/EnumExtensions.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-// -----------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// -----------------------------------------------------------------------
-#if !CLR40
-using System;
-
-namespace System
-{
- public static class EnumExtensions
- {
- public static bool HasFlag(this Enum enumRef, Enum flag)
- {
- long value = Convert.ToInt64(enumRef);
- long flagVal = Convert.ToInt64(flag);
-
- return (value & flagVal) == flagVal;
- }
- }
-}
-#endif
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Globalization/.gitattributes b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Globalization/.gitattributes
deleted file mode 100644
index f5c09b62787..00000000000
--- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Globalization/.gitattributes
+++ /dev/null
@@ -1 +0,0 @@
-/CurrentCultureContext.cs -crlf
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Globalization/CurrentCultureContext.cs b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Globalization/CurrentCultureContext.cs
deleted file mode 100644
index 6210c7f9aa6..00000000000
--- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Globalization/CurrentCultureContext.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-// -----------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// -----------------------------------------------------------------------
-using System;
-using System.Globalization;
-using System.Threading;
-
-namespace System.Globalization
-{
- public class CurrentCultureContext : IDisposable
- {
- private CultureInfo _previousCulture;
-
- public CurrentCultureContext(CultureInfo culture)
- {
- _previousCulture = Thread.CurrentThread.CurrentCulture;
-
- Thread.CurrentThread.CurrentCulture = culture;
- }
-
- public void Dispose()
- {
- if (_previousCulture != null)
- {
- Thread.CurrentThread.CurrentCulture = _previousCulture;
- }
- }
- }
-} \ No newline at end of file
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/IO/.gitattributes b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/IO/.gitattributes
deleted file mode 100644
index bca099de401..00000000000
--- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/IO/.gitattributes
+++ /dev/null
@@ -1,4 +0,0 @@
-/FileIO.cs -crlf
-/TemporaryDirectory.cs -crlf
-/TemporaryFile.cs -crlf
-/TemporaryFileCopier.cs -crlf
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/IO/FileIO.cs b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/IO/FileIO.cs
deleted file mode 100644
index d004fd7c7de..00000000000
--- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/IO/FileIO.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-// -----------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// -----------------------------------------------------------------------
-using System;
-using System.Reflection;
-using System.UnitTesting;
-
-namespace System.IO
-{
- public static class FileIO
- {
- public const string RootTemporaryDirectoryName = "RootTempDirectory";
-
- private static string _temporaryDirectory;
- public static string GetRootTemporaryDirectory()
- {
- if (_temporaryDirectory == null)
- {
-#if SILVERLIGHT
- string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), RootTemporaryDirectoryName);
-#else
- string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, RootTemporaryDirectoryName);
-#endif
-
- if (!Directory.Exists(path))
- {
- Directory.CreateDirectory(path);
- }
-
- _temporaryDirectory = path;
- }
-
- return _temporaryDirectory;
- }
-
- public static string GetNewTemporaryDirectory()
- {
- string path = Path.Combine(GetRootTemporaryDirectory(), TestServices.GenerateRandomString());
-
- Directory.CreateDirectory(path);
-
- return path;
- }
-
- public static string GetTemporaryFileName(string extension)
- {
- return Path.Combine(GetRootTemporaryDirectory(), TestServices.GenerateRandomString() + "." + extension);
- }
- }
-}
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/IO/TemporaryDirectory.cs b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/IO/TemporaryDirectory.cs
deleted file mode 100644
index 7f373a292f5..00000000000
--- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/IO/TemporaryDirectory.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-// -----------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// -----------------------------------------------------------------------
-
-#if !SILVERLIGHT
-
-using System;
-
-namespace System.IO
-{
- public class TemporaryDirectory : IDisposable
- {
- private string _directoryPath;
-
- public TemporaryDirectory()
- {
- _directoryPath = FileIO.GetNewTemporaryDirectory();
- }
-
- public string DirectoryPath
- {
- get { return _directoryPath; }
- }
-
- public void Dispose()
- {
- if (_directoryPath != null)
- {
- try
- {
- Directory.Delete(_directoryPath, true);
- }
- catch (IOException)
- {
- }
-
- _directoryPath = null;
- }
- }
- }
-}
-
-#endif \ No newline at end of file
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/IO/TemporaryFile.cs b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/IO/TemporaryFile.cs
deleted file mode 100644
index 69fda640ef6..00000000000
--- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/IO/TemporaryFile.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-// -----------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// -----------------------------------------------------------------------
-#if !SILVERLIGHT
-
-using System;
-
-namespace System.IO
-{
- public class TemporaryFile : IDisposable
- {
- private string _fileName;
-
- public TemporaryFile()
- {
- _fileName = Path.GetTempFileName();
- }
-
- public string FileName
- {
- get { return _fileName; }
- }
-
- public void Dispose()
- {
- if (_fileName != null)
- {
- File.Delete(_fileName);
- _fileName = null;
- }
- }
- }
-}
-
-#endif \ No newline at end of file
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/IO/TemporaryFileCopier.cs b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/IO/TemporaryFileCopier.cs
deleted file mode 100644
index d1ae9070ba5..00000000000
--- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/IO/TemporaryFileCopier.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-// -----------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// -----------------------------------------------------------------------
-#if !SILVERLIGHT
-
-using System;
-
-namespace System.IO
-{
- public class TemporaryFileCopier : TemporaryDirectory
- {
- public TemporaryFileCopier(params string[] fileNames)
- {
- foreach (string fileName in fileNames)
- {
- File.Copy(fileName, Path.Combine(DirectoryPath, Path.GetFileName(fileName)));
- }
- }
- }
-}
-
-#endif \ No newline at end of file
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ReferenceTracker.cs b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ReferenceTracker.cs
deleted file mode 100644
index b803e62f604..00000000000
--- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/ReferenceTracker.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-// -----------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// -----------------------------------------------------------------------
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.UnitTesting;
-
-namespace System
-{
- public class ReferenceTracker
- {
- public readonly List<WeakReference> ReferencesExpectedToBeCollected = new List<WeakReference>();
- public readonly List<WeakReference> ReferencesNotExpectedToBeCollected = new List<WeakReference>();
-
- public void AddReferencesExpectedToBeCollected(params object[] objects)
- {
- for (int i = 0; i < objects.Length; i++)
- {
- ReferencesExpectedToBeCollected.Add(new WeakReference(objects[i]));
- objects[i] = null;
- }
- }
-
- public void AddReferencesNotExpectedToBeCollected(params object[] objects)
- {
- for (int i = 0; i < objects.Length; i++)
- {
- ReferencesNotExpectedToBeCollected.Add(new WeakReference(objects[i]));
- objects[i] = null;
- }
- }
-
- public void CollectAndAssert()
- {
- GC.Collect();
- GC.WaitForPendingFinalizers();
-
- EnumerableAssert.IsTrueForAll(ReferencesExpectedToBeCollected, wr => wr.Target == null, "Object should have been collected.");
- EnumerableAssert.IsTrueForAll(ReferencesNotExpectedToBeCollected, wr => wr.Target != null, "Object should be have NOT been collected.");
- }
- }
-}
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Runtime/Serialization/.gitattributes b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Runtime/Serialization/.gitattributes
deleted file mode 100644
index 3ed0af6a232..00000000000
--- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Runtime/Serialization/.gitattributes
+++ /dev/null
@@ -1,2 +0,0 @@
-/SerializationTestServices.cs -crlf
-/StrictFormatterConverter.cs -crlf
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Runtime/Serialization/SerializationTestServices.cs b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Runtime/Serialization/SerializationTestServices.cs
deleted file mode 100644
index 338b520cf94..00000000000
--- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Runtime/Serialization/SerializationTestServices.cs
+++ /dev/null
@@ -1,155 +0,0 @@
-// -----------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// -----------------------------------------------------------------------
-#if !SILVERLIGHT
-
-using System;
-using System.IO;
-using System.Runtime.Serialization.Formatters.Binary;
-using System.Reflection;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace System.Runtime.Serialization
-{
- public static class SerializationTestServices
- {
- /// <summary>
- /// Serializes and then deserializes the specified value.
- /// </summary>
- public static T RoundTrip<T>(T value)
- {
- Assert.IsNotNull(value);
-
- using (MemoryStream stream = new MemoryStream())
- {
- BinaryFormatter formatter = new BinaryFormatter();
- formatter.Serialize(stream, value);
-
- stream.Seek(0, SeekOrigin.Begin);
- return (T)formatter.Deserialize(stream);
- }
- }
-
- /// <summary>
- /// Creates an instance of a type using the serialization constructor.
- /// </summary>
- public static T Create<T>(SerializationInfo info, StreamingContext context)
- {
- ConstructorInfo constructor = typeof(T).GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null,
- new Type[] { typeof(SerializationInfo), typeof(StreamingContext) },
- (ParameterModifier[])null);
-
- Assert.IsNotNull(constructor, "Type does not have a private or protected serialization constructor.");
-
- try
- {
- return (T)constructor.Invoke(new object[] { info, context });
- }
- catch (TargetInvocationException ex)
- {
- throw ex.InnerException;
- }
- }
-
- /// <summary>
- /// Returns a new instance of <see cref="SerializationInfo"/> replacing the specified member name with the specified value.
- /// </summary>
- public static SerializationInfo CreateSerializationInfoReplacingMember<T>(string memberName, object value)
- where T : ISerializable, new()
- {
- return CreateSerializationInfoReplacingMember(memberName, value, () => new T());
- }
-
- /// <summary>
- /// Returns a new instance of <see cref="SerializationInfo"/> replacing the specified member name with the specified value.
- /// </summary>
- public static SerializationInfo CreateSerializationInfoReplacingMember<T>(string memberName, object value, Func<T> creator)
- where T : ISerializable
- {
- T serializableObject = creator();
-
- var info = GetObjectDataFrom(serializableObject);
-
- return CloneReplacingMember<T>(info, memberName, value);
- }
-
- /// <summary>
- /// Returns a new instance of <see cref="SerializationInfo"/> removing the specified member name.
- /// </summary>
- public static SerializationInfo CreateSerializationInfoRemovingMember<T>(string memberName)
- where T : ISerializable, new()
- {
- return CreateSerializationInfoRemovingMember(memberName, () => new T());
- }
-
- /// <summary>
- /// Returns a new instance of <see cref="SerializationInfo"/> removing the specified member name.
- /// </summary>
- public static SerializationInfo CreateSerializationInfoRemovingMember<T>(string memberName, Func<T> creator)
- where T : ISerializable
- {
- T serializableObject = creator();
-
- var info = GetObjectDataFrom(serializableObject);
-
- return CloneRemovingMember<T>(info, memberName);
- }
-
- private static SerializationInfo CloneReplacingMember<T>(SerializationInfo info, string memberName, object value)
- {
- return Clone<T>(info, (entry, clone) =>
- {
- if (entry.Name != memberName)
- {
- return true;
- }
-
- // Replace the entry
- clone.AddValue(entry.Name, value, value == null ? entry.ObjectType : value.GetType());
- return false;
- });
- }
-
- private static SerializationInfo CloneRemovingMember<T>(SerializationInfo info, string memberName)
- {
- return Clone<T>(info, (entry, clone) =>
- {
- // Add everything except the member we want to remove
- return entry.Name != memberName;
- });
- }
-
- private static SerializationInfo Clone<T>(SerializationInfo info, Func<SerializationEntry, SerializationInfo, bool> predicate)
- {
- var clone = GetEmptySerializationInfo<T>();
-
- foreach (var entry in info)
- {
- if (predicate(entry, clone))
- {
- clone.AddValue(entry.Name, entry.Value, entry.ObjectType);
- }
- }
-
- return clone;
- }
-
- private static SerializationInfo GetObjectDataFrom<T>(T serializableObject) where T : ISerializable
- {
- var info = GetEmptySerializationInfo<T>();
-
- serializableObject.GetObjectData(info, new StreamingContext());
-
- return info;
- }
-
- private static SerializationInfo GetEmptySerializationInfo<T>()
- {
- StrictFormatterConverter converter = new StrictFormatterConverter();
-
- return new SerializationInfo(typeof(T), converter);
- }
- }
-}
-
-#endif // !SILVERLIGHT \ No newline at end of file
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Runtime/Serialization/StrictFormatterConverter.cs b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Runtime/Serialization/StrictFormatterConverter.cs
deleted file mode 100644
index 29e68d753b3..00000000000
--- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/Runtime/Serialization/StrictFormatterConverter.cs
+++ /dev/null
@@ -1,106 +0,0 @@
-// -----------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// -----------------------------------------------------------------------
-#if !SILVERLIGHT
-
-using System;
-
-namespace System.Runtime.Serialization
-{
- /// <summary>
- /// Represents an <see cref="IFormatterConverter"/> where no conversion is actually performed.
- /// </summary>
- public class StrictFormatterConverter : IFormatterConverter
- {
- public object Convert(object value, TypeCode typeCode)
- {
- return value;
- }
-
- public object Convert(object value, Type type)
- {
- return value;
- }
-
- public bool ToBoolean(object value)
- {
- return (bool)value;
- }
-
- public byte ToByte(object value)
- {
- return (byte)value;
- }
-
- public char ToChar(object value)
- {
- return (char)value;
- }
-
- public DateTime ToDateTime(object value)
- {
- return (DateTime)value;
- }
-
- public decimal ToDecimal(object value)
- {
- return (decimal)value;
- }
-
- public double ToDouble(object value)
- {
- return (double)value;
- }
-
- public short ToInt16(object value)
- {
- return (short)value;
- }
-
- public int ToInt32(object value)
- {
- return (int)value;
- }
-
- public long ToInt64(object value)
- {
- return (long)value;
- }
-
- [CLSCompliant(false)]
- public sbyte ToSByte(object value)
- {
- return (sbyte)value;
- }
-
- public float ToSingle(object value)
- {
- return (float)value;
- }
-
- public string ToString(object value)
- {
- return (string)value;
- }
-
- [CLSCompliant(false)]
- public ushort ToUInt16(object value)
- {
- return (ushort)value;
- }
-
- [CLSCompliant(false)]
- public uint ToUInt32(object value)
- {
- return (uint)value;
- }
-
- [CLSCompliant(false)]
- public ulong ToUInt64(object value)
- {
- return (ulong)value;
- }
- }
-}
-
-#endif // !SILVERLIGHT \ No newline at end of file
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/TypeExtensions.cs b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/TypeExtensions.cs
deleted file mode 100644
index 55d0fb1b22b..00000000000
--- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/TypeExtensions.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// -----------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// -----------------------------------------------------------------------
-using System;
-using System.Linq;
-using System.Reflection;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace System
-{
- public static class TypeExtensions
- {
- public static MemberInfo GetSingleMember(this Type type, string name)
- {
- Assert.IsNotNull(type);
- Assert.IsNotNull(name);
-
- return type.GetMember(name).Single();
- }
- }
-}
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/.gitattributes b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/.gitattributes
deleted file mode 100644
index 7c48b21042d..00000000000
--- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/.gitattributes
+++ /dev/null
@@ -1,10 +0,0 @@
-/EnumerableAssert.cs -crlf
-/ExceptionAssert.cs -crlf
-/ExpectationCollectionOfI.cs -crlf
-/ExpectationCollectionOfIO.cs -crlf
-/ExpectationOfI.cs -crlf
-/ExpectationOfIO.cs -crlf
-/ExtendedAssert.cs -crlf
-/ReflectionAssert.cs -crlf
-/RetryMode.cs -crlf
-/TestServices.cs -crlf
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/EnumerableAssert.cs b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/EnumerableAssert.cs
deleted file mode 100644
index 35331181341..00000000000
--- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/EnumerableAssert.cs
+++ /dev/null
@@ -1,204 +0,0 @@
-// -----------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// -----------------------------------------------------------------------
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Collections;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Microsoft.Internal.Collections;
-
-namespace System.UnitTesting
-{
- public static class EnumerableAssert
- {
- public static void IsTrueForAll<T>(IEnumerable<T> source, Predicate<T> predicate)
- {
- IsTrueForAll(source, predicate, "IsTrueForAll Failed");
- }
-
- public static void IsTrueForAll<T>(IEnumerable<T> source, Predicate<T> predicate, string message)
- {
- Assert.IsNotNull(source, "Source should not be null!");
-
- foreach (T t in source)
- {
- Assert.IsTrue(predicate(t), message);
- }
- }
-
- // Needed to prevent strings from matching to the plain IEnumerable overload
- public static void AreEqual(IEnumerable actual, params string[] expected)
- {
- AreEqual((IEnumerable)expected, (IEnumerable)actual);
- }
-
- public static void AreEqual(IEnumerable actual, params object[] expected)
- {
- AreEqual((IEnumerable)expected, (IEnumerable)actual);
- }
-
- public static void AreEqual<T>(IEnumerable<T> actual, params T[] expected)
- {
- AreEqual<T>((IEnumerable<T>)expected, (IEnumerable<T>)actual);
- }
-
- public static void AreEqual(IEnumerable expected, IEnumerable actual)
- {
- Assert.AreEqual(expected.Count(), actual.Count(), "Enumerable should contain the correct number of items");
-
- List<object> actualList = actual.ToList();
-
- foreach (object value in expected)
- {
- bool removed = actualList.Remove(value);
-
- Assert.IsTrue(removed, "Enumerable does not contain value {0}.", value);
- }
-
- Assert.AreEqual(0, actualList.Count, "Enumerable contains extra values.");
- }
-
- public static void AreEqual<T>(IEnumerable<T> expected, IEnumerable<T> actual)
- {
- // First, test the IEnumerable implementation
- AreEqual((IEnumerable)expected, (IEnumerable)actual);
-
- // Second, test the IEnumerable<T> implementation
- Assert.AreEqual(expected.Count(), actual.Count(), "Enumerable should contain the correct number of items");
-
- List<T> actualList = actual.ToList();
-
- foreach (T value in expected)
- {
- bool removed = actualList.Remove(value);
-
- Assert.IsTrue(removed, "Enumerable does not contain value {0}.", value);
- }
-
- Assert.AreEqual(0, actualList.Count, "Enumerable contains extra values.");
- }
-
- // Needed to prevent strings from matching to the plain IEnumerable overload
- public static void AreSequenceEqual(IEnumerable actual, params string[] expected)
- {
- AreEqual((IEnumerable)expected, (IEnumerable)actual);
- }
-
- public static void AreSequenceEqual(IEnumerable actual, params object[] expected)
- {
- AreEqual((IEnumerable)expected, (IEnumerable)actual);
- }
-
- public static void AreSequenceEqual(IEnumerable expected, IEnumerable actual)
- {
- AreSequenceEqual(expected, actual, (Action<int, object, object>)null);
- }
-
- public static void AreSequenceEqual(IEnumerable expected, IEnumerable actual, Action<int, object, object> comparer)
- {
- if (comparer == null)
- {
- comparer = (i, left, right) => Assert.AreEqual(left, right, "Enumerable at index {0} should have same value", i);
- }
-
- int expectedCount = expected.Count();
-
- Assert.AreEqual(expectedCount, actual.Count(), "Enumerable should contain the correct number of items");
-
- IEnumerator actualEnumerator = actual.GetEnumerator();
- IEnumerator expectedEnumerator = expected.GetEnumerator();
-
- int index = 0;
- while (index < expectedCount)
- {
- Assert.IsTrue(actualEnumerator.MoveNext());
- Assert.IsTrue(expectedEnumerator.MoveNext());
-
- comparer(index, expectedEnumerator.Current, actualEnumerator.Current);
- index++;
- }
- }
-
- public static void AreSequenceEqual<T>(IEnumerable<T> actual, params T[] expected)
- {
- AreSequenceEqual<T>((IEnumerable<T>)expected, (IEnumerable<T>)actual);
- }
-
- public static void AreSequenceEqual<T>(IEnumerable<T> expected, IEnumerable<T> actual)
- {
- AreSequenceEqual<T>(expected, actual, (Action<int, T, T>)null);
- }
-
- public static void AreSequenceEqual<T>(IEnumerable<T> expected, IEnumerable<T> actual, Action<int, T, T> comparer)
- {
- if (comparer == null)
- {
- comparer = (i, left, right) => Assert.AreEqual(left, right, "Enumerable at index {0} should have same value", i);
- }
-
- // First, test the IEnumerable implementation
- AreSequenceEqual((IEnumerable)expected, (IEnumerable)actual, (Action<int, object, object>)((currentIndex, left, right) => comparer(currentIndex, (T)left, (T)right)));
-
- // Second, test the IEnumerable<T> implementation
- int expectedCount = expected.Count();
-
- IEnumerator<T> actualEnumerator = actual.GetEnumerator();
- IEnumerator<T> expectedEnumerator = expected.GetEnumerator();
-
- int index = 0;
- while (index < expectedCount)
- {
- Assert.IsTrue(actualEnumerator.MoveNext());
- Assert.IsTrue(expectedEnumerator.MoveNext());
-
- comparer(index, expectedEnumerator.Current, actualEnumerator.Current);
- index++;
- }
- }
-
- public static void AreSequenceSame<T>(IEnumerable<T> expected, IEnumerable<T> actual)
- {
- AreSequenceEqual<T>(expected, actual, (index, left, right) =>
- {
- Assert.AreSame(left, right, "Enumerable at index {0} should have same value", index);
- });
- }
-
- public static void AreEqual<TKey, TValue>(IDictionary<TKey, TValue> expected, IDictionary<TKey, TValue> actual)
- {
- Assert.AreEqual(expected.Count, actual.Count, "Dictionaries are different : first has '{0} elements, whereas second has '{1}", expected.Count, actual.Count);
-
- foreach (KeyValuePair<TKey, TValue> kvp in expected)
- {
- TValue firstValue = kvp.Value;
- TValue secondValue = default(TValue);
- if (!actual.TryGetValue(kvp.Key, out secondValue))
- {
- Assert.Fail("Dictionaries are different : There is no item with key '{0}' in the second dictionary", kvp.Key);
- }
-
- if ((firstValue is IDictionary<TKey, TValue>) && (secondValue is IDictionary<TKey, TValue>))
- {
- AreEqual((IDictionary<TKey, TValue>)firstValue, (IDictionary<TKey, TValue>)secondValue);
- continue;
- }
-
- Assert.AreEqual(kvp.Value, secondValue, "Dictionaries are different : values for key '{0}' are different - '{1}' vs '{2}'", kvp.Key, firstValue, secondValue);
- }
- }
-
- /// <summary>
- /// Verifies that the specified enumerable is empty.
- /// </summary>
- public static void IsEmpty(IEnumerable source)
- {
- IsEmpty(source, null);
- }
-
- public static void IsEmpty(IEnumerable source, string message)
- {
- Assert.AreEqual(0, source.Count(), message);
- }
- }
-}
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/ExceptionAssert.cs b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/ExceptionAssert.cs
deleted file mode 100644
index c75dcc759ba..00000000000
--- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/ExceptionAssert.cs
+++ /dev/null
@@ -1,326 +0,0 @@
-// -----------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// -----------------------------------------------------------------------
-using System;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System.Runtime.Serialization;
-
-namespace System.UnitTesting
-{
- public static class ExceptionAssert
- {
- // NOTE: To catch state corrupting exceptions, it by design that
- // the ThrowsXXX methods retry by default. To prevent this in a
- // test, simply use one of the overloads that takes a RetryMode.
-
- /// <summary>
- /// Verifies that the exception has the default message generated by the base Exception class.
- /// </summary>
- public static void HasDefaultMessage(Exception exception)
- {
- Assert.IsNotNull(exception);
-
- // Exception of type '[typename]' was thrown
- StringAssert.Contains(exception.Message, exception.GetType().FullName);
- }
-
- /// <summary>
- /// Verifies that the specified action throws a SerializationException.
- /// </summary>
- public static SerializationException ThrowsSerialization(string memberName, Action action)
- {
- var exception = Throws<SerializationException>(RetryMode.Retry, action, (actual, retryCount) =>
- {
- AssertSerializationMemberName(memberName, actual, retryCount);
- });
-
- return exception;
- }
-
- /// <summary>
- /// Verifies that the specified action throws an ObjectDisposedException.
- /// </summary>
- public static ObjectDisposedException ThrowsDisposed(object instance, Action action)
- {
- var exception = Throws<ObjectDisposedException>(RetryMode.Retry, action, (actual, retryCount) =>
- {
- AssertObjectDisposed(instance, actual, retryCount);
- });
-
- return exception;
- }
-
- /// <summary>
- /// Verifies that the specified action throws an ArgumentNullException.
- /// </summary>
- public static ArgumentNullException ThrowsArgumentNull(string parameterName, Action action)
- {
- return ThrowsArgument<ArgumentNullException>(parameterName, action);
- }
-
- /// <summary>
- /// Verifies that the specified action throws an ArgumentException.
- /// </summary>
- public static ArgumentException ThrowsArgument(string parameterName, Action action)
- {
- return ThrowsArgument<ArgumentException>(parameterName, action);
- }
-
- /// <summary>
- /// Verifies that the specified action throws an ArgumentException of type <typeparam name="T"/>.
- /// </summary>
- public static T ThrowsArgument<T>(string parameterName, Action action)
- where T : ArgumentException
- {
- var exception = Throws<T>(RetryMode.Retry, action, (actual, retryCount) =>
- {
- AssertSameParameterName(parameterName, actual, retryCount);
- });
-
- return exception;
- }
-
- /// <summary>
- /// Verifies that the specified action throws an exception of type <typeparam name="T"/>,
- /// with the specified inner exception of type <typeparam name="TInner"/>.
- /// </summary>
- public static T Throws<T, TInner>(Action action)
- where T : Exception
- where TInner : Exception
- {
- return Throws<T, TInner>(RetryMode.Retry, action);
- }
-
- /// <summary>
- /// Verifies that the specified action throws an exception of type <typeparam name="T"/>,
- /// with the specified inner exception of type <typeparam name="TInner"/>, and indicating
- /// whether to retry.
- /// </summary>
- public static T Throws<T, TInner>(RetryMode retry, Action action)
- where T : Exception
- where TInner : Exception
- {
- return Throws<T, TInner>(retry, action, (Action<T, int>)null);
- }
-
- /// <summary>
- /// Verifies that the specified action throws an exception of type <typeparam name="T"/>,
- /// with the specified inner exception of type <typeparam name="TInner"/>, indicating
- /// whether to retry and running the specified validator.
- /// </summary>
- public static T Throws<T, TInner>(RetryMode retry, Action action, Action<T, int> validator)
- where T : Exception
- where TInner : Exception
- {
- var exception = Throws<T>(retry, action, (actual, retryCount) =>
- {
- AssertIsExactInstanceOfInner(typeof(TInner), actual, retryCount);
-
- if (validator != null)
- {
- validator(actual, retryCount);
- }
- });
-
- return exception;
- }
-
- /// <summary>
- /// Verifies that the specified action throws an exception of type <typeparam name="T"/>,
- /// with the specified inner exception.
- /// </summary>
- public static T Throws<T>(Exception innerException, Action action)
- where T : Exception
- {
- return Throws<T>(innerException, RetryMode.Retry, action, (Action<T, int>)null);
- }
-
- /// <summary>
- /// Verifies that the specified action throws an exception of type <typeparam name="T"/>,
- /// with the specified inner exception, and indicating whether to retry.
- /// </summary>
- public static T Throws<T>(Exception innerException, RetryMode retry, Action action)
- where T : Exception
- {
- return Throws<T>(innerException, RetryMode.Retry, action, (Action<T, int>)null);
- }
-
- /// <summary>
- /// Verifies that the specified action throws an exception of type <typeparam name="T"/>,
- /// with the specified inner exception, indicating whether to retry and running the
- /// specified validator.
- /// </summary>
- public static T Throws<T>(Exception innerException, RetryMode retry, Action action, Action<T, int> validator)
- where T : Exception
- {
- T exception = Throws<T>(retry, action, (actual, retryCount) =>
- {
- AssertSameInner(innerException, actual, retryCount);
-
- if (validator != null)
- {
- validator(actual, retryCount);
- }
- });
-
- return exception;
- }
-
- /// <summary>
- /// Verifies that the specified action throws an exception of type <typeparam name="T"/>.
- /// </summary>
- public static T Throws<T>(Action action)
- where T : Exception
- {
- return Throws<T>(RetryMode.Retry, action, (Action<T, int>)null);
- }
-
- /// <summary>
- /// Verifies that the specified action throws an exception of type <typeparam name="T"/>,
- /// indicating whether to retry.
- /// </summary>
- public static T Throws<T>(RetryMode retry, Action action)
- where T : Exception
- {
- return Throws<T>(retry, action, (Action<T, int>)null);
- }
-
- /// <summary>
- /// Verifies that the specified action throws an exception of type <typeparam name="T"/>,
- /// indicating whether to retry and running the specified validator.
- /// </summary>
- public static T Throws<T>(RetryMode retry, Action action, Action<T, int> validator)
- where T : Exception
- {
- var exception = (T)Run(retry, action, (actual, retryCount) =>
- {
- AssertIsExactInstanceOf(typeof(T), actual, retryCount);
-
- if (validator != null)
- {
- validator((T)actual, retryCount);
- }
- });
-
- return exception;
- }
-
- /// <summary>
- /// Verifies that the specified action throws the specified exception.
- /// </summary>
- public static void Throws(Exception expected, Action action)
- {
- Throws(expected, RetryMode.Retry, action);
- }
-
- /// <summary>
- /// Verifies that the specified action throws the specified exception,
- /// indicating whether to retry.
- /// </summary>
- public static void Throws(Exception expected, RetryMode retry, Action action)
- {
- Throws(expected, retry, action, (Action<Exception, int>)null);
- }
-
- /// <summary>
- /// Verifies that the specified action throws the specified exception,
- /// indicating whether to retry and running the specified validator.
- /// </summary>
- public static void Throws(Exception expected, RetryMode retry, Action action, Action<Exception, int> validator)
- {
- Run(retry, action, (actual, retryCount) =>
- {
- AssertSame(expected, actual, retryCount);
-
- if (validator != null)
- {
- validator(actual, retryCount);
- }
- });
- }
-
- private static Exception Run(RetryMode retry, Action action, Action<Exception, int> validator)
- {
- Exception exception = null;
-
- for (int i = -1; i < (int)retry; i++)
- {
- exception = Run(action);
-
- validator(exception, i + 2);
- }
-
- return exception;
- }
-
- private static Exception Run(Action action)
- {
- try
- {
- action();
- return null;
- }
- catch (Exception ex)
- {
- return ex;
- }
- }
-
- private static void AssertSerializationMemberName(string memberName, SerializationException actual, int retryCount)
- {
- // Unfortunately, SerializationException does not provide a way to get our hands on the
- // the actual member that was missing from the SerializationInfo, so we need to grok the
- // message string.
-
- // Member '[memberName]' was not found.
- StringAssert.Contains(actual.Message, "'" + memberName + "'", "Retry Count {0}: Expected SerializationException MemberName to be '{1}'", retryCount, memberName);
- }
-
- private static void AssertObjectDisposed(object instance, ObjectDisposedException actual, int retryCount)
- {
- string objectName = instance.GetType().FullName;
-
- Assert.AreEqual(objectName, actual.ObjectName, "Retry Count {0}: Expected {1}.ObjectName to be '{2}', however, '{3}' is.", retryCount, actual.GetType().Name, objectName, actual.ObjectName);
- }
-
- private static void AssertSameParameterName(string parameterName, ArgumentException actual, int retryCount)
- {
-#if !SILVERLIGHT
- Assert.AreEqual(parameterName, actual.ParamName, "Retry Count {0}: Expected {1}.ParamName to be '{2}', however, '{3}' is.", retryCount, actual.GetType().Name, parameterName, actual.ParamName);
-#else
- // Silverlight doesn't have ArgumentException.ParamName
- StringAssert.Contains(actual.Message, parameterName, "Retry Count {0}: Expected {1}.ParamName to be '{2}'", retryCount, actual.GetType().Name, parameterName);
-#endif
- }
-
- private static void AssertSame(Exception expected, Exception actual, int retryCount)
- {
- Assert.AreSame(expected, actual, "Retry Count {0}: Expected '{1}' to be thrown, however, '{2}' was thrown.", retryCount, expected, actual);
- }
-
- private static void AssertSameInner(Exception innerException, Exception actual, int retryCount)
- {
- Assert.AreSame(innerException, actual.InnerException, "Retry Count {0}: Expected '{1}' to be the inner exception, however, '{2}' is.", retryCount, innerException, actual.InnerException);
- }
-
- private static void AssertIsExactInstanceOf(Type expectedType, Exception actual, int retryCount)
- {
- if (actual == null)
- Assert.Fail("Retry Count {0}: Expected '{1}' to be thrown", retryCount, expectedType);
-
- Type actualType = actual.GetType();
-
- Assert.AreSame(expectedType, actualType, "Retry Count {0}: Expected '{1}' to be thrown, however, '{2}' was thrown.", retryCount, expectedType, actualType);
- }
-
- private static void AssertIsExactInstanceOfInner(Type expectedType, Exception actual, int retryCount)
- {
- if (actual.InnerException == null)
- Assert.Fail("Retry Count {0}: Expected '{1}' be the inner exception, however, it is null.", retryCount, expectedType);
-
- Type actualType = actual.InnerException.GetType();
-
- Assert.AreSame(expectedType, actualType, "Retry Count {0}: Expected '{1}' to be the inner exception, however, '{2}' is.", retryCount, expectedType, actualType);
- }
- }
-}
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/ExpectationCollectionOfI.cs b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/ExpectationCollectionOfI.cs
deleted file mode 100644
index 718c898193d..00000000000
--- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/ExpectationCollectionOfI.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-// -----------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// -----------------------------------------------------------------------
-using System;
-using System.Collections.ObjectModel;
-using System.Collections.Generic;
-
-namespace System.UnitTesting
-{
- public class ExpectationCollection<TInputAndOutput> : Collection<Expectation<TInputAndOutput>>
- {
- public void Add(TInputAndOutput inputAndOutput)
- {
- Add(inputAndOutput, inputAndOutput);
- }
-
- public void AddRange(IEnumerable<TInputAndOutput> inputAndOutputs)
- {
- foreach (TInputAndOutput inputAndOutput in inputAndOutputs)
- {
- Add(inputAndOutput);
- }
- }
-
- public void Add(TInputAndOutput input, TInputAndOutput output)
- {
- Add(new Expectation<TInputAndOutput>(input, output));
- }
- }
-}
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/ExpectationCollectionOfIO.cs b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/ExpectationCollectionOfIO.cs
deleted file mode 100644
index f323eb5242d..00000000000
--- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/ExpectationCollectionOfIO.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-// -----------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// -----------------------------------------------------------------------
-using System;
-using System.Collections.ObjectModel;
-
-namespace System.UnitTesting
-{
- public class ExpectationCollection<TInput, TOutput> : Collection<Expectation<TInput, TOutput>>
- {
- public void Add(TInput input, TOutput output)
- {
- Add(new Expectation<TInput, TOutput>(input, output));
- }
- }
-}
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/ExpectationOfI.cs b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/ExpectationOfI.cs
deleted file mode 100644
index 7670f8cf6f2..00000000000
--- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/ExpectationOfI.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-// -----------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// -----------------------------------------------------------------------
-using System;
-
-namespace System.UnitTesting
-{
- public class Expectation<TInputAndOutput> : Expectation<TInputAndOutput, TInputAndOutput>
- {
- public Expectation(TInputAndOutput input, TInputAndOutput output)
- : base(input, output)
- {
- }
- }
-
-}
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/ExpectationOfIO.cs b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/ExpectationOfIO.cs
deleted file mode 100644
index 00e1b7bc999..00000000000
--- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/ExpectationOfIO.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-// -----------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// -----------------------------------------------------------------------
-using System;
-
-namespace System.UnitTesting
-{
- public class Expectation<TInput, TOutput>
- {
- public Expectation(TInput input, TOutput output)
- {
- Input = input;
- Output = output;
- }
-
- public TInput Input
- {
- get;
- private set;
- }
-
- public TOutput Output
- {
- get;
- private set;
- }
- }
-}
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/ExtendedAssert.cs b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/ExtendedAssert.cs
deleted file mode 100644
index 97b605c88da..00000000000
--- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/ExtendedAssert.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-// -----------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// -----------------------------------------------------------------------
-using System;
-using System.IO;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace System.UnitTesting
-{
- public static class ExtendedAssert
- {
- /// <summary>
- /// Verifies that the two specified objects are an instance of the same type.
- /// </summary>
- public static void IsInstanceOfSameType(object expected, object actual)
- {
- if (expected == null || actual == null)
- {
- Assert.AreSame(expected, actual);
- return;
- }
-
- Assert.AreSame(expected.GetType(), actual.GetType());
- }
-
- public static void ContainsLines(string value, params string[] lines)
- {
- StringReader reader = new StringReader(value);
-
- int count = 0;
- string line;
- while ((line = reader.ReadLine()) != null)
- {
- if (count == lines.Length)
- {
- Assert.Fail();
- }
-
- StringAssert.Contains(line, lines[count]);
-
- count++;
- }
-
- Assert.AreEqual(lines.Length, count, "Expectation: {0}; Result: {1}", String.Join(Environment.NewLine, lines), value);
- }
-
- public static void EnumsContainSameValues<TEnum1, TEnum2>()
- where TEnum1 : struct
- where TEnum2 : struct
- {
- EnumsContainSameValuesCore<TEnum1, TEnum2>();
- EnumsContainSameValuesCore<TEnum2, TEnum1>();
- }
-
- private static void EnumsContainSameValuesCore<TEnum1, TEnum2>()
- where TEnum1 : struct
- where TEnum2 : struct
- {
- var values = TestServices.GetEnumValues<TEnum1>();
-
- foreach (TEnum1 value in values)
- {
- string name1 = Enum.GetName(typeof(TEnum1), value);
- string name2 = Enum.GetName(typeof(TEnum2), value);
-
- Assert.AreEqual(name1, name2, "{0} contains a value that {1} does not have. These enums need to be in sync.", typeof(TEnum1), typeof(TEnum2));
- }
- }
- }
-}
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/ReflectionAssert.cs b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/ReflectionAssert.cs
deleted file mode 100644
index bc0fca3b83e..00000000000
--- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/ReflectionAssert.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-// -----------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// -----------------------------------------------------------------------
-using System;
-using System.ComponentModel.Composition;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System.Reflection;
-
-namespace System.UnitTesting
-{
- // Unfortunately, you can't rely on reference equality for MemberInfo and ParameterInfo
- // objects because, you may get different instances representing the same members depending
- // on the type that the member was retrieived from.
-
- public static class ReflectionAssert
- {
- public static void AreSame(MemberInfo expected, MemberInfo actual)
- {
- if (expected == null && actual == null)
- {
- return;
- }
-
- Assert.AreEqual(expected.MetadataToken, actual.MetadataToken);
- Assert.AreSame(expected.Module, actual.Module);
- Assert.AreEqual(expected.MemberType, actual.MemberType);
- }
-
- public static void AreSame(ParameterInfo expected, ParameterInfo actual)
- {
- if (expected == null && actual == null)
- {
- return;
- }
-
- ReflectionAssert.AreSame(expected.Member, actual.Member);
- Assert.AreEqual(expected.MetadataToken, actual.MetadataToken);
- }
- }
-}
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/RetryMode.cs b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/RetryMode.cs
deleted file mode 100644
index bdda321a7c9..00000000000
--- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/RetryMode.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-// -----------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// -----------------------------------------------------------------------
-using System;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace System.UnitTesting
-{
- public enum RetryMode : int
- {
- DoNotRetry = 0,
- Retry = 1,
- }
-}
diff --git a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/TestServices.cs b/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/TestServices.cs
deleted file mode 100644
index 87032d796ad..00000000000
--- a/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/TestServices.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-// -----------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// -----------------------------------------------------------------------
-using System;
-using System.Reflection;
-using System.Collections.Generic;
-
-namespace System.UnitTesting
-{
- public static class TestServices
- {
- public static string GenerateRandomString()
- {
- return Guid.NewGuid().ToString().Replace('-', '_');
- }
-
- public static IEnumerable<TEnum> GetEnumValues<TEnum>() where TEnum : struct
- { // Silverlight 2.0 does not have Enum.GetValues()
- // so we need to write our own
-
- foreach (FieldInfo field in typeof(TEnum).GetFields())
- {
- if (!field.IsLiteral)
- continue;
-
- yield return (TEnum)field.GetRawConstantValue();
- }
- }
- }
-} \ No newline at end of file