public void DefaultBuildKeyIsAnnotatedMemberType() { DependencyAttribute attribute = new DependencyAttribute(); IParameter result = attribute.CreateParameter(typeof(object)); DependencyParameter parameter = Assert.IsType <DependencyParameter>(result); Assert.Equal <object>(typeof(object), parameter.BuildKey); }
public void DefaultNotPresentBehaviorIsBuild() { DependencyAttribute attribute = new DependencyAttribute("Foo"); IParameter result = attribute.CreateParameter(typeof(object)); DependencyParameter parameter = Assert.IsType <DependencyParameter>(result); Assert.Equal(NotPresentBehavior.Build, parameter.NotPresentBehavior); }
public void ReturnsDependencyParameter() { DependencyAttribute attribute = new DependencyAttribute("Foo"); attribute.NotPresentBehavior = NotPresentBehavior.Throw; IParameter result = attribute.CreateParameter(typeof(object)); DependencyParameter parameter = Assert.IsType <DependencyParameter>(result); Assert.Equal <object>("Foo", parameter.BuildKey); Assert.Equal(NotPresentBehavior.Throw, parameter.NotPresentBehavior); }
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); }