public void ClassesWithOwnInterfacesAreRegisteredOnlyInterfaceTypes() { var logerFactory = new LoggerFactory(); var services = new ServiceCollection(); var registrationConvention = new DefaultRegistrationConvention(logerFactory); var types = new HashSet<Type> { typeof(TransientInterfacedClass), typeof(ScopedInterfacedClass), typeof(SingletoneInterfacedClass), }; registrationConvention.RegisterServices(types, services); Assert.Equal(3, services.Count); Assert.Equal(ServiceLifetime.Transient, services[0].Lifetime); Assert.Equal(typeof(ITransientInterface), services[0].ServiceType); Assert.Equal(ServiceLifetime.Scoped, services[1].Lifetime); Assert.Equal(typeof(IScopedInterface), services[1].ServiceType); Assert.Equal(ServiceLifetime.Singleton, services[2].Lifetime); Assert.Equal(typeof(ISingletoneInterface), services[2].ServiceType); }
public void ClassesWithSomeInterfacesAreNotRegistered() { var logerFactory = new LoggerFactory(); var services = new ServiceCollection(); var registrationConvention = new DefaultRegistrationConvention(logerFactory); var types = new HashSet<Type> { typeof(ClassWithSomeInterface) }; registrationConvention.RegisterServices(types, services); Assert.Equal(0, services.Count); }