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