public void BuildWithCollection() { this.Initialize(); var generator1 = new AssemblyGenerator("BuildWithList1", new Dictionary<string, ReadOnlyCollection<MethodGenerator>>() { { "Type1", new List<MethodGenerator>() { new MethodGenerator("Method1", true), new MethodGenerator("Method2", false) }.AsReadOnly() }, { "Type2", new List<MethodGenerator>() { new MethodGenerator("Method1", true), new MethodGenerator("Method2", false) }.AsReadOnly() } }); var generator2 = new AssemblyGenerator("BuildWithList2", new Dictionary<string, ReadOnlyCollection<MethodGenerator>>() { { "Type1", new List<MethodGenerator>() { new MethodGenerator("Method1", true), new MethodGenerator("Method2", false) }.AsReadOnly() }, }); var assembly1 = generator1.Generate(); var assembly2 = generator2.Generate(); var types = new List<Type>(); types.AddRange(assembly1.GetTypes()); types.AddRange(assembly2.GetTypes()); ProxyBuilder.Build(types.AsReadOnly()); var proxyAssemblies = new HashSet<Assembly>(); foreach (var type1 in assembly1.GetTypes()) { proxyAssemblies.Add(Activator.CreateInstance(type1).CreateProxy(this).GetType().Assembly); } Assert.Equal(1, proxyAssemblies.Count); }
public void BuildWithType() { this.Initialize(); var generator = new AssemblyGenerator("BuildWithType", new Dictionary<string, ReadOnlyCollection<MethodGenerator>>() { { "Type1", new List<MethodGenerator>() { new MethodGenerator("Method1", true), new MethodGenerator("Method2", false) }.AsReadOnly() } }); var assembly = generator.Generate(); ProxyBuilder.Build(assembly.GetTypes()[0]); var proxyAssemblies = new HashSet<Assembly>(); foreach (var type in assembly.GetTypes()) { proxyAssemblies.Add(Activator.CreateInstance(type).CreateProxy(this).GetType().Assembly); } Assert.Equal(1, proxyAssemblies.Count); }