Exemple #1
0
        public void ForTypesDerivedFrom_ConfigurationUnrelatedTypes_MatchIsFalse()
        {
            ConventionRegistrationBehavior behavior = GetTarget();

            ServiceBuilder serviceBuilder = behavior.ForTypesDerivedFrom <MyService>();

            Assert.False(serviceBuilder.IsMatch(typeof(MyOtherService)));
        }
Exemple #2
0
        public void ForTypesMatching_ConfigurationWithNoServiceSuffix_MatchIsFalse()
        {
            ConventionRegistrationBehavior behavior = GetTarget();

            ServiceBuilder serviceBuilder = behavior.ForTypesMatching(t => t.Name.EndsWith("Service"));

            Assert.False(serviceBuilder.IsMatch(typeof(Repository)));
        }
Exemple #3
0
        public void ForTypesDerivedFrom_ConfigurationWithBaseAndInheritedTypes_MatchIsTrue()
        {
            ConventionRegistrationBehavior behavior = GetTarget();

            ServiceBuilder serviceBuilder = behavior.ForTypesDerivedFrom <MyBaseService>();

            Assert.True(serviceBuilder.IsMatch(typeof(MyService)));
        }
Exemple #4
0
        public void ForType_ConfigurationForNonMatchingType_MatchIsFalse()
        {
            ConventionRegistrationBehavior behavior = GetTarget();

            ServiceBuilder serviceBuilder = behavior.ForType <MyService>();

            Assert.False(serviceBuilder.IsMatch(typeof(MyOtherService)));
        }
Exemple #5
0
        public void ForType_ConfigurationForMatchingType_OneMatches()
        {
            ConventionRegistrationBehavior behavior = GetTarget();

            ServiceBuilder serviceBuilder = behavior.ForType <MyService>();

            Assert.True(serviceBuilder.IsMatch(typeof(MyService)));
        }
        private static ConventionRegistrationBehavior GetDefaultConventions()
        {
            var conventions = new ConventionRegistrationBehavior();

            conventions.ForType <Repository>().Export(b => b.AsContractType <IRepository>());
            conventions.ForType <InterceptorsResolver>().Export(b => b.AsContractType <IInterceptorsResolver>().WithLifetime(Lifetime.Application));

            return(conventions);
        }
Exemple #7
0
        public void GetServicesFrom_NoConventions_NothingExported()
        {
            ConventionRegistrationBehavior conventions = GetTarget();

            conventions.GetServicesFrom(typeof(MyService));

            ServiceInfo[] services = conventions.GetServicesFrom(typeof(MyService)).ToArray();
            Assert.Equal(0, services.Length);
        }
Exemple #8
0
        public void GetServicesFrom_TwoConventionsForType_BothExported()
        {
            ConventionRegistrationBehavior conventions = GetTarget();

            conventions.ForType <MyService>().Export(b => b.AsContractName("Configuration 1"));
            conventions.ForType <MyService>().Export(b => b.AsContractName("Configuration 2"));

            conventions.GetServicesFrom(typeof(MyService));

            var services = conventions.GetServicesFrom(typeof(MyService));

            ServiceInfo[] expected =
            {
                new ServiceInfo(typeof(MyService), typeof(MyService), "Configuration 1", Lifetime.Instance),
                new ServiceInfo(typeof(MyService), typeof(MyService), "Configuration 2", Lifetime.Instance)
            };
            AssertEx.AreEquivalent(services, this.comparer.Equals, expected);
        }