Fixing injection tests
This commit is contained in:
Родитель
529dc79ae1
Коммит
f503f9fa41
|
@ -37,7 +37,7 @@ namespace Injection
|
||||||
=> Assert_Injection(
|
=> Assert_Injection(
|
||||||
BaselineTestNamed.MakeGenericType(type),
|
BaselineTestNamed.MakeGenericType(type),
|
||||||
InjectionMember_Default(),
|
InjectionMember_Default(),
|
||||||
@default, named);
|
@default, registered);
|
||||||
|
|
||||||
[DynamicData(nameof(Test_Type_Data), typeof(PatternBase))]
|
[DynamicData(nameof(Test_Type_Data), typeof(PatternBase))]
|
||||||
[PatternTestMethod("Inject {1} dependency by {2} and {3}"), TestCategory(CATEGORY_INJECT)]
|
[PatternTestMethod("Inject {1} dependency by {2} and {3}"), TestCategory(CATEGORY_INJECT)]
|
||||||
|
|
|
@ -28,13 +28,9 @@ namespace Parameters
|
||||||
public void GenericParameter(Type type, Type definition, string member, string import,
|
public void GenericParameter(Type type, Type definition, string member, string import,
|
||||||
Func<object, InjectionMember> func, object registered, object named,
|
Func<object, InjectionMember> func, object registered, object named,
|
||||||
object injected, object @default, bool isNamed)
|
object injected, object @default, bool isNamed)
|
||||||
#if BEHAVIOR_V4 || BEHAVIOR_V5
|
|
||||||
=> Assert_Generic_Injected(definition, type,
|
=> Assert_Generic_Injected(definition, type,
|
||||||
func(new GenericParameter(TDependency)), import, isNamed, registered, registered);
|
func(new GenericParameter(TDependency)), import, isNamed, registered, registered);
|
||||||
#else
|
|
||||||
=> Assert_Generic_Injected(definition, type,
|
|
||||||
func(new GenericParameter(TDependency)), import, isNamed, registered, named);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
[PatternTestMethod("GenericParameter(T, null) forces contract: T, null")]
|
[PatternTestMethod("GenericParameter(T, null) forces contract: T, null")]
|
||||||
[DynamicData(nameof(Parameters_Test_Data)), TestProperty(PARAMETER, nameof(GenericParameter))]
|
[DynamicData(nameof(Parameters_Test_Data)), TestProperty(PARAMETER, nameof(GenericParameter))]
|
||||||
|
@ -182,7 +178,7 @@ namespace Parameters
|
||||||
|
|
||||||
// Validate
|
// Validate
|
||||||
Assert.IsNotNull(instance);
|
Assert.IsNotNull(instance);
|
||||||
Assert.AreEqual(expected, instance.Value);
|
Assert.AreEqual(registered, instance.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -21,13 +21,8 @@ namespace Parameters
|
||||||
public void OptionalGenericParameter(Type type, Type definition, string member, string import,
|
public void OptionalGenericParameter(Type type, Type definition, string member, string import,
|
||||||
Func<object, InjectionMember> func, object registered, object named,
|
Func<object, InjectionMember> func, object registered, object named,
|
||||||
object injected, object @default, bool isNamed)
|
object injected, object @default, bool isNamed)
|
||||||
#if BEHAVIOR_V4 || BEHAVIOR_V5
|
|
||||||
=> Assert_Optional_Injected(definition, type,
|
=> Assert_Optional_Injected(definition, type,
|
||||||
func(new OptionalGenericParameter(TDependency)), @default, import, isNamed, registered, registered);
|
func(new OptionalGenericParameter(TDependency)), @default, import, isNamed, registered, registered);
|
||||||
#else
|
|
||||||
=> Assert_Optional_Injected(definition, type,
|
|
||||||
func(new OptionalGenericParameter(TDependency)), @default, import, isNamed, registered, named);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
[PatternTestMethod("OptionalGenericParameter(T, null) forces contract: T, null")]
|
[PatternTestMethod("OptionalGenericParameter(T, null) forces contract: T, null")]
|
||||||
|
|
|
@ -16,16 +16,13 @@ namespace Parameters
|
||||||
#region Success
|
#region Success
|
||||||
|
|
||||||
#if !UNITY_V4
|
#if !UNITY_V4
|
||||||
#if BEHAVIOR_V5
|
|
||||||
[Ignore("Contract is ignored")]
|
|
||||||
#endif
|
|
||||||
[PatternTestMethod("OptionalParameter() preserves annotated contract")]
|
[PatternTestMethod("OptionalParameter() preserves annotated contract")]
|
||||||
[DynamicData(nameof(Parameters_Test_Data)), TestProperty(PARAMETER, nameof(OptionalParameter))]
|
[DynamicData(nameof(Parameters_Test_Data)), TestProperty(PARAMETER, nameof(OptionalParameter))]
|
||||||
public void OptionalParameter(Type type, Type definition, string member, string import,
|
public void OptionalParameter(Type type, Type definition, string member, string import,
|
||||||
Func<object, InjectionMember> func, object registered, object named,
|
Func<object, InjectionMember> func, object registered, object named,
|
||||||
object injected, object @default, bool isNamed)
|
object injected, object @default, bool isNamed)
|
||||||
=> Assert_Optionally_Injected(definition.MakeGenericType(type),
|
=> Assert_Optionally_Injected(definition.MakeGenericType(type),
|
||||||
func(new OptionalParameter()), @default, import, isNamed, registered, named);
|
func(new OptionalParameter()), @default, import, isNamed, registered, registered);
|
||||||
|
|
||||||
[PatternTestMethod("OptionalParameter(null) forces contract: AnnotatedType, null")]
|
[PatternTestMethod("OptionalParameter(null) forces contract: AnnotatedType, null")]
|
||||||
[DynamicData(nameof(Parameters_Test_Data)), TestProperty(PARAMETER, nameof(OptionalParameter))]
|
[DynamicData(nameof(Parameters_Test_Data)), TestProperty(PARAMETER, nameof(OptionalParameter))]
|
||||||
|
|
|
@ -16,16 +16,13 @@ namespace Parameters
|
||||||
#region Success
|
#region Success
|
||||||
|
|
||||||
#if !UNITY_V4
|
#if !UNITY_V4
|
||||||
#if BEHAVIOR_V5
|
|
||||||
[Ignore("Name is ignored")]
|
|
||||||
#endif
|
|
||||||
[PatternTestMethod("ResolvedParameter() preserves annotated contract"), TestProperty(PARAMETER, nameof(ResolvedParameter))]
|
[PatternTestMethod("ResolvedParameter() preserves annotated contract"), TestProperty(PARAMETER, nameof(ResolvedParameter))]
|
||||||
[DynamicData(nameof(Parameters_Test_Data))]
|
[DynamicData(nameof(Parameters_Test_Data))]
|
||||||
public void ResolvedParameter(Type type, Type definition, string member, string import,
|
public void ResolvedParameter(Type type, Type definition, string member, string import,
|
||||||
Func<object, InjectionMember> func, object registered, object named,
|
Func<object, InjectionMember> func, object registered, object named,
|
||||||
object injected, object @default, bool isNamed)
|
object injected, object @default, bool isNamed)
|
||||||
=> Assert_Parameter_Injected(definition.MakeGenericType(type),
|
=> Assert_Parameter_Injected(definition.MakeGenericType(type),
|
||||||
func(new ResolvedParameter()), import, isNamed, registered, named);
|
func(new ResolvedParameter()), import, isNamed, registered, registered);
|
||||||
|
|
||||||
|
|
||||||
[PatternTestMethod("ResolvedParameter(null) forces contract: AnnotatedType, null")]
|
[PatternTestMethod("ResolvedParameter(null) forces contract: AnnotatedType, null")]
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
using Regression;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Methods
|
namespace Methods
|
||||||
|
@ -32,6 +33,12 @@ namespace Methods
|
||||||
public override void Member_Injected_ByValue(string test, Type type, object defaultValue, object defaultAttr, object registered, object named, object injected, object overridden, object @default) { }
|
public override void Member_Injected_ByValue(string test, Type type, object defaultValue, object defaultAttr, object registered, object named, object injected, object overridden, object @default) { }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
[DynamicData(nameof(Test_Type_Data), typeof(PatternBase))]
|
||||||
|
[PatternTestMethod("Inject Named dependency by XxxMember()"), TestCategory(CATEGORY_INJECT)]
|
||||||
|
public override void Inject_Named_Default(string test, Type type, object defaultValue, object defaultAttr, object registered, object named, object injected, object overridden, object @default)
|
||||||
|
=> Assert_Injection(BaselineTestNamed.MakeGenericType(type),
|
||||||
|
InjectionMember_Default(), @default, named);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче