public void each_service_interface_can_be_resolved_from_container()
        {
            var assemblies = ConventionsHelper.assemblies()
                             .ToArray();

            var builder = new ContainerBuilder();

            builder.RegisterAssemblyModules(assemblies);

            var container = builder.Build();

            var service_interfaces = ConventionsHelper.interfaces()
                                     .Where(x => x != typeof(IEntity))
                                     .Where(x => x.Namespace.Contains("._Infrastructure") == false)
                                     .ToList();

            Assert.NotEmpty(service_interfaces);

            foreach (var serviceInterface in service_interfaces)
            {
                var error = Record.Exception(
                    () => container.Resolve(serviceInterface)
                    );

                Assert.Null(error);
            }
        }
        public void each_interface_name_starts_with_capital_I()
        {
            var interfaces = ConventionsHelper.interfaces();

            Assert.NotEmpty(interfaces);

            var interfaces_not_starting_with_I = interfaces
                                                 .Where(x => x.Name.StartsWith("I") == false);

            Assert.Empty(interfaces_not_starting_with_I);
        }
Ejemplo n.º 3
0
        public void each_interface_has_at_least_one_implementation()
        {
            var interfaces = ConventionsHelper.interfaces()
                             .Where(x => x.Namespace.Contains("._Infrastructure") == false)
                             .ToList();

            var concrete_types = ConventionsHelper.classes()
                                 .Where(x => x.IsConcrete())
                                 .ToList();

            foreach (var @interface in interfaces)
            {
                var types_assignable_to_interface = concrete_types
                                                    .Where(x => @interface.IsAssignableFrom(x));

                Assert.NotEmpty(types_assignable_to_interface);
            }
        }