public void Discover_can_resolve_classes_that_do_not_implement_any_interfaces() { using (var container = new UnityContainer()) { var discoverer = new ConventionMappingTypeDiscoverer(); discoverer.Discover(container); var resolved = container.Resolve <ClassThatImplementsNoInterface>(); Assert.That(resolved, Is.Not.Null); Assert.That(resolved, Is.InstanceOf <ClassThatImplementsNoInterface>()); } }
public void Discover_excludes_types_decorated_with_NUnitExcludeFromAutoScanAttribute_from_ioc_container_registration() { using (var container = new UnityContainer()) { var discoverer = new ConventionMappingTypeDiscoverer(); discoverer.Discover(container); Assert.That( container.Registrations.Any(r => r.RegisteredType == typeof(IFoo) && r.MappedToType == typeof(Foo)), Is.False, $"Found a registration which mapped type {typeof(IFoo).FullName} to {typeof(Foo).FullName}"); } }
public void Discover_excludes_interfaces_that_do_not_have_corresponding_concrete_implementations() { using (var container = new UnityContainer()) { var discoverer = new ConventionMappingTypeDiscoverer(); discoverer.Discover(container); Assert.That( container.Registrations.Any(r => r.RegisteredType.IsAbstract && r.MappedToType is null), Is.False, "Found a registration for a type without a concrete implementation"); } }
public void Discover_registers_expected_abstract_type_with_provided_ioc_container() { using (var container = new UnityContainer()) { var discoverer = new ConventionMappingTypeDiscoverer(); discoverer.Discover(container); Assert.That( container.Registrations.Any(r => r.RegisteredType == typeof(ITestSettings) && r.MappedToType == typeof(TestSettings)), Is.True, $"No registration of type {typeof(ITestSettings).FullName} that maps to {typeof(TestSettings).FullName}"); } }