public void CallsGetMembers() { TestableReflectionStrategy strategy = new TestableReflectionStrategy(); MockBuilderContext context = new MockBuilderContext(); object existing = new object(); strategy.BuildUp(context, "foo", existing); Assert.Same(context, strategy.GetMembers_Context); Assert.Same("foo", strategy.GetMembers_BuildKey); Assert.Same(existing, strategy.GetMembers_Existing); }
public void MultipleAttributesNotAllowed() { TestableReflectionStrategy strategy = new TestableReflectionStrategy(); MockBuilderContext context = new MockBuilderContext(); MethodInfo method = typeof(Dummy).GetMethod("Method3"); strategy.GetMembers__Result.Add(new MethodMemberInfo <MethodInfo>(method)); Assert.Throws <InvalidAttributeException>( delegate { strategy.BuildUp(context, "foo", null); }); }
public void CallsAddParametersToPolicy() { TestableReflectionStrategy strategy = new TestableReflectionStrategy(); MockBuilderContext context = new MockBuilderContext(); MethodInfo method = typeof(Dummy).GetMethod("Method1"); strategy.GetMembers__Result.Add(new MethodMemberInfo <MethodInfo>(method)); strategy.BuildUp(context, "foo", null); Assert.Same(context, strategy.AddParametersToPolicy_Context); Assert.Same("foo", strategy.AddParametersToPolicy_BuildKey); Assert.Same(method, strategy.AddParametersToPolicy_Member); }
public void CallsMemberRequiresProcessing() { TestableReflectionStrategy strategy = new TestableReflectionStrategy(); MockBuilderContext context = new MockBuilderContext(); MethodInfo method1 = typeof(Dummy).GetMethod("Method1"); MethodInfo method2 = typeof(Dummy).GetMethod("Method2"); strategy.GetMembers__Result.Add(new MethodMemberInfo <MethodInfo>(method1)); strategy.GetMembers__Result.Add(new MethodMemberInfo <MethodInfo>(method2)); strategy.BuildUp(context, "foo", null); Assert.Contains(method1, strategy.MemberRequiresProcessing_Members); Assert.Contains(method2, strategy.MemberRequiresProcessing_Members); }
public void UsesAttributeInforationWhenPresent() { TestableReflectionStrategy strategy = new TestableReflectionStrategy(); MockBuilderContext context = new MockBuilderContext(); MethodInfo method = typeof(Dummy).GetMethod("Method2"); strategy.GetMembers__Result.Add(new MethodMemberInfo <MethodInfo>(method)); strategy.BuildUp(context, "foo", null); IParameter parameter = strategy.AddParametersToPolicy_Parameters[0]; DependencyParameter dependency = Assert.IsType <DependencyParameter>(parameter); Assert.Equal <object>("bar", dependency.BuildKey); Assert.Equal(NotPresentBehavior.Throw, dependency.NotPresentBehavior); }
public void DefaultParameterBehaviorIsBuildDependencyByType() { TestableReflectionStrategy strategy = new TestableReflectionStrategy(); MockBuilderContext context = new MockBuilderContext(); MethodInfo method = typeof(Dummy).GetMethod("Method1"); strategy.GetMembers__Result.Add(new MethodMemberInfo <MethodInfo>(method)); strategy.BuildUp(context, "foo", null); IParameter parameter = strategy.AddParametersToPolicy_Parameters[0]; DependencyParameter dependency = Assert.IsType <DependencyParameter>(parameter); Assert.Equal <object>(typeof(int), dependency.BuildKey); Assert.Equal(NotPresentBehavior.Build, dependency.NotPresentBehavior); }