예제 #1
0
        public void ShouldHaveNoHandlersWhenPolicyDoesntMatch()
        {
            IMatchingRule[] rules     = { };
            IUnityContainer container = CreateConfiguredContainer();

            InjectionPolicy p = CreatePolicy(container, rules);

            MethodImplementationInfo thisMember = GetMethodImplInfo <PolicyFixture>("ShouldHaveNoHandlersWhenPolicyDoesntMatch");
            List <ICallHandler>      memberHandlers
                = new List <ICallHandler>(p.GetHandlersFor(thisMember, container));

            Assert.AreEqual(0, memberHandlers.Count);
        }
예제 #2
0
        public void ShouldGetHandlersInOrderWithGetHandlersFor()
        {
            IMatchingRule[] rules     = { new MemberNameMatchingRule("ShouldGetHandlersInOrderWithGetHandlersFor") };
            IUnityContainer container = CreateConfiguredContainer();

            InjectionPolicy p = CreatePolicy(container, rules);

            MethodImplementationInfo member = GetMethodImplInfo <PolicyFixture>("ShouldGetHandlersInOrderWithGetHandlersFor");

            List <ICallHandler> expectedHandlers = new List <ICallHandler>(container.ResolveAll <ICallHandler>());
            List <ICallHandler> actualHandlers   = new List <ICallHandler>(p.GetHandlersFor(member, container));

            CollectionAssertExtensions.AreEqual(
                expectedHandlers,
                actualHandlers,
                new TypeComparer());
        }
예제 #3
0
        public void ShouldBeAbleToMatchPropertyGet()
        {
            IMatchingRule[] rules     = { new MemberNameMatchingRule("get_Balance") };
            IUnityContainer container = CreateConfiguredContainer();

            InjectionPolicy p = CreatePolicy(container, rules);

            PropertyInfo             balanceProperty = typeof(MockDal).GetProperty("Balance");
            MethodImplementationInfo getMethod       = new MethodImplementationInfo(null, balanceProperty.GetGetMethod());

            List <ICallHandler> expectedHandlers = new List <ICallHandler>(container.ResolveAll <ICallHandler>());
            List <ICallHandler> actualHandlers   = new List <ICallHandler>(p.GetHandlersFor(getMethod, container));

            CollectionAssertExtensions.AreEqual(
                expectedHandlers,
                actualHandlers,
                new TypeComparer());
        }