Skip to content

Commit cae00d3

Browse files
author
Mike Doerfler
committed
more work on test fixture.
SVN: trunk@1147
1 parent e6c8bca commit cae00d3

File tree

3 files changed

+43
-6
lines changed

3 files changed

+43
-6
lines changed

src/NHibernate.DomainModel/Baz.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,8 @@ public System.Collections.IList ByteBag
546546

547547
public void SetDefaults()
548548
{
549+
DateTime today = new DateTime( DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day );
550+
549551
StringSet = new Iesi.Collections.HashedSet();
550552
StringSet.Add( "foo" );
551553
StringSet.Add( "bar" );
@@ -574,7 +576,7 @@ public void SetDefaults()
574576
Count = 667;
575577
Name="Bazza";
576578
TopComponents = new ArrayList();
577-
TopComponents.Add( new FooComponent("foo", 11, new DateTime[] { new DateTime(), new DateTime(2123,1,1) }, null) );
579+
TopComponents.Add( new FooComponent("foo", 11, new DateTime[] { today, new DateTime(2123,1,1) }, null) );
578580
TopComponents.Add( new FooComponent("bar", 22, new DateTime[] { new DateTime(2007,2,3), new DateTime(1945,6,1) }, null) );
579581
TopComponents.Add( null );
580582
Bag = new ArrayList();

src/NHibernate.DomainModel/Foo.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ public LifecycleVeto OnSave(ISession s)
347347
{
348348
"foo", "bar"
349349
};
350-
_component = new FooComponent("foo", 12, new DateTime[] { _date, _timestamp, DateTime.MinValue, new DateTime() }, new FooComponent("bar", 666, new DateTime[] { new DateTime(1999,12,3), DateTime.MinValue }, null ) );
350+
_component = new FooComponent("foo", 12, new DateTime[] { _date, _timestamp, DateTime.MinValue, new DateTime( DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day ) }, new FooComponent("bar", 666, new DateTime[] { new DateTime(1999,12,3), DateTime.MinValue }, null ) );
351351
_component.Glarch = new Glarch();
352352
_dependent = new Fee();
353353
_dependent.Fi = "belongs to foo # " + Key;

src/NHibernate.Test/FooBarTest.cs

+39-4
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ public void AssociationId()
841841
t = s.BeginTransaction();
842842
//The special property (lowercase) id may be used to reference the unique identifier of an object. (You may also use its property name.)
843843
string hqlString = "from s in class Stuff where s.Foo.id = ? and s.id.Id = ? and s.MoreStuff.id.IntId = ? and s.MoreStuff.id.StringId = ?";
844-
object[] values = new object[] {bar, (long)1234, (int)12, "id" };
844+
object[] values = new object[] {bar, (long)1234, 12, "id" };
845845
Type.IType[] types = new Type.IType[]
846846
{
847847
NHibernate.Entity(typeof(Foo)),
@@ -1818,8 +1818,45 @@ public void Query()
18181818
s.Find( "from Baz baz left join baz.FooToGlarch join baz.FooSet" );
18191819
s.Find( "from Baz baz left join baz.FooToGlarch join fetch baz.FooSet foo left join fetch foo.TheFoo" );
18201820

1821-
//TODO: resume h2.0.3 - line 1613
1821+
// foo.Boolean = true
1822+
list = s.Find( "from foo in class NHibernate.DomainModel.Foo where foo.String='osama bin laden' and foo.Boolean = 1 order by foo.String asc, foo.Component.Count desc" );
1823+
Assert.AreEqual( 0, list.Count, "empty query" );
1824+
IEnumerable enumer = s.Enumerable( "from foo in class NHibernate.DomainModel.Foo where foo.String='osama bin laden' order by foo.String asc, foo.Component.Count desc" );
1825+
Assert.IsFalse( enumer.GetEnumerator().MoveNext(), "empty enumerator" );
1826+
1827+
list = s.Find( "select foo.TheFoo from foo in class NHibernate.DomainModel.Foo" );
1828+
Assert.AreEqual( 1, list.Count, "query" );
1829+
Assert.AreEqual( foo.TheFoo, list[0], "returned object" );
1830+
foo.TheFoo.TheFoo = foo;
1831+
foo.String = "fizard";
1832+
1833+
// the following test is disabled for databases with no subselects...also for Interbase (not sure why) - h2.0.3
1834+
// also HSQLDialect, MckoiDialect, SAPDBDialect, PointbaseDialect
1835+
if( !(dialect is Dialect.MySQLDialect) )
1836+
{
1837+
// add an !InterbaseDialect wrapper around list and assert
1838+
list = s.Find( "from foo in class NHibernate.DomainModel.Foo where ? = some foo.Component.ImportantDates.elements", new DateTime( DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day ), NHibernate.DateTime );
1839+
Assert.AreEqual( 2, list.Count, "componenet query" );
1840+
}
1841+
1842+
// WAS: 3 in h2.0.3 - there's a null value at index 2 that is not in the db with hibernate - it is a missing index
1843+
// in the db
1844+
list = s.Find( "from foo in class NHibernate.DomainModel.Foo where size(foo.Component.ImportantDates) = 4" );
1845+
Assert.AreEqual( 2, list.Count, "component query" );
1846+
list = s.Find( "from foo in class Foo where 0 = size(foo.Component.ImportantDates)" );
1847+
Assert.AreEqual( 0, list.Count, "component query" );
1848+
list = s.Find( "from foo in class Foo where exists elements(foo.Component.ImportantDates)" );
1849+
Assert.AreEqual( 2, list.Count, "component query" );
1850+
s.Find( "from foo in class Foo where not exists (from bar in class Bar where bar.id = foo.id)" );
1851+
1852+
s.Find( "select foo.TheFoo from foo in class Foo where foo = some(select x from x in class Foo where x.Long > foo.TheFoo.Long)" );
1853+
s.Find( "from foo in class Foo where foo = some(select x from x in class Foo where x.Long > foo.TheFoo.Long) and foo.TheFoo.String='baz'" );
1854+
s.Find( "from foo in class Foo where foo.TheFoo.String='baz' and foo = some(select x from x in class Foo where x.Long>foo.TheFoo.Long)" );
1855+
s.Find( "from foo in class Foo where foo = some(select x from x in class Foo where x.Long > foo.TheFoo.Long)" );
1856+
1857+
s.Enumerable( "select foo.String, foo.Date, foo.TheFoo.String, foo.id from foo in class Foo, baz in class Baz where foo in elements(baz.FooArray) and foo.String like 'foo'" );
18221858
}
1859+
// line 1645
18231860

18241861
[Test]
18251862
public void DeleteRecursive()
@@ -2907,7 +2944,6 @@ public void ProxyArray()
29072944
s.Save( g3 );
29082945
g2.ProxyArray = new GlarchProxy[] { null, g3, g };
29092946

2910-
object emptyObject = new object();
29112947
Iesi.Collections.ISet hashset = new Iesi.Collections.HashedSet();
29122948
hashset.Add( g1 );
29132949
hashset.Add( g2 );
@@ -3501,7 +3537,6 @@ public void ProxiesInCollections()
35013537
object bar2id = s.Save( bar2 );
35023538
baz.FooArray = new Foo[] { bar, bar2 };
35033539

3504-
object emptyObject = new object();
35053540
Iesi.Collections.ISet hashset = new Iesi.Collections.HashedSet();
35063541
bar = new Bar();
35073542
s.Save( bar );

0 commit comments

Comments
 (0)