예제 #1
0
        public void Entity_Can_Reside_In_Assembly_Separate_From_Mapping()
        {
            CrossAppDomainCaller.RunInOtherAppDomain(delegate
            {
                Type userType = typeof(User);

                Assembly entityAssembly  = userType.Assembly;
                Assembly mappingAssembly = typeof(Person).Assembly;

                Assert.AreNotEqual(entityAssembly, mappingAssembly);

                Assembly proxyAssembly = _generator.Generate(CreateOptions(_outputAssemblyPath, mappingAssembly.Location));

                Assert.IsNotNull(proxyAssembly);

                Type userProxyType = null;
                foreach (Type type in proxyAssembly.GetTypes())
                {
                    if (type.BaseType == userType)
                    {
                        userProxyType = type;
                        break;
                    }
                }

                Assert.IsNotNull(userProxyType);

                Assert.IsTrue(typeof(INHibernateProxy).IsAssignableFrom(userProxyType));
            });
        }
예제 #2
0
        public void Generates_Proxies_From_Multiple_Assemblies()
        {
            CrossAppDomainCaller.RunInOtherAppDomain(delegate
            {
                Type personType        = typeof(Person);
                Type addressType       = typeof(Address);
                Assembly proxyAssembly = _generator.Generate(CreateOptions(_outputAssemblyPath, personType.Assembly.Location, addressType.Assembly.Location));

                Assert.IsNotNull(proxyAssembly);

                Type personProxyType  = null;
                Type addressProxyType = null;
                foreach (Type type in proxyAssembly.GetTypes())
                {
                    if (type.BaseType == personType)
                    {
                        personProxyType = type;
                    }
                    else if (type.BaseType == addressType)
                    {
                        addressProxyType = type;
                    }
                }

                Assert.IsNotNull(personProxyType);
                Assert.IsNotNull(addressProxyType);

                Assert.IsTrue(typeof(INHibernateProxy).IsAssignableFrom(personProxyType));
                Assert.IsTrue(typeof(INHibernateProxy).IsAssignableFrom(addressProxyType));
            });
        }
예제 #3
0
        public Assembly Generate(ProxyGeneratorOptions options)
        {
            ValidateOptions(options);
            try
            {
                CrossAppDomainCaller.RunInOtherAppDomain(Generate, this, options);
            }
            finally
            {
                CleanUpIntermediateFiles(options);
            }

            return(Assembly.LoadFrom(options.OutputAssemblyPath));
        }
        public void Generates_Proxies_From_Single_Assembly()
        {
            CrossAppDomainCaller.RunInOtherAppDomain(delegate
            {
                Type personType        = typeof(Person);
                Assembly proxyAssembly = _generator.Generate(CreateOptions(_outputAssemblyPath, personType.Assembly.Location));

                Assert.IsNotNull(proxyAssembly);

                Type personProxyType = proxyAssembly.GetTypes().FirstOrDefault(type => type.BaseType == personType);

                Assert.IsNotNull(personProxyType);

                Assert.IsTrue(typeof(INHibernateProxy).IsAssignableFrom(personProxyType));
            });
        }
        public void Generates_Proxies_For_ActiveRecords()
        {
            CrossAppDomainCaller.RunInOtherAppDomain(delegate
            {
                Type arUserType        = typeof(ARUser);
                Assembly proxyAssembly = _generator.Generate(CreateOptions(_outputAssemblyPath, arUserType.Assembly.Location));

                Assert.IsNotNull(proxyAssembly);

                Type arUserTypeProxy = null;
                foreach (Type type in proxyAssembly.GetTypes())
                {
                    if (type.BaseType == arUserType)
                    {
                        arUserTypeProxy = type;
                        break;
                    }
                }
                Assert.IsNotNull(arUserTypeProxy);

                Assert.IsTrue(typeof(INHibernateProxy).IsAssignableFrom(arUserTypeProxy));
            });
        }