Exemplo n.º 1
0
        public void GetServicesFrom_NotDecoratedWithServiceAttribute_NoServicesReturned()
        {
            ServiceRegistrationBehavior behavior = new ServiceRegistrationBehavior();

            IEnumerable <ServiceInfo> services = behavior.GetServicesFrom(typeof(MyNonService));

            Assert.Empty(services);
        }
Exemplo n.º 2
0
        public void GetServicesFrom_DecoratedWithAttribute_ServiceInfoWithAttributeParameters()
        {
            ServiceRegistrationBehavior behavior = new ServiceRegistrationBehavior();

            IEnumerable <ServiceInfo> services = behavior.GetServicesFrom(typeof(MyService));

            ServiceInfo expected = new ServiceInfo(typeof(IMyService), typeof(MyService),
                                                   "SomeContractName", Lifetime.Application);

            AssertEx.AreEquivalent(services, ServiceInfoEquals, expected);
        }
Exemplo n.º 3
0
        public void GetServicesFrom_ServiceAttributeDoesNotHaveExportType_DecoratedTypeUsedAsFromType()
        {
            ServiceAttribute service  = new ServiceAttribute();
            Type             fakeType = GetFakeType(service);

            ServiceRegistrationBehavior behavior = GetTarget();

            IEnumerable <ServiceInfo> services = behavior.GetServicesFrom(fakeType);

            ServiceInfo[] expected = { new ServiceInfo(fakeType, fakeType, Lifetime.Instance) };
            AssertEx.AreEquivalent(services, ServiceInfoEquals, expected);
        }
Exemplo n.º 4
0
        public void GetServicesFrom_DecoratedWithTwoAttributes_TwoServiceInfoReturned()
        {
            ServiceInfo expected1 = new ServiceInfo(typeof(IMyService), typeof(MyDoubleService), "SomeContractName",
                                                    Lifetime.Application);
            ServiceInfo expected2 = new ServiceInfo(typeof(IMyService), typeof(MyDoubleService),
                                                    "SomeOtherContractName", Lifetime.Instance);

            ServiceRegistrationBehavior behavior = new ServiceRegistrationBehavior();

            IEnumerable <ServiceInfo> services = behavior.GetServicesFrom(typeof(MyDoubleService));

            AssertEx.AreEquivalent(services, ServiceInfoEquals, expected1, expected2);
        }