public void GetsNoTypes() { WithMappings.None(typeof(TypeWithoutInterfaces)).AssertHasNoItems(); WithMappings.None(typeof(DisposableType)).AssertHasNoItems(); WithMappings.None(typeof(TestObject)).AssertHasNoItems(); WithMappings.None(typeof(AnotherTestObject)).AssertHasNoItems(); }
public void WhenMappedToTypeHasNoInterfaceAndMappedToNoType() { IUnityContainer container = new UnityContainer(); container.RegisterTypes( AllClasses.FromAssemblies( Assembly.Load(new AssemblyName(RegistrationByConventionAssembly1Name)), Assembly.Load(new AssemblyName(RegistrationByConventionAssembly2Name))), (t) => WithMappings.None(typeof(TypeWithNoInterface)), WithName.TypeName, null); var resolved = container.Resolve <TypeWithNoInterface>("TypeWithNoInterface"); Assert.IsInstanceOfType(resolved, typeof(TypeWithNoInterface)); }
public void WhenFilteringToNoTypes() { IUnityContainer container = new UnityContainer(); container.RegisterTypes( AllClasses.FromAssemblies( Assembly.Load(new AssemblyName(RegistrationByConventionAssembly1Name)), Assembly.Load(new AssemblyName(RegistrationByConventionAssembly2Name))), (t) => { return(WithMappings.None(typeof(TypeImplementingI12))); }, WithName.TypeName, null); foreach (var reg in container.Registrations) { System.Diagnostics.Debug.WriteLine(reg.Name); } var resolved = container.Resolve <TypeImplementingI12>("TypeImplementingI12"); Assert.IsInstanceOfType(resolved, typeof(TypeImplementingI12)); AssertHelper.ThrowsException <ResolutionFailedException>(() => container.Resolve <ITypeImplementingI1>("TypeImplementingI12")); }