From: <pa...@us...> - 2011-03-02 04:28:25
|
Revision: 5411 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5411&view=rev Author: patearl Date: 2011-03-02 04:28:18 +0000 (Wed, 02 Mar 2011) Log Message: ----------- Improved portability of NHibernate.Test.Component.Basic.ComponentTest. Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/Component/Basic/ComponentTest.cs Modified: trunk/nhibernate/src/NHibernate.Test/Component/Basic/ComponentTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Component/Basic/ComponentTest.cs 2011-03-01 16:51:25 UTC (rev 5410) +++ trunk/nhibernate/src/NHibernate.Test/Component/Basic/ComponentTest.cs 2011-03-02 04:28:18 UTC (rev 5411) @@ -1,5 +1,8 @@ using System; +using System.Collections; using System.Collections.Generic; +using System.IO; +using System.Reflection; using NHibernate; using NHibernate.Cfg; using NHibernate.Criterion; @@ -18,12 +21,30 @@ protected override System.Collections.IList Mappings { - get { return new string[] { "Component.Basic.User.hbm.xml" }; } + get { return new string[] { }; } } protected override void Configure(Configuration configuration) { - configuration.SetProperty(NHibernate.Cfg.Environment.GenerateStatistics, "true"); + if (Dialect.Functions.ContainsKey("year")) + { + using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("NHibernate.Test.Component.Basic.User.hbm.xml")) + { + using (StreamReader reader = new StreamReader(stream)) + { + string mapping = reader.ReadToEnd(); + + IList args = new ArrayList(); + args.Add("dob"); + // We don't have a session factory yet... is there some way to get one sooner? + string replacement = Dialect.Functions["year"].Render(args, null).ToString(); + mapping = mapping.Replace("year(dob)", replacement); + + configuration.AddXml(mapping); + configuration.SetProperty(Cfg.Environment.GenerateStatistics, "true"); + } + } + } } protected override void OnTearDown() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |