Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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);
        }