/// <summary> /// supports testing by creating remote assembly /// </summary> /// <param name="resourceName">e.g. PureDITest.SomeTestDataFolder.Target.cs /// This is a combination of the assembly name and the path of the resource /// IOCCTest.Utils.TestResourcePrefix constant can usefully be employed by clients /// building the name</param> /// <returns></returns> public static Assembly CreateAssembly(string resourceName) { #if !USE_THIS_ASSEMBLY string codeText = GetResource( resourceName); Assembly assembly = new AssemblyMaker().MakeAssembly(codeText); #else Assembly assembly = typeof(Utils).Assembly; #endif return(assembly); }
public void ShouldHandleDuplicateAssemblies() { Assert.ThrowsException <DIException>(() => { string codeText = GetResource( "PureDITest.NamespaceData.DuplicateAssemblies.cs"); //string codeText = "public class abc {}"; Assembly assembly = new AssemblyMaker().MakeAssembly( codeText, "RemoteAssembly", new[] { this.GetType().Assembly }); DependencyInjector pdi = new DependencyInjector(); object obj = pdi.CreateAndInjectDependencies <global::IOCCTest.DuplicateAssemblies .DuplicateAssemblies>( assemblies: new Assembly[] { assembly, this.GetType().Assembly }).rootBean; Assert.IsNotNull(obj); } ); }