Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Windows Phone 8.1/ Windows 8.1 Issues #73

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/TinyIoC.Tests/TinyIoCTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1473,26 +1473,38 @@ public void AutoRegister_TinyIoCAssembly_CannotResolveInternalTinyIoCClass()
}

[TestMethod]
[ExpectedException(typeof(TinyIoCAutoRegistrationException))]
//[ExpectedException(typeof(TinyIoCAutoRegistrationException))]
public void AutoRegister_ThisAssemblySpecifiedDuplicateActionFail_ThrowsException()
{
var container = UtilityMethods.GetContainer();
container.AutoRegister(new[] { this.GetType().Assembly }, DuplicateImplementationActions.Fail);
#if NETFX_CORE
AssertHelper.ThrowsException<TinyIoCAutoRegistrationException>(() => container.AutoRegister(new[] { this.GetType().GetTypeInfo().Assembly }, DuplicateImplementationActions.Fail));
#else
AssertHelper.ThrowsException<TinyIoCAutoRegistrationException>(() => container.AutoRegister(new[] { this.GetType().Assembly }, DuplicateImplementationActions.Fail));
#endif
//Assert.IsTrue(false);
}

[TestMethod]
public void AutoRegister_TinyIoCAssemblySpecifiedDuplicateActionFail_NoErrors()
{
var container = UtilityMethods.GetContainer();
#if NETFX_CORE
container.AutoRegister(new[] { typeof(TinyIoCContainer).GetTypeInfo().Assembly }, DuplicateImplementationActions.Fail);
#else
container.AutoRegister(new[] { typeof(TinyIoCContainer).Assembly }, DuplicateImplementationActions.Fail);
#endif
}

[TestMethod]
public void AutoRegister_SpecifiedDuplicateActionRegisterMultiple_RegistersMultipleImplementations()
{
var container = UtilityMethods.GetContainer();
#if NETFX_CORE
container.AutoRegister(new[] { typeof(TestClassDefaultCtor).GetTypeInfo().Assembly }, DuplicateImplementationActions.RegisterMultiple);
#else
container.AutoRegister(new[] { typeof(TestClassDefaultCtor).Assembly }, DuplicateImplementationActions.RegisterMultiple);
#endif

var results = container.ResolveAll<ITestInterface>();

Expand Down
59 changes: 55 additions & 4 deletions src/TinyIoC.Tests/TypeExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class ClassImplementingITestInterface : ITestInterface

public class AnotherClassImplementingITestInterface : ITestInterface
{

}

public class ClassNotImplementingITestInterface
Expand All @@ -37,12 +37,20 @@ public void GetGenericMethod_RegisterOneGenericParameterNoParameters_ReturnsCorr
{
var firstGenericParameter = typeof(ClassNotImplementingITestInterface);

#if NETFX_CORE
var method = typeof(TinyIoCContainer).GetGenericMethod(
"Register",
new Type[] { firstGenericParameter },
new Type[] { }
);
#else
var method = typeof(TinyIoCContainer).GetGenericMethod(
BindingFlags.Public | BindingFlags.Instance,
"Register",
new Type[] {firstGenericParameter},
BindingFlags.Public | BindingFlags.Instance,
"Register",
new Type[] { firstGenericParameter },
new Type[] { }
);
#endif

Assert.IsInstanceOfType(method, typeof(MethodInfo));
Assert.IsTrue(method.IsGenericMethod);
Expand All @@ -57,12 +65,20 @@ public void GetGenericMethod_RegisterTwoAcceptableGenericParameterNoParameters_R
var firstGenericParameter = typeof(ITestInterface);
var secondGenericParameter = typeof(ClassImplementingITestInterface);

#if NETFX_CORE
var method = typeof(TinyIoCContainer).GetGenericMethod(
"Register",
new Type[] { firstGenericParameter, secondGenericParameter },
new Type[] { }
);
#else
var method = typeof(TinyIoCContainer).GetGenericMethod(
BindingFlags.Public | BindingFlags.Instance,
"Register",
new Type[] { firstGenericParameter, secondGenericParameter },
new Type[] { }
);
#endif

Assert.IsInstanceOfType(method, typeof(MethodInfo));
Assert.IsTrue(method.IsGenericMethod);
Expand All @@ -80,6 +96,16 @@ public void GetGenericMethod_TwiceWithDifferentGenericParamters_ReturnsCorrectMe
var methodTwoFirstGenericParameter = typeof(ITestInterface);
var methodTwoSecondGenericParameter = typeof(AnotherClassImplementingITestInterface);

#if NETFX_CORE
var methodOne = typeof(TinyIoCContainer).GetGenericMethod(
"Register",
new Type[] { methodOneFirstGenericParameter, methodOneSecondGenericParameter },
new Type[] { });
var methodTwo = typeof(TinyIoCContainer).GetGenericMethod(
"Register",
new Type[] { methodTwoFirstGenericParameter, methodTwoSecondGenericParameter },
new Type[] { });
#else
var methodOne = typeof(TinyIoCContainer).GetGenericMethod(
BindingFlags.Public | BindingFlags.Instance,
"Register",
Expand All @@ -90,6 +116,7 @@ public void GetGenericMethod_TwiceWithDifferentGenericParamters_ReturnsCorrectMe
"Register",
new Type[] { methodTwoFirstGenericParameter, methodTwoSecondGenericParameter },
new Type[] { });
#endif

Assert.IsInstanceOfType(methodOne, typeof(MethodInfo));
Assert.IsTrue(methodOne.IsGenericMethod);
Expand All @@ -110,12 +137,20 @@ public void GetGenericMethod_RegisterTwoUnacceptableGenericParameterNoParameters
{
try
{
#if NETFX_CORE
var method = typeof(TinyIoCContainer).GetGenericMethod(
"Register",
new Type[] { typeof(ITestInterface), typeof(ClassNotImplementingITestInterface) },
new Type[] { }
);
#else
var method = typeof(TinyIoCContainer).GetGenericMethod(
BindingFlags.Public | BindingFlags.Instance,
"Register",
new Type[] { typeof(ITestInterface), typeof(ClassNotImplementingITestInterface) },
new Type[] { }
);
#endif

Assert.Fail();
}
Expand All @@ -131,12 +166,20 @@ public void GetGenericMethod_RegisterTwoAcceptableGenericParameterMethodParamete
var secondGenericParameter = typeof(ClassImplementingITestInterface);
var firstParameter = typeof(string);

#if NETFX_CORE
var method = typeof(TinyIoCContainer).GetGenericMethod(
"Register",
new Type[] { firstGenericParameter, secondGenericParameter },
new Type[] { firstParameter }
);
#else
var method = typeof(TinyIoCContainer).GetGenericMethod(
BindingFlags.Public | BindingFlags.Instance,
"Register",
new Type[] { firstGenericParameter, secondGenericParameter },
new Type[] { firstParameter }
);
#endif

Assert.IsInstanceOfType(method, typeof(MethodInfo));
Assert.IsTrue(method.IsGenericMethod);
Expand All @@ -154,12 +197,20 @@ public void GetGenericMethod_RegisterWithGenericTypeAsAMethodParameter_ReturnsCo
var secondGenericParameter = typeof(ClassImplementingITestInterface);
var firstParameter = typeof(ClassImplementingITestInterface);

#if NETFX_CORE
var method = typeof(TinyIoCContainer).GetGenericMethod(
"Register",
new Type[] { firstGenericParameter, secondGenericParameter },
new Type[] { firstParameter }
);
#else
var method = typeof(TinyIoCContainer).GetGenericMethod(
BindingFlags.Public | BindingFlags.Instance,
"Register",
new Type[] { firstGenericParameter, secondGenericParameter },
new Type[] { firstParameter }
);
#endif

Assert.IsInstanceOfType(method, typeof(MethodInfo));
Assert.IsTrue(method.IsGenericMethod);
Expand Down
Loading