|
From: <dar...@us...> - 2009-02-04 22:19:13
|
Revision: 4044
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4044&view=rev
Author: darioquintana
Date: 2009-02-04 21:49:37 +0000 (Wed, 04 Feb 2009)
Log Message:
-----------
Refactoring: running datetimes test in a separated way
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/AllDates.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTime2Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeAssert.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeOffSetFixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DatesFixtureBase.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/DateTime2.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/DateTimeOffset.hbm.xml
Removed Paths:
-------------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTime2AndDateTimeOffSetFixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings.hbm.xml
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/AllDates.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/AllDates.cs 2009-02-04 04:46:26 UTC (rev 4033)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/AllDates.cs 2009-02-04 21:49:37 UTC (rev 4044)
@@ -1,6 +1,6 @@
using System;
-namespace NHibernate.Test.NHSpecificTest.DateTime2AndDateTimeOffSet
+namespace NHibernate.Test.NHSpecificTest.Dates
{
public class AllDates
{
Deleted: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTime2AndDateTimeOffSetFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/DateTime2AndDateTimeOffSetFixture.cs 2009-02-04 04:46:26 UTC (rev 4033)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTime2AndDateTimeOffSetFixture.cs 2009-02-04 21:49:37 UTC (rev 4044)
@@ -1,85 +0,0 @@
-using System;
-using System.Collections;
-using NHibernate.Dialect;
-using NHibernate.Type;
-using NUnit.Framework;
-
-namespace NHibernate.Test.NHSpecificTest.DateTime2AndDateTimeOffSet
-{
- [TestFixture]
- public class DateTime2AndDateTimeOffSetFixture : TestCase
- {
- protected override IList Mappings
- {
- get { return new[] {"NHSpecificTest.DateTime2AndDateTimeOffSet.Mappings.hbm.xml"}; }
- }
-
- protected override string MappingsAssembly
- {
- get { return "NHibernate.Test"; }
- }
-
- protected override bool AppliesTo(Dialect.Dialect dialect)
- {
- return dialect is MsSql2008Dialect;
- }
-
-
- public class DateTimeAssert
- {
- public static void AreEqual(DateTime dt1, DateTime dt2)
- {
- bool areEqual = new DateTimeType().IsEqual(dt1, dt2);
-
- if (!areEqual)
- Assert.Fail("Expected {0} but was {1}");
- }
-
- public static void AreEqual(DateTimeOffset dt1, DateTimeOffset dt2)
- {
- bool areEqual = new DateTimeOffsetType().IsEqual(dt1, dt2);
-
- if (!areEqual)
- Assert.Fail("Expected {0} but was {1}");
- }
- }
-
- [Test]
- public void SavingAndRetrieving()
- {
- DateTime Now = DateTime.Now;
- DateTimeOffset NowOS = DateTimeOffset.Now;
- var dates = new AllDates
- {
- Sql_datetime = Now,
- Sql_datetime2 = DateTime.MinValue,
- Sql_datetimeoffset = NowOS,
- };
-
- using (ISession s = OpenSession())
- using (ITransaction tx = s.BeginTransaction())
- {
- s.Save(dates);
- tx.Commit();
- }
-
- using (ISession s = OpenSession())
- using (ITransaction tx = s.BeginTransaction())
- {
- var datesRecovered = s.CreateQuery("from AllDates").UniqueResult<AllDates>();
-
- DateTimeAssert.AreEqual(datesRecovered.Sql_datetime, Now);
- DateTimeAssert.AreEqual(datesRecovered.Sql_datetime2, DateTime.MinValue);
- DateTimeAssert.AreEqual(datesRecovered.Sql_datetimeoffset, NowOS);
- }
-
- using (ISession s = OpenSession())
- using (ITransaction tx = s.BeginTransaction())
- {
- var datesRecovered = s.CreateQuery("from AllDates").UniqueResult<AllDates>();
- s.Delete(datesRecovered);
- tx.Commit();
- }
- }
- }
-}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTime2Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTime2Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTime2Fixture.cs 2009-02-04 21:49:37 UTC (rev 4044)
@@ -0,0 +1,31 @@
+using System;
+using System.Collections;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.Dates
+{
+ [TestFixture]
+ public class DateTime2Fixture : DatesFixtureBase
+ {
+ protected override IList Mappings
+ {
+ get { return new[] {"NHSpecificTest.Dates.Mappings.DateTime2.hbm.xml"}; }
+ }
+
+ [Test]
+ public void SavingAndRetrievingTest()
+ {
+ DateTime Now = DateTime.Now;
+
+ SavingAndRetrievingAction(new AllDates {Sql_datetime2 = Now},
+ entity => DateTimeAssert.AreEqual(entity.Sql_datetime2, Now));
+
+
+ SavingAndRetrievingAction(new AllDates { Sql_datetime2 = DateTime.MinValue },
+ entity => DateTimeAssert.AreEqual(entity.Sql_datetime2, DateTime.MinValue));
+
+ SavingAndRetrievingAction(new AllDates { Sql_datetime2 = DateTime.MaxValue },
+ entity => DateTimeAssert.AreEqual(entity.Sql_datetime2, DateTime.MaxValue));
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeAssert.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeAssert.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeAssert.cs 2009-02-04 21:49:37 UTC (rev 4044)
@@ -0,0 +1,25 @@
+using System;
+using NHibernate.Type;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.Dates
+{
+ public class DateTimeAssert
+ {
+ public static void AreEqual(DateTime dt1, DateTime dt2)
+ {
+ bool areEqual = new DateTimeType().IsEqual(dt1, dt2);
+
+ if (!areEqual)
+ Assert.Fail(string.Format("Expected {0} but was {1}",dt1,dt2));
+ }
+
+ public static void AreEqual(DateTimeOffset dt1, DateTimeOffset dt2)
+ {
+ bool areEqual = new DateTimeOffsetType().IsEqual(dt1, dt2);
+
+ if (!areEqual)
+ Assert.Fail(string.Format("Expected {0} but was {1}", dt1, dt2));
+ }
+ }
+}
\ No newline at end of file
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeOffSetFixture.cs (from rev 4033, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/DateTime2AndDateTimeOffSetFixture.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeOffSetFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeOffSetFixture.cs 2009-02-04 21:49:37 UTC (rev 4044)
@@ -0,0 +1,24 @@
+using System;
+using System.Collections;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.Dates
+{
+ [TestFixture]
+ public class DateTimeOffSetFixture : DatesFixtureBase
+ {
+ protected override IList Mappings
+ {
+ get { return new[] {"NHSpecificTest.Dates.Mappings.DateTimeOffset.hbm.xml"}; }
+ }
+
+ [Test]
+ public void SavingAndRetrievingTest()
+ {
+ DateTimeOffset NowOS = DateTimeOffset.Now;
+
+ SavingAndRetrievingAction(new AllDates {Sql_datetimeoffset = NowOS},
+ entity => DateTimeAssert.AreEqual(entity.Sql_datetimeoffset, NowOS));
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DatesFixtureBase.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DatesFixtureBase.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DatesFixtureBase.cs 2009-02-04 21:49:37 UTC (rev 4044)
@@ -0,0 +1,51 @@
+using System;
+using System.Collections;
+using NHibernate.Dialect;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.Dates
+{
+ [TestFixture]
+ public abstract class DatesFixtureBase : TestCase
+ {
+ protected abstract override IList Mappings { get; }
+
+ protected override string MappingsAssembly
+ {
+ get { return "NHibernate.Test"; }
+ }
+
+ protected override bool AppliesTo(Dialect.Dialect dialect)
+ {
+ return dialect is MsSql2008Dialect;
+ }
+
+ protected void SavingAndRetrievingAction(AllDates entity, Action<AllDates> action)
+ {
+ AllDates dates = entity;
+
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ s.Save(dates);
+ tx.Commit();
+ }
+
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ var datesRecovered = s.CreateQuery("from AllDates").UniqueResult<AllDates>();
+
+ action.Invoke(datesRecovered);
+ }
+
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ var datesRecovered = s.CreateQuery("from AllDates").UniqueResult<AllDates>();
+ s.Delete(datesRecovered);
+ tx.Commit();
+ }
+ }
+ }
+}
\ No newline at end of file
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/DateTime2.hbm.xml (from rev 4033, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/Mappings.hbm.xml)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/DateTime2.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/DateTime2.hbm.xml 2009-02-04 21:49:37 UTC (rev 4044)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.Dates"
+ assembly="NHibernate.Test">
+
+ <class name="AllDates" lazy="false">
+
+ <id name="Id">
+ <generator class="native"/>
+ </id>
+
+ <property name="Sql_datetime2" type="datetime2" />
+
+ </class>
+
+</hibernate-mapping>
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/DateTimeOffset.hbm.xml (from rev 4033, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/Mappings.hbm.xml)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/DateTimeOffset.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/DateTimeOffset.hbm.xml 2009-02-04 21:49:37 UTC (rev 4044)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.Dates"
+ assembly="NHibernate.Test">
+
+ <class name="AllDates" lazy="false">
+
+ <id name="Id">
+ <generator class="native"/>
+ </id>
+
+ <property name="Sql_datetimeoffset" type="datetimeoffset" />
+
+ </class>
+
+</hibernate-mapping>
Deleted: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/Mappings.hbm.xml 2009-02-04 04:46:26 UTC (rev 4033)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings.hbm.xml 2009-02-04 21:49:37 UTC (rev 4044)
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
- namespace="NHibernate.Test.NHSpecificTest.DateTime2AndDateTimeOffSet"
- assembly="NHibernate.Test">
-
- <class name="AllDates" lazy="false">
-
- <id name="Id">
- <generator class="identity"/>
- </id>
-
- <property name="Sql_datetime" />
- <property name="Sql_datetime2" type="datetime2" />
- <property name="Sql_datetimeoffset" type="datetimeoffset" />
-
- </class>
-
-</hibernate-mapping>
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-04 20:49:36 UTC (rev 4043)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-04 21:49:37 UTC (rev 4044)
@@ -380,11 +380,14 @@
<Compile Include="NHSpecificTest\BasicTimeFixture.cs" />
<Compile Include="NHSpecificTest\BugTestCase.cs" />
<Compile Include="NHSpecificTest\CollectionFixture.cs" />
+ <Compile Include="NHSpecificTest\Dates\DatesFixtureBase.cs" />
+ <Compile Include="NHSpecificTest\Dates\DateTime2Fixture.cs" />
+ <Compile Include="NHSpecificTest\Dates\DateTimeAssert.cs" />
<Compile Include="NHSpecificTest\Futures\FutureQueryFixture.cs" />
<Compile Include="NHSpecificTest\Futures\FutureCriteriaFixture.cs" />
<Compile Include="NHSpecificTest\Futures\Person.cs" />
- <Compile Include="NHSpecificTest\DateTime2AndDateTimeOffSet\AllDates.cs" />
- <Compile Include="NHSpecificTest\DateTime2AndDateTimeOffSet\DateTime2AndDateTimeOffSetFixture.cs" />
+ <Compile Include="NHSpecificTest\Dates\AllDates.cs" />
+ <Compile Include="NHSpecificTest\Dates\DateTimeOffSetFixture.cs" />
<Compile Include="NHSpecificTest\NH1274ExportExclude\Home.cs" />
<Compile Include="NHSpecificTest\NH1274ExportExclude\NH1274ExportExcludeFixture.cs" />
<Compile Include="NHSpecificTest\NH1274ExportExclude\Person.cs" />
@@ -1619,9 +1622,10 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\Dates\Mappings\DateTimeOffset.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1654\Mappings.hbm.xml" />
<EmbeddedResource Include="Pagination\DataPoint.hbm.xml" />
- <EmbeddedResource Include="NHSpecificTest\DateTime2AndDateTimeOffSet\Mappings.hbm.xml" />
+ <EmbeddedResource Include="NHSpecificTest\Dates\Mappings\DateTime2.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\Futures\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1643\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1640\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|