From: <cha...@us...> - 2008-08-12 18:47:27
|
Revision: 3699 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3699&view=rev Author: chadly69 Date: 2008-08-12 18:47:36 +0000 (Tue, 12 Aug 2008) Log Message: ----------- Adding NHibernate.Linq test model (Animal hierarchy) and basic test setup classes. Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Linq/ExpressionVisitor.cs trunk/nhibernate/src/NHibernate.Linq.Test/NHibernate.Linq.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Linq.Test/App.config trunk/nhibernate/src/NHibernate.Linq.Test/BaseTest.cs trunk/nhibernate/src/NHibernate.Linq.Test/GlobalSetup.cs trunk/nhibernate/src/NHibernate.Linq.Test/Model/ trunk/nhibernate/src/NHibernate.Linq.Test/Model/Animal.cs trunk/nhibernate/src/NHibernate.Linq.Test/Model/Animal.hbm.xml Property Changed: ---------------- trunk/nhibernate/src/NHibernate.Linq.Test/ Modified: trunk/nhibernate/src/NHibernate.Linq/ExpressionVisitor.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Linq/ExpressionVisitor.cs 2008-08-12 15:40:30 UTC (rev 3698) +++ trunk/nhibernate/src/NHibernate.Linq/ExpressionVisitor.cs 2008-08-12 18:47:36 UTC (rev 3699) @@ -5,7 +5,7 @@ using System.Linq.Expressions; using System.Reflection; -namespace NHibernate.Linq.Visitors +namespace NHibernate.Linq { /// <summary> /// Provides virtual methods that can be used by subclasses to parse an expression tree. Property changes on: trunk/nhibernate/src/NHibernate.Linq.Test ___________________________________________________________________ Modified: svn:ignore - [Bb]in obj [Dd]ebug [Rr]elease *.user *.aps *.eto + [Bb]in obj [Dd]ebug [Rr]elease *.user *.aps *.eto hibernate.cfg.xml Added: trunk/nhibernate/src/NHibernate.Linq.Test/App.config =================================================================== --- trunk/nhibernate/src/NHibernate.Linq.Test/App.config (rev 0) +++ trunk/nhibernate/src/NHibernate.Linq.Test/App.config 2008-08-12 18:47:36 UTC (rev 3699) @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8" ?> +<configuration> + <configSections> + <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" /> + </configSections> + + <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" > + <session-factory name="NHibernate.Linq.Test"> + <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property> + <property name="connection.connection_string"> + Server=.\SQLEXPRESS;initial catalog=linq2nhibernate;Integrated Security=true + </property> + <property name="adonet.batch_size">10</property> + <property name="show_sql">false</property> + <property name="dialect">NHibernate.Dialect.MsSql2000Dialect</property> + <property name="use_outer_join">true</property> + <property name="command_timeout">444</property> + <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property> + <mapping assembly="NHibernate.Linq.Test" /> + </session-factory> + </hibernate-configuration> +</configuration> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Linq.Test/BaseTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Linq.Test/BaseTest.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Linq.Test/BaseTest.cs 2008-08-12 18:47:36 UTC (rev 3699) @@ -0,0 +1,31 @@ +using System.Configuration; +using System.Data; +using System.Data.SqlClient; +using NUnit.Framework; + +namespace NHibernate.Linq.Test +{ + public class BaseTest + { + protected ISession session; + + static BaseTest() + { + GlobalSetup.SetupNHibernate(); + } + + [SetUp] + public virtual void Setup() + { + session = GlobalSetup.CreateSession(); + } + + [TearDown] + public virtual void TearDown() + { + session.Connection.Dispose(); + session.Dispose(); + session = null; + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Linq.Test/GlobalSetup.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Linq.Test/GlobalSetup.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Linq.Test/GlobalSetup.cs 2008-08-12 18:47:36 UTC (rev 3699) @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Data; +using NHibernate; +using NUnit.Framework; +using NHibernate.Cfg; +using NHibernate.Tool.hbm2ddl; + +namespace NHibernate.Linq.Test +{ + public static class GlobalSetup + { + private static ISessionFactory factory; + + public static void SetupNHibernate() + { + Configuration cfg = new Configuration().Configure(); + new SchemaExport(cfg).Execute(false, true, false, true); + factory = cfg.BuildSessionFactory(); + } + + public static ISession CreateSession() + { + return factory.OpenSession(); + } + + public static ISession CreateSession(IDbConnection con) + { + return factory.OpenSession(con); + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Linq.Test/Model/Animal.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Linq.Test/Model/Animal.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Linq.Test/Model/Animal.cs 2008-08-12 18:47:36 UTC (rev 3699) @@ -0,0 +1,108 @@ +using System; +using System.Collections.Generic; +using Iesi.Collections.Generic; + +namespace NHibernate.Linq.Test.Model +{ + public class Animal + { + public virtual int Id { get; set; } + public virtual string Description { get; set; } + public virtual double BodyWeight { get; set; } + public virtual Animal Mother { get; set; } + public virtual Animal Father { get; set; } + public virtual Zoo Zoo { get; set; } + public virtual string SerialNumber { get; set; } + public virtual ISet<Animal> Offspring { get; set; } + } + + public class Reptile : Animal + { + public virtual double BodyTemperature { get; set; } + } + + public class Lizard : Reptile { } + + public class Mammal : Animal + { + public virtual bool Pregnant { get; set; } + public virtual DateTime? BirthDate { get; set; } + } + + public class DomesticAnimal : Mammal + { + public virtual Human Owner { get; set; } + } + + public class Cat : DomesticAnimal { } + + public class Dog : DomesticAnimal { } + + public class Human : Mammal + { + public virtual HumanName Name { get; set; } + public virtual string NickName { get; set; } + public virtual double Height { get; set; } + public virtual int IntValue { get; set; } + public virtual float FloatValue { get; set; } + public virtual decimal DecimalValue { get; set; } + public virtual Int64 Int64Value { get; set; } + public virtual IList<Human> Friends { get; set; } + public virtual IDictionary<string, Human> Family { get; set; } + public virtual IList<DomesticAnimal> Pets { get; set; } + public virtual ISet<string> NickNames { get; set; } + public virtual IDictionary<string, Address> Addresses { get; set; } + } + + public struct Address + { + public string Street { get; set; } + public string City { get; set; } + public string PostalCode { get; set; } + public string Country { get; set; } + public StateProvince StateProvince { get; set; } + } + + public struct HumanName + { + public string First { get; set; } + public string Initial { get; set; } + public string Last { get; set; } + } + + public class User + { + public virtual int Id { get; set; } + public virtual Human Human { get; set; } + public virtual string UserName { get; set; } + public virtual IList<string> Permissions { get; set; } + } + + public class Zoo + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + public virtual ClassificationType Classification { get; set; } + public virtual IDictionary<string, Mammal> Mammals { get; set; } + public virtual IDictionary<string, Animal> Animals { get; set; } + public virtual Address Address { get; set; } + } + + public enum ClassificationType { Large, Medium, Small } + + public class PettingZoo : Zoo { } + + public class StateProvince + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + public virtual string IsoCode { get; set; } + } + + public class Joiner + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + public virtual string JoinedName { get; set; } + } +} Added: trunk/nhibernate/src/NHibernate.Linq.Test/Model/Animal.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Linq.Test/Model/Animal.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Linq.Test/Model/Animal.hbm.xml 2008-08-12 18:47:36 UTC (rev 3699) @@ -0,0 +1,170 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="NHibernate.Linq.Test.Model" assembly="NHibernate.Linq.Test"> + <class name="Animal"> + <id name="Id"> + <generator class="native"/> + </id> + + <property name="Description"/> + <property name="BodyWeight" column="body_weight"/> + <many-to-one name="Mother" column="mother_id"/> + <many-to-one name="Father" column="father_id"/> + <many-to-one name="Zoo" column="zoo_id"/> + <property name="SerialNumber"/> + + <set name="Offspring" order-by="father_id"> + <key column="mother_id"/> + <one-to-many class="Animal"/> + </set> + + <joined-subclass name="Reptile"> + <key column="Animal"/> + <property name="BodyTemperature"/> + + <joined-subclass name="Lizard"> + <key column="Reptile"/> + </joined-subclass> + </joined-subclass> + + <joined-subclass name="Mammal"> + <key column="Animal"/> + <property name="Pregnant"/> + <property name="BirthDate" type="DateTime"/> + + <joined-subclass name="DomesticAnimal"> + <key column="Mammal"/> + <many-to-one name="Owner"/> + + <joined-subclass name="Cat"> + <key column="mammal"/> + </joined-subclass> + + <joined-subclass name="Dog"> + <key column="mammal"/> + </joined-subclass> + </joined-subclass> + + <joined-subclass name="Human"> + <key column="Mammal"/> + + <component name="Name"> + <property name="First" column="name_first"/> + <property name="Initial" column="name_initial"/> + <property name="Last" column="name_last"/> + </component> + + <property name="NickName"/> + <property name="Height"/> + + <property name="IntValue"/> + <property name="FloatValue"/> + <property name="DecimalValue"/> + <property name="Int64Value"/> + + <bag name="Friends"> + <key column="Human1"/> + <many-to-many column="Human2" class="Human"/> + </bag> + + <map name="Family"> + <key column="Human1"/> + <map-key column="Relationship" type="AnsiString"/> + <many-to-many column="Human2" class="Human"/> + </map> + + <bag name="Pets" inverse="true"> + <key column="Owner"/> + <one-to-many class="DomesticAnimal"/> + </bag> + + <set name="NickNames" lazy="false" table="human_nick_names" sort="natural"> + <key column="Human"/> + <element column="nick_name" type="string" not-null="true" /> + </set> + + <map name="Addresses" table="addresses"> + <key column="Human"/> + <map-key type="string" column="type" /> + + <composite-element class="Address"> + <property name="Street"/> + <property name="City"/> + <property name="PostalCode"/> + <property name="Country"/> + <many-to-one name="StateProvince" column="state_prov_id" class="StateProvince" /> + </composite-element> + </map> + </joined-subclass> + </joined-subclass> + </class> + + <class name="User" table="User"> + <id name="Id"> + <generator class="foreign"> + <param name="property">Human</param> + </generator> + </id> + + <property name="UserName" /> + <one-to-one name="Human" constrained="true" /> + + <list name="Permissions"> + <key column="UserId" /> + <list-index column="PermissionId" /> + <element type="string" column="PermissionName" /> + </list> + </class> + + <class name="Zoo" discriminator-value="Z"> + <id name="Id"> + <generator class="native"/> + </id> + <discriminator column="ZooType" type="character"/> + + <property name="Name" type="String"/> + <property name="Classification" /> + + <map name="Mammals"> + <key column="MammalZoo_id"/> + <index type="string" column="Name"/> + <one-to-many class="Mammal"/> + </map> + + <map name="Animals" inverse="true"> + <key column="zoo_id"/> + <index type="string" column="SerialNumber"/> + <one-to-many class="Animal"/> + </map> + + <component name="Address" class="Address"> + <property name="Street"/> + <property name="City"/> + <property name="PostalCode"/> + <property name="Country"/> + <many-to-one name="StateProvince" column="state_prov_id" class="StateProvince" /> + </component> + + <subclass name="PettingZoo" discriminator-value="P"/> + </class> + + <class name="StateProvince"> + <id name="Id"> + <generator class="native"/> + </id> + + <property name="Name"/> + <property name="IsoCode"/> + </class> + + <class name="Joiner"> + <id name="Id"> + <generator class="native"/> + </id> + + <property name="Name"/> + <join table="JOINED"> + <key column="Id"/> + <property name="JoinedName"/> + </join> + </class> +</hibernate-mapping> \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Linq.Test/NHibernate.Linq.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Linq.Test/NHibernate.Linq.Test.csproj 2008-08-12 15:40:30 UTC (rev 3698) +++ trunk/nhibernate/src/NHibernate.Linq.Test/NHibernate.Linq.Test.csproj 2008-08-12 18:47:36 UTC (rev 3699) @@ -32,6 +32,14 @@ <TreatWarningsAsErrors>true</TreatWarningsAsErrors> </PropertyGroup> <ItemGroup> + <Reference Include="Iesi.Collections, Version=1.0.0.3, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\lib\net\2.0\Iesi.Collections.dll</HintPath> + </Reference> + <Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\lib\net\2.0\log4net.dll</HintPath> + </Reference> <Reference Include="nunit.core, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>..\..\lib\net\2.0\nunit.core.dll</HintPath> @@ -57,6 +65,17 @@ <Name>NHibernate-3.5</Name> </ProjectReference> </ItemGroup> + <ItemGroup> + <EmbeddedResource Include="Model\Animal.hbm.xml" /> + </ItemGroup> + <ItemGroup> + <None Include="App.config" /> + </ItemGroup> + <ItemGroup> + <Compile Include="BaseTest.cs" /> + <Compile Include="GlobalSetup.cs" /> + <Compile Include="Model\Animal.cs" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |