(split) add xamarin tests project. refactor existing tests to work with nunit lite and reimplement missing assert functionality.
This commit is contained in:
Родитель
76309238b8
Коммит
0488464c2c
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Microsoft.Practices.Unity.TestSupport;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Microsoft.Practices.Unity.InterceptionExtension.Tests
|
||||
|
@ -71,19 +71,19 @@ namespace Microsoft.Practices.Unity.InterceptionExtension.Tests
|
|||
Assert.AreEqual(84, param4);
|
||||
|
||||
Assert.AreEqual(5, argumentsCount);
|
||||
CollectionAssert.AreEqual(new[] { 1, 0, 3, 4, 5 }, argumentsValuesByIndex);
|
||||
CollectionAssert.AreEqual(new[] { "param1", "param2", "param3", "param4", "param5" }, argumentsNames);
|
||||
CollectionAssert.AreEqual(new[] { 1, 0, 3, 4, 5 }, argumentsValuesByName);
|
||||
CollectionAssertExtensions.AreEqual(new[] { 1, 0, 3, 4, 5 }, argumentsValuesByIndex);
|
||||
CollectionAssertExtensions.AreEqual(new[] { "param1", "param2", "param3", "param4", "param5" }, argumentsNames);
|
||||
CollectionAssertExtensions.AreEqual(new[] { 1, 0, 3, 4, 5 }, argumentsValuesByName);
|
||||
|
||||
Assert.AreEqual(4, inputsCount);
|
||||
CollectionAssert.AreEqual(new[] { 1, 3, 4, 5 }, inputsValuesByIndex);
|
||||
CollectionAssert.AreEqual(new[] { "param1", "param3", "param4", "param5" }, inputsNames);
|
||||
CollectionAssert.AreEqual(new[] { 1, 3, 4, 5 }, inputsValuesByName);
|
||||
CollectionAssertExtensions.AreEqual(new[] { 1, 3, 4, 5 }, inputsValuesByIndex);
|
||||
CollectionAssertExtensions.AreEqual(new[] { "param1", "param3", "param4", "param5" }, inputsNames);
|
||||
CollectionAssertExtensions.AreEqual(new[] { 1, 3, 4, 5 }, inputsValuesByName);
|
||||
|
||||
Assert.AreEqual(2, outputsCount);
|
||||
CollectionAssert.AreEqual(new[] { 25, 39 }, outputsValuesByIndex);
|
||||
CollectionAssert.AreEqual(new[] { "param2", "param4" }, outputsNames);
|
||||
CollectionAssert.AreEqual(new[] { 25, 39 }, outputsValuesByName);
|
||||
CollectionAssertExtensions.AreEqual(new[] { 25, 39 }, outputsValuesByIndex);
|
||||
CollectionAssertExtensions.AreEqual(new[] { "param2", "param4" }, outputsNames);
|
||||
CollectionAssertExtensions.AreEqual(new[] { 25, 39 }, outputsValuesByName);
|
||||
|
||||
Assert.AreEqual(11 + 25 + 13 + 39 + 15, originalReturnValue);
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace Microsoft.Practices.Unity.InterceptionExtension.Tests.InterfaceInterce
|
|||
new MethodImplementationInfo(typeof(IInterfaceOne).GetMethod("TargetMethod"),
|
||||
typeof(ImplementationOne).GetMethod("TargetMethod"))).ToList();
|
||||
|
||||
CollectionAssert.AreEquivalent(expected, methods);
|
||||
CollectionAssertExtensions.AreEquivalent(expected, methods);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
@ -58,7 +58,7 @@ namespace Microsoft.Practices.Unity.InterceptionExtension.Tests.InterfaceInterce
|
|||
typeof(InterfaceBase).GetMethod("Method3")))
|
||||
.ToList();
|
||||
|
||||
CollectionAssert.AreEquivalent(expected, methods);
|
||||
CollectionAssertExtensions.AreEquivalent(expected, methods);
|
||||
}
|
||||
|
||||
|
||||
|
@ -76,7 +76,7 @@ namespace Microsoft.Practices.Unity.InterceptionExtension.Tests.InterfaceInterce
|
|||
typeof(WrappableThroughInterface).GetMethod("Method3")))
|
||||
.ToList();
|
||||
|
||||
CollectionAssert.AreEquivalent(expected, methods);
|
||||
CollectionAssertExtensions.AreEquivalent(expected, methods);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
@ -89,7 +89,7 @@ namespace Microsoft.Practices.Unity.InterceptionExtension.Tests.InterfaceInterce
|
|||
GetExpectedMethods<IGenericOne<string>, GenericImplementationOne<string>>("DoSomething")
|
||||
.ToList();
|
||||
|
||||
CollectionAssert.AreEquivalent(expected, methods);
|
||||
CollectionAssertExtensions.AreEquivalent(expected, methods);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System.Linq;
|
||||
using Microsoft.Practices.Unity.TestSupport;
|
||||
using Microsoft.Practices.Unity.Utility;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
|
@ -19,19 +20,19 @@ namespace Microsoft.Practices.Unity.InterceptionExtension.Tests
|
|||
pi => true);
|
||||
|
||||
Assert.AreEqual(5, collection.Count);
|
||||
CollectionAssert.AreEqual(
|
||||
CollectionAssertExtensions.AreEqual(
|
||||
new[] { 10, 20, 30, 40, 50 },
|
||||
collection);
|
||||
CollectionAssert.AreEqual(
|
||||
CollectionAssertExtensions.AreEqual(
|
||||
new[] { 50, 20, 40, 30, 10 },
|
||||
new[] { 4, 1, 3, 2, 0 }.Select(i => collection[i]).ToArray());
|
||||
CollectionAssert.AreEqual(
|
||||
CollectionAssertExtensions.AreEqual(
|
||||
new[] { 50, 20, 40, 30, 10 },
|
||||
new[] { "param5", "param2", "param4", "param3", "param1" }.Select(i => collection[i]).ToArray());
|
||||
CollectionAssert.AreEqual(
|
||||
CollectionAssertExtensions.AreEqual(
|
||||
new[] { "param1", "param2", "param3", "param4", "param5" },
|
||||
Enumerable.Range(0, 5).Select(i => collection.ParameterName(i)).ToArray());
|
||||
CollectionAssert.AreEqual(
|
||||
CollectionAssertExtensions.AreEqual(
|
||||
new[] { "param1", "param2", "param3", "param4", "param5" },
|
||||
Enumerable.Range(0, 5).Select(i => collection.GetParameterInfo(i).Name).ToArray());
|
||||
}
|
||||
|
@ -47,19 +48,19 @@ namespace Microsoft.Practices.Unity.InterceptionExtension.Tests
|
|||
pi => param++ % 2 == 1);
|
||||
|
||||
Assert.AreEqual(3, collection.Count);
|
||||
CollectionAssert.AreEqual(
|
||||
CollectionAssertExtensions.AreEqual(
|
||||
new[] { 10, 30, 50 },
|
||||
collection);
|
||||
CollectionAssert.AreEqual(
|
||||
CollectionAssertExtensions.AreEqual(
|
||||
new[] { 50, 30, 10 },
|
||||
new[] { 2, 1, 0 }.Select(i => collection[i]).ToArray());
|
||||
CollectionAssert.AreEqual(
|
||||
CollectionAssertExtensions.AreEqual(
|
||||
new[] { 50, 30, 10 },
|
||||
new[] { "param5", "param3", "param1" }.Select(i => collection[i]).ToArray());
|
||||
CollectionAssert.AreEqual(
|
||||
CollectionAssertExtensions.AreEqual(
|
||||
new[] { "param1", "param3", "param5" },
|
||||
Enumerable.Range(0, 3).Select(i => collection.ParameterName(i)).ToArray());
|
||||
CollectionAssert.AreEqual(
|
||||
CollectionAssertExtensions.AreEqual(
|
||||
new[] { "param1", "param3", "param5" },
|
||||
Enumerable.Range(0, 3).Select(i => collection.GetParameterInfo(i).Name).ToArray());
|
||||
}
|
||||
|
@ -70,12 +71,12 @@ namespace Microsoft.Practices.Unity.InterceptionExtension.Tests
|
|||
object dummy;
|
||||
object dummy2;
|
||||
var inputsCollection =
|
||||
new ParameterCollection(new object[] {"one", "two", "three", "four"},
|
||||
new ParameterCollection(new object[] { "one", "two", "three", "four" },
|
||||
StaticReflection.GetMethodInfo(() => MethodWithOuts(out dummy, null, out dummy2, null)).GetParameters(),
|
||||
pi => !pi.IsOut);
|
||||
|
||||
Assert.AreEqual(2, inputsCollection.Count);
|
||||
CollectionAssert.AreEqual(new object[] {"two", "four"}, inputsCollection);
|
||||
CollectionAssertExtensions.AreEqual(new object[] { "two", "four" }, inputsCollection);
|
||||
Assert.AreEqual("two", inputsCollection["param2"]);
|
||||
Assert.AreEqual("four", inputsCollection["param4"]);
|
||||
}
|
||||
|
@ -103,8 +104,8 @@ namespace Microsoft.Practices.Unity.InterceptionExtension.Tests
|
|||
StaticReflection.GetMethodInfo(() => TestMethod(null, null, null, null, null)).GetParameters(),
|
||||
p => true);
|
||||
|
||||
Assert.IsTrue(new [] {"param1", "param2", "param3", "param4", "param5"}.All(collection.ContainsParameter));
|
||||
Assert.IsTrue(new[] {"someOtherParam", "notThisOneEither"}.All(p => !collection.ContainsParameter(p)));
|
||||
Assert.IsTrue(new[] { "param1", "param2", "param3", "param4", "param5" }.All(collection.ContainsParameter));
|
||||
Assert.IsTrue(new[] { "someOtherParam", "notThisOneEither" }.All(p => !collection.ContainsParameter(p)));
|
||||
}
|
||||
|
||||
public static void TestMethod(object param1, object param2, object param3, object param4, object param5)
|
||||
|
|
|
@ -5,6 +5,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Microsoft.Practices.Unity.InterceptionExtension.Tests.ObjectsUnderTest;
|
||||
using Microsoft.Practices.Unity.TestSupport;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Microsoft.Practices.Unity.InterceptionExtension.Tests
|
||||
|
@ -70,7 +71,7 @@ namespace Microsoft.Practices.Unity.InterceptionExtension.Tests
|
|||
List<ICallHandler> expectedHandlers = new List<ICallHandler>(container.ResolveAll<ICallHandler>());
|
||||
List<ICallHandler> actualHandlers = new List<ICallHandler>(p.GetHandlersFor(member, container));
|
||||
|
||||
CollectionAssert.AreEqual(
|
||||
CollectionAssertExtensions.AreEqual(
|
||||
expectedHandlers,
|
||||
actualHandlers,
|
||||
new TypeComparer());
|
||||
|
@ -90,7 +91,7 @@ namespace Microsoft.Practices.Unity.InterceptionExtension.Tests
|
|||
List<ICallHandler> expectedHandlers = new List<ICallHandler>(container.ResolveAll<ICallHandler>());
|
||||
List<ICallHandler> actualHandlers = new List<ICallHandler>(p.GetHandlersFor(getMethod, container));
|
||||
|
||||
CollectionAssert.AreEqual(
|
||||
CollectionAssertExtensions.AreEqual(
|
||||
expectedHandlers,
|
||||
actualHandlers,
|
||||
new TypeComparer());
|
||||
|
@ -116,7 +117,7 @@ namespace Microsoft.Practices.Unity.InterceptionExtension.Tests
|
|||
private static MethodImplementationInfo GetMethodImplInfo<T>(string methodName)
|
||||
{
|
||||
return new MethodImplementationInfo(null,
|
||||
typeof (T).GetMethod(methodName));
|
||||
typeof(T).GetMethod(methodName));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Microsoft.Practices.Unity.TestSupport;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Microsoft.Practices.Unity.InterceptionExtension.Tests.TransparentProxyInterception
|
||||
|
@ -16,7 +17,7 @@ namespace Microsoft.Practices.Unity.InterceptionExtension.Tests.TransparentProxy
|
|||
{
|
||||
List<MethodImplementationInfo> methods = GetMethods<SingleInterceptableMethod>();
|
||||
|
||||
CollectionAssert.AreEquivalent(GetOnlyImplementations(typeof(SingleInterceptableMethod), "MyMethod"),
|
||||
CollectionAssertExtensions.AreEquivalent(GetOnlyImplementations(typeof(SingleInterceptableMethod), "MyMethod"),
|
||||
methods);
|
||||
}
|
||||
|
||||
|
@ -25,7 +26,7 @@ namespace Microsoft.Practices.Unity.InterceptionExtension.Tests.TransparentProxy
|
|||
{
|
||||
List<MethodImplementationInfo> methods = GetMethods<InheritsSingleMethodAndAdds>();
|
||||
|
||||
CollectionAssert.AreEquivalent(
|
||||
CollectionAssertExtensions.AreEquivalent(
|
||||
GetOnlyImplementations(typeof(InheritsSingleMethodAndAdds), "MyMethod", "AnotherMethod", "StillMoreMethod"),
|
||||
methods);
|
||||
}
|
||||
|
@ -39,7 +40,7 @@ namespace Microsoft.Practices.Unity.InterceptionExtension.Tests.TransparentProxy
|
|||
|
||||
List<MethodImplementationInfo> expected = GetExpectedMethodImplementations(typeof(IMyOperations), typeof(Operations));
|
||||
|
||||
CollectionAssert.AreEquivalent(expected, methods);
|
||||
CollectionAssertExtensions.AreEquivalent(expected, methods);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
@ -47,7 +48,7 @@ namespace Microsoft.Practices.Unity.InterceptionExtension.Tests.TransparentProxy
|
|||
{
|
||||
List<MethodImplementationInfo> methods = GetMethods<Incoherent>();
|
||||
|
||||
CollectionAssert.AreEquivalent(
|
||||
CollectionAssertExtensions.AreEquivalent(
|
||||
GetExpectedMethodImplementations(typeof(IMyOperations), typeof(Incoherent))
|
||||
.Concat(GetExpectedMethodImplementations(typeof(ImTiredOfInterfaces), typeof(Incoherent))).ToList(),
|
||||
methods);
|
||||
|
@ -58,7 +59,7 @@ namespace Microsoft.Practices.Unity.InterceptionExtension.Tests.TransparentProxy
|
|||
{
|
||||
List<MethodImplementationInfo> methods = GetMethods<Marked>();
|
||||
|
||||
CollectionAssert.AreEquivalent(
|
||||
CollectionAssertExtensions.AreEquivalent(
|
||||
GetExpectedMethodImplementations(typeof(IMyOperations), typeof(Marked)),
|
||||
methods);
|
||||
}
|
||||
|
@ -68,7 +69,7 @@ namespace Microsoft.Practices.Unity.InterceptionExtension.Tests.TransparentProxy
|
|||
{
|
||||
List<MethodImplementationInfo> methods = GetMethods<HasProperties>();
|
||||
|
||||
CollectionAssert.AreEquivalent(
|
||||
CollectionAssertExtensions.AreEquivalent(
|
||||
GetOnlyImplementations(typeof(HasProperties), "get_SettableProp", "set_SettableProp", "get_GetOnly"),
|
||||
methods);
|
||||
}
|
||||
|
@ -78,7 +79,7 @@ namespace Microsoft.Practices.Unity.InterceptionExtension.Tests.TransparentProxy
|
|||
{
|
||||
List<MethodImplementationInfo> methods = GetMethods<PropThroughInterface>();
|
||||
|
||||
CollectionAssert.AreEquivalent(
|
||||
CollectionAssertExtensions.AreEquivalent(
|
||||
GetExpectedMethodImplementations(typeof(IHasProperties), typeof(PropThroughInterface)),
|
||||
methods);
|
||||
}
|
||||
|
@ -91,7 +92,7 @@ namespace Microsoft.Practices.Unity.InterceptionExtension.Tests.TransparentProxy
|
|||
var expected = GetExpectedMethodImplementations(typeof(IHasProperties), typeof(MBROWithPropThroughInterface))
|
||||
.Concat(GetOnlyImplementations(typeof(MBROWithPropThroughInterface), "get_Gettable"));
|
||||
|
||||
CollectionAssert.AreEquivalent(expected.ToList(), methods);
|
||||
CollectionAssertExtensions.AreEquivalent(expected.ToList(), methods);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
@ -101,7 +102,7 @@ namespace Microsoft.Practices.Unity.InterceptionExtension.Tests.TransparentProxy
|
|||
|
||||
var expected = GetExpectedMethodImplementations(typeof(IMyOperations), typeof(ExplicitImplementation))
|
||||
.Concat(GetOnlyImplementations(typeof(ExplicitImplementation), "AClassMethod"));
|
||||
CollectionAssert.AreEquivalent(expected.ToList(), methods);
|
||||
CollectionAssertExtensions.AreEquivalent(expected.ToList(), methods);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
|
Загрузка…
Ссылка в новой задаче