|
From: <dar...@us...> - 2009-03-29 15:37:07
|
Revision: 4166
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4166&view=rev
Author: darioquintana
Date: 2009-03-29 15:36:13 +0000 (Sun, 29 Mar 2009)
Log Message:
-----------
- the actual TimeSpan type moved to TimeAsTimeSpan.
- TimeSpanInt64 type moved back to TimeSpan (related to NH-1617)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate/NHibernateUtil.cs
trunk/nhibernate/src/NHibernate/Type/TimeType.cs
trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/AllDates.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/Time.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Type/TimeAsTimeSpanType.cs
trunk/nhibernate/src/NHibernate/Type/TimeSpanType.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/TimeAsTimeSpan.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/TimeAsTimeSpanFixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/TimeFixture.cs
trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeAsTimeSpanClass.cs
trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeAsTimeSpanClass.hbm.xml
trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeAsTimeSpanTypeFixture.cs
trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanClass.cs
trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanClass.hbm.xml
trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanTypeFixture.cs
Removed Paths:
-------------
trunk/nhibernate/src/NHibernate/Type/TimeSpanInt64Type.cs
trunk/nhibernate/src/NHibernate/Type/TimeSpanType.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/TimeFixture.cs
trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanClass.cs
trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanClass.hbm.xml
trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanInt64Class.cs
trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanInt64Class.hbm.xml
trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanInt64TypeFixture.cs
trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanTypeFixture.cs
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-03-29 06:27:12 UTC (rev 4165)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-03-29 15:36:13 UTC (rev 4166)
@@ -395,7 +395,7 @@
<Compile Include="Type\StringClobType.cs" />
<Compile Include="Type\StringType.cs" />
<Compile Include="Type\TicksType.cs" />
- <Compile Include="Type\TimeSpanInt64Type.cs" />
+ <Compile Include="Type\TimeSpanType.cs" />
<Compile Include="Type\TimestampType.cs" />
<Compile Include="Type\TimeType.cs" />
<Compile Include="Type\TrueFalseType.cs" />
@@ -1092,7 +1092,7 @@
<Compile Include="Type\AnyType.cs" />
<Compile Include="Type\AbstractCharType.cs" />
<Compile Include="Type\CurrencyType.cs" />
- <Compile Include="Type\TimeSpanType.cs" />
+ <Compile Include="Type\TimeAsTimeSpanType.cs" />
<Compile Include="Type\DateTime2Type.cs" />
<Compile Include="Type\ClassMetaType.cs" />
<Compile Include="Type\CollectionType.cs" />
Modified: trunk/nhibernate/src/NHibernate/NHibernateUtil.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernateUtil.cs 2009-03-29 06:27:12 UTC (rev 4165)
+++ trunk/nhibernate/src/NHibernate/NHibernateUtil.cs 2009-03-29 15:36:13 UTC (rev 4166)
@@ -213,12 +213,12 @@
/// <summary>
/// NHibernate Ticks type
/// </summary>
- public static readonly NullableType TimeSpan = new TimeSpanType();
+ public static readonly NullableType TimeAsTimeSpan = new TimeAsTimeSpanType();
/// <summary>
/// NHibernate Ticks type
/// </summary>
- public static readonly NullableType TimeSpanInt64 = new TimeSpanInt64Type();
+ public static readonly NullableType TimeSpan = new TimeSpanType();
/// <summary>
/// NHibernate Timestamp type
Copied: trunk/nhibernate/src/NHibernate/Type/TimeAsTimeSpanType.cs (from rev 4165, trunk/nhibernate/src/NHibernate/Type/TimeSpanType.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/TimeAsTimeSpanType.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Type/TimeAsTimeSpanType.cs 2009-03-29 15:36:13 UTC (rev 4166)
@@ -0,0 +1,122 @@
+using System;
+using System.Collections;
+using System.Data;
+using NHibernate.Engine;
+using NHibernate.SqlTypes;
+using System.Collections.Generic;
+
+namespace NHibernate.Type
+{
+ /// <summary>
+ /// Maps a <see cref="System.TimeSpan" /> Property to an <see cref="DbType.Time" /> column
+ /// This is an extra way to map a <see cref="DbType.Time"/>. You already have <see cref="TimeType"/>
+ /// but mapping against a <see cref="DateTime"/>.
+ /// </summary>
+ [Serializable]
+ public class TimeAsTimeSpanType : PrimitiveType, IVersionType
+ {
+ private static readonly DateTime BaseDateValue = new DateTime(1753, 01, 01);
+
+ internal TimeAsTimeSpanType()
+ : base(SqlTypeFactory.Time)
+ {
+ }
+
+ public override string Name
+ {
+ get { return "TimeAsTimeSpan"; }
+ }
+
+ public override object Get(IDataReader rs, int index)
+ {
+ try
+ {
+ object value = rs[index];
+ if(value is TimeSpan)
+ return (TimeSpan)value;
+
+ return ((DateTime)value).Subtract(BaseDateValue);
+ }
+ catch (Exception ex)
+ {
+ throw new FormatException(string.Format("Input string '{0}' was not in the correct format.", rs[index]), ex);
+ }
+ }
+
+ public override object Get(IDataReader rs, string name)
+ {
+ try
+ {
+ object value = rs[name];
+ if (value is TimeSpan) //For those dialects where DbType.Time means TimeSpan.
+ return (TimeSpan)value;
+
+ return ((DateTime)value).Subtract(BaseDateValue);
+ }
+ catch (Exception ex)
+ {
+ throw new FormatException(string.Format("Input string '{0}' was not in the correct format.", rs[name]), ex);
+ }
+ }
+
+ public override void Set(IDbCommand st, object value, int index)
+ {
+ DateTime date = BaseDateValue.AddTicks(((TimeSpan)value).Ticks);
+ ((IDataParameter) st.Parameters[index]).Value = date;
+ }
+
+ public override System.Type ReturnedClass
+ {
+ get { return typeof(TimeSpan); }
+ }
+
+ public override string ToString(object val)
+ {
+ return ((TimeSpan)val).Ticks.ToString();
+ }
+
+ #region IVersionType Members
+
+ public object Next(object current, ISessionImplementor session)
+ {
+ return Seed(session);
+ }
+
+ public virtual object Seed(ISessionImplementor session)
+ {
+ return new TimeSpan(DateTime.Now.Ticks);
+ }
+
+ public object StringToObject(string xml)
+ {
+ return TimeSpan.Parse(xml);
+ }
+
+ public IComparer Comparator
+ {
+ get { return Comparer<TimeSpan>.Default; }
+ }
+
+ #endregion
+
+ public override object FromStringValue(string xml)
+ {
+ return TimeSpan.Parse(xml);
+ }
+
+ public override System.Type PrimitiveClass
+ {
+ get { return typeof(TimeSpan); }
+ }
+
+ public override object DefaultValue
+ {
+ get { return TimeSpan.Zero; }
+ }
+
+ public override string ObjectToSQLString(object value, Dialect.Dialect dialect)
+ {
+ return '\'' + ((TimeSpan)value).Ticks.ToString() + '\'';
+ }
+ }
+}
\ No newline at end of file
Deleted: trunk/nhibernate/src/NHibernate/Type/TimeSpanInt64Type.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/TimeSpanInt64Type.cs 2009-03-29 06:27:12 UTC (rev 4165)
+++ trunk/nhibernate/src/NHibernate/Type/TimeSpanInt64Type.cs 2009-03-29 15:36:13 UTC (rev 4166)
@@ -1,119 +0,0 @@
-using System;
-using System.Collections;
-using System.Data;
-using NHibernate.Engine;
-using NHibernate.SqlTypes;
-using System.Collections.Generic;
-
-namespace NHibernate.Type
-{
- /// <summary>
- /// Maps a <see cref="System.TimeSpan" /> Property to an <see cref="DbType.Int64" /> column
- /// </summary>
- [Serializable]
- public class TimeSpanInt64Type : PrimitiveType, IVersionType, ILiteralType
- {
- /// <summary></summary>
- internal TimeSpanInt64Type()
- : base(SqlTypeFactory.Int64)
- {
- }
-
- /// <summary></summary>
- public override string Name
- {
- get { return "TimeSpanInt64"; }
- }
-
- public override object Get(IDataReader rs, int index)
- {
- try
- {
- return new TimeSpan(Convert.ToInt64(rs[index]));
- }
- catch (Exception ex)
- {
- throw new FormatException(string.Format("Input string '{0}' was not in the correct format.", rs[index]), ex);
- }
- }
-
- public override object Get(IDataReader rs, string name)
- {
- try
- {
- return new TimeSpan(Convert.ToInt64(rs[name]));
- }
- catch (Exception ex)
- {
- throw new FormatException(string.Format("Input string '{0}' was not in the correct format.", rs[name]), ex);
- }
- }
-
- /// <summary></summary>
- public override System.Type ReturnedClass
- {
- get { return typeof(TimeSpan); }
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="st"></param>
- /// <param name="value"></param>
- /// <param name="index"></param>
- public override void Set(IDbCommand st, object value, int index)
- {
- ((IDataParameter)st.Parameters[index]).Value = ((TimeSpan)value).Ticks;
- }
-
- public override string ToString(object val)
- {
- return ((TimeSpan)val).Ticks.ToString();
- }
-
- #region IVersionType Members
-
- public object Next(object current, ISessionImplementor session)
- {
- return Seed(session);
- }
-
- /// <summary></summary>
- public virtual object Seed(ISessionImplementor session)
- {
- return new TimeSpan(DateTime.Now.Ticks);
- }
-
- public object StringToObject(string xml)
- {
- return TimeSpan.Parse(xml);
- }
-
- public IComparer Comparator
- {
- get { return Comparer<TimeSpan>.Default; }
- }
-
- #endregion
-
- public override object FromStringValue(string xml)
- {
- return TimeSpan.Parse(xml);
- }
-
- public override System.Type PrimitiveClass
- {
- get { return typeof(TimeSpan); }
- }
-
- public override object DefaultValue
- {
- get { return TimeSpan.Zero; }
- }
-
- public override string ObjectToSQLString(object value, Dialect.Dialect dialect)
- {
- return '\'' + ((TimeSpan)value).Ticks.ToString() + '\'';
- }
- }
-}
\ No newline at end of file
Deleted: trunk/nhibernate/src/NHibernate/Type/TimeSpanType.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/TimeSpanType.cs 2009-03-29 06:27:12 UTC (rev 4165)
+++ trunk/nhibernate/src/NHibernate/Type/TimeSpanType.cs 2009-03-29 15:36:13 UTC (rev 4166)
@@ -1,120 +0,0 @@
-using System;
-using System.Collections;
-using System.Data;
-using NHibernate.Engine;
-using NHibernate.SqlTypes;
-using System.Collections.Generic;
-
-namespace NHibernate.Type
-{
- /// <summary>
- /// Maps a <see cref="System.TimeSpan" /> Property to an <see cref="DbType.Time" /> column
- /// </summary>
- [Serializable]
- public class TimeSpanType : PrimitiveType, IVersionType, ILiteralType
- {
- private static readonly DateTime BaseDateValue = new DateTime(1753, 01, 01);
-
- internal TimeSpanType()
- : base(SqlTypeFactory.Time)
- {
- }
-
- public override string Name
- {
- get { return "TimeSpan"; }
- }
-
- public override object Get(IDataReader rs, int index)
- {
- try
- {
- object value = rs[index];
- if(value is TimeSpan)
- return (TimeSpan)value;
-
- return ((DateTime)value).Subtract(BaseDateValue);
- }
- catch (Exception ex)
- {
- throw new FormatException(string.Format("Input string '{0}' was not in the correct format.", rs[index]), ex);
- }
- }
-
- public override object Get(IDataReader rs, string name)
- {
- try
- {
- object value = rs[name];
- if (value is TimeSpan) //For those dialects where DbType.Time means TimeSpan.
- return (TimeSpan)value;
-
- return ((DateTime)value).Subtract(BaseDateValue);
- }
- catch (Exception ex)
- {
- throw new FormatException(string.Format("Input string '{0}' was not in the correct format.", rs[name]), ex);
- }
- }
-
- public override void Set(IDbCommand st, object value, int index)
- {
- DateTime date = BaseDateValue.AddTicks(((TimeSpan)value).Ticks);
- ((IDataParameter) st.Parameters[index]).Value = date;
- }
-
- public override System.Type ReturnedClass
- {
- get { return typeof(TimeSpan); }
- }
-
- public override string ToString(object val)
- {
- return ((TimeSpan)val).Ticks.ToString();
- }
-
- #region IVersionType Members
-
- public object Next(object current, ISessionImplementor session)
- {
- return Seed(session);
- }
-
- public virtual object Seed(ISessionImplementor session)
- {
- return new TimeSpan(DateTime.Now.Ticks);
- }
-
- public object StringToObject(string xml)
- {
- return TimeSpan.Parse(xml);
- }
-
- public IComparer Comparator
- {
- get { return Comparer<TimeSpan>.Default; }
- }
-
- #endregion
-
- public override object FromStringValue(string xml)
- {
- return TimeSpan.Parse(xml);
- }
-
- public override System.Type PrimitiveClass
- {
- get { return typeof(TimeSpan); }
- }
-
- public override object DefaultValue
- {
- get { return TimeSpan.Zero; }
- }
-
- public override string ObjectToSQLString(object value, Dialect.Dialect dialect)
- {
- return '\'' + ((TimeSpan)value).Ticks.ToString() + '\'';
- }
- }
-}
\ No newline at end of file
Copied: trunk/nhibernate/src/NHibernate/Type/TimeSpanType.cs (from rev 4165, trunk/nhibernate/src/NHibernate/Type/TimeSpanInt64Type.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/TimeSpanType.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Type/TimeSpanType.cs 2009-03-29 15:36:13 UTC (rev 4166)
@@ -0,0 +1,119 @@
+using System;
+using System.Collections;
+using System.Data;
+using NHibernate.Engine;
+using NHibernate.SqlTypes;
+using System.Collections.Generic;
+
+namespace NHibernate.Type
+{
+ /// <summary>
+ /// Maps a <see cref="System.TimeSpan" /> Property to an <see cref="DbType.Int64" /> column
+ /// </summary>
+ [Serializable]
+ public class TimeSpanType : PrimitiveType, IVersionType, ILiteralType
+ {
+ /// <summary></summary>
+ internal TimeSpanType()
+ : base(SqlTypeFactory.Int64)
+ {
+ }
+
+ /// <summary></summary>
+ public override string Name
+ {
+ get { return "TimeSpan"; }
+ }
+
+ public override object Get(IDataReader rs, int index)
+ {
+ try
+ {
+ return new TimeSpan(Convert.ToInt64(rs[index]));
+ }
+ catch (Exception ex)
+ {
+ throw new FormatException(string.Format("Input string '{0}' was not in the correct format.", rs[index]), ex);
+ }
+ }
+
+ public override object Get(IDataReader rs, string name)
+ {
+ try
+ {
+ return new TimeSpan(Convert.ToInt64(rs[name]));
+ }
+ catch (Exception ex)
+ {
+ throw new FormatException(string.Format("Input string '{0}' was not in the correct format.", rs[name]), ex);
+ }
+ }
+
+ /// <summary></summary>
+ public override System.Type ReturnedClass
+ {
+ get { return typeof(TimeSpan); }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="st"></param>
+ /// <param name="value"></param>
+ /// <param name="index"></param>
+ public override void Set(IDbCommand st, object value, int index)
+ {
+ ((IDataParameter)st.Parameters[index]).Value = ((TimeSpan)value).Ticks;
+ }
+
+ public override string ToString(object val)
+ {
+ return ((TimeSpan)val).Ticks.ToString();
+ }
+
+ #region IVersionType Members
+
+ public object Next(object current, ISessionImplementor session)
+ {
+ return Seed(session);
+ }
+
+ /// <summary></summary>
+ public virtual object Seed(ISessionImplementor session)
+ {
+ return new TimeSpan(DateTime.Now.Ticks);
+ }
+
+ public object StringToObject(string xml)
+ {
+ return TimeSpan.Parse(xml);
+ }
+
+ public IComparer Comparator
+ {
+ get { return Comparer<TimeSpan>.Default; }
+ }
+
+ #endregion
+
+ public override object FromStringValue(string xml)
+ {
+ return TimeSpan.Parse(xml);
+ }
+
+ public override System.Type PrimitiveClass
+ {
+ get { return typeof(TimeSpan); }
+ }
+
+ public override object DefaultValue
+ {
+ get { return TimeSpan.Zero; }
+ }
+
+ public override string ObjectToSQLString(object value, Dialect.Dialect dialect)
+ {
+ return '\'' + ((TimeSpan)value).Ticks.ToString() + '\'';
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Type/TimeType.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/TimeType.cs 2009-03-29 06:27:12 UTC (rev 4165)
+++ trunk/nhibernate/src/NHibernate/Type/TimeType.cs 2009-03-29 15:36:13 UTC (rev 4166)
@@ -7,6 +7,8 @@
/// <summary>
/// Maps a <see cref="System.DateTime" /> Property to an DateTime column that only stores the
/// Hours, Minutes, and Seconds of the DateTime as significant.
+ /// Also you have for <see cref="DbType.Time"/> handling, the NHibernate Type <see cref="TimeAsTimeSpanType"/>,
+ /// the which maps to a <see cref="TimeSpan"/>.
/// </summary>
/// <remarks>
/// <para>
@@ -14,7 +16,7 @@
/// using this Type indicates that you don't care about the Date portion of the DateTime.
/// </para>
/// <para>
- /// A more appropriate choice to store the duration/time is the <see cref="TimeSpanInt64Type"/>.
+ /// A more appropriate choice to store the duration/time is the <see cref="TimeSpanType"/>.
/// The underlying <see cref="DbType.Time"/> tends to be handled differently by different
/// DataProviders.
/// </para>
Modified: trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2009-03-29 06:27:12 UTC (rev 4165)
+++ trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2009-03-29 15:36:13 UTC (rev 4166)
@@ -120,8 +120,8 @@
RegisterType(typeof(SByte), NHibernateUtil.SByte, null);
RegisterType(typeof(Single), NHibernateUtil.Single, "float");
RegisterType(typeof(String), NHibernateUtil.String, "string");
- RegisterType(typeof(TimeSpan), NHibernateUtil.TimeSpanInt64,null);
- RegisterType(typeof(TimeSpan), NHibernateUtil.TimeSpan, null);
+ RegisterType(typeof(TimeSpan), NHibernateUtil.TimeAsTimeSpan, "TimeAsTimeSpan");
+ RegisterType(typeof(TimeSpan), NHibernateUtil.TimeSpan,null);
RegisterType(typeof(System.Type), NHibernateUtil.Class, "class");
RegisterType(typeof(UInt16), NHibernateUtil.UInt16, null);
@@ -141,8 +141,8 @@
typeByTypeOfName[NHibernateUtil.TrueFalse.Name] = NHibernateUtil.TrueFalse;
typeByTypeOfName[NHibernateUtil.YesNo.Name] = NHibernateUtil.YesNo;
typeByTypeOfName[NHibernateUtil.Ticks.Name] = NHibernateUtil.Ticks;
- typeByTypeOfName[NHibernateUtil.TimeSpanInt64.Name] = NHibernateUtil.TimeSpanInt64;
typeByTypeOfName[NHibernateUtil.TimeSpan.Name] = NHibernateUtil.TimeSpan;
+ typeByTypeOfName[NHibernateUtil.TimeAsTimeSpan.Name] = NHibernateUtil.TimeAsTimeSpan;
typeByTypeOfName[NHibernateUtil.Currency.Name] = NHibernateUtil.Currency;
// need to do add the key "Serializable" because the hbm files will have a
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/AllDates.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/AllDates.cs 2009-03-29 06:27:12 UTC (rev 4165)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/AllDates.cs 2009-03-29 15:36:13 UTC (rev 4166)
@@ -12,7 +12,9 @@
public DateTimeOffset Sql_datetimeoffset { get; set; }
- public TimeSpan Sql_time { get; set; }
+ public TimeSpan Sql_TimeAsTimeSpan { get; set; }
+
+ public DateTime Sql_time { get; set; }
public DateTime Sql_date { get; set; }
}
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/Time.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/Time.hbm.xml 2009-03-29 06:27:12 UTC (rev 4165)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/Time.hbm.xml 2009-03-29 15:36:13 UTC (rev 4166)
@@ -9,7 +9,7 @@
<generator class="native"/>
</id>
- <property name="Sql_time" type="TimeSpan" />
+ <property name="Sql_time" type="time" />
</class>
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/TimeAsTimeSpan.hbm.xml (from rev 4165, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/Time.hbm.xml)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/TimeAsTimeSpan.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/TimeAsTimeSpan.hbm.xml 2009-03-29 15:36:13 UTC (rev 4166)
@@ -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_TimeAsTimeSpan" type="TimeAsTimeSpan" />
+
+ </class>
+
+</hibernate-mapping>
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/TimeAsTimeSpanFixture.cs (from rev 4165, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/TimeFixture.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/TimeAsTimeSpanFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/TimeAsTimeSpanFixture.cs 2009-03-29 15:36:13 UTC (rev 4166)
@@ -0,0 +1,29 @@
+using System;
+using System.Collections;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.Dates
+{
+ [TestFixture]
+ public class TimeAsTimeSpanFixture : FixtureBase
+ {
+ protected override IList Mappings
+ {
+ get { return new[] {"NHSpecificTest.Dates.Mappings.TimeAsTimeSpan.hbm.xml"}; }
+ }
+
+ [Test]
+ public void SavingAndRetrievingTest()
+ {
+ TimeSpan now = DateTime.Parse("23:59:59").TimeOfDay;
+
+ SavingAndRetrievingAction(new AllDates { Sql_TimeAsTimeSpan = now },
+ entity =>
+ {
+ Assert.AreEqual(entity.Sql_TimeAsTimeSpan.Hours, now.Hours);
+ Assert.AreEqual(entity.Sql_TimeAsTimeSpan.Minutes, now.Minutes);
+ Assert.AreEqual(entity.Sql_TimeAsTimeSpan.Seconds, now.Seconds);
+ });
+ }
+ }
+}
\ No newline at end of file
Deleted: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/TimeFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/TimeFixture.cs 2009-03-29 06:27:12 UTC (rev 4165)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/TimeFixture.cs 2009-03-29 15:36:13 UTC (rev 4166)
@@ -1,33 +0,0 @@
-using System;
-using System.Collections;
-using NHibernate.Dialect;
-using NUnit.Framework;
-
-namespace NHibernate.Test.NHSpecificTest.Dates
-{
- [TestFixture]
- public class TimeFixture : FixtureBase
- {
- protected override IList Mappings
- {
- get { return new[] {"NHSpecificTest.Dates.Mappings.Time.hbm.xml"}; }
- }
-
- [Test]
- public void SavingAndRetrievingTest()
- {
- var now = DateTime.Parse("23:59:59").TimeOfDay;
-
- SavingAndRetrievingAction(new AllDates {Sql_time = now},
- entity =>
- {
- Assert.AreEqual(entity.Sql_time.Hours, now.Hours);
- Assert.AreEqual(entity.Sql_time.Minutes, now.Minutes);
- Assert.AreEqual(entity.Sql_time.Seconds, now.Seconds);
- });
-
- if(Dialect is MsSql2008Dialect)
- SavingAndRetrievingAction(new AllDates { Sql_time = now }, entity => Assert.AreEqual(entity.Sql_time, now));
- }
- }
-}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/TimeFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/TimeFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/TimeFixture.cs 2009-03-29 15:36:13 UTC (rev 4166)
@@ -0,0 +1,29 @@
+using System;
+using System.Collections;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.Dates
+{
+ [TestFixture]
+ public class TimeFixture : FixtureBase
+ {
+ protected override IList Mappings
+ {
+ get { return new[] {"NHSpecificTest.Dates.Mappings.Time.hbm.xml"}; }
+ }
+
+ [Test]
+ public void SavingAndRetrievingTest()
+ {
+ DateTime now = DateTime.Parse("23:59:59");
+
+ SavingAndRetrievingAction(new AllDates {Sql_time = now},
+ entity =>
+ {
+ Assert.AreEqual(entity.Sql_time.Hour, now.Hour);
+ Assert.AreEqual(entity.Sql_time.Minute, now.Minute);
+ Assert.AreEqual(entity.Sql_time.Second, now.Second);
+ });
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-03-29 06:27:12 UTC (rev 4165)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-03-29 15:36:13 UTC (rev 4166)
@@ -292,6 +292,7 @@
<Compile Include="GenericTest\SetGeneric\SetGenericFixture.cs" />
<Compile Include="HQL\Animal.cs" />
<Compile Include="HQL\BaseFunctionFixture.cs" />
+ <Compile Include="NHSpecificTest\Dates\TimeFixture.cs" />
<Compile Include="NHSpecificTest\DtcFailures\DtcFailuresFixture.cs" />
<Compile Include="NHSpecificTest\DtcFailures\Person.cs" />
<Compile Include="NHSpecificTest\NH1635\Fixture.cs" />
@@ -416,7 +417,7 @@
<Compile Include="NHSpecificTest\BasicTimeFixture.cs" />
<Compile Include="NHSpecificTest\BugTestCase.cs" />
<Compile Include="NHSpecificTest\CollectionFixture.cs" />
- <Compile Include="NHSpecificTest\Dates\TimeFixture.cs" />
+ <Compile Include="NHSpecificTest\Dates\TimeAsTimeSpanFixture.cs" />
<Compile Include="NHSpecificTest\Dates\DateFixture.cs" />
<Compile Include="NHSpecificTest\Dates\FixtureBase.cs" />
<Compile Include="NHSpecificTest\Dates\DateTime2Fixture.cs" />
@@ -1061,9 +1062,9 @@
<Compile Include="TypesTest\ByteTypeFixture.cs" />
<Compile Include="TypesTest\CurrencyClass.cs" />
<Compile Include="TypesTest\CurrencyTypeFixture.cs" />
+ <Compile Include="TypesTest\TimeAsTimeSpanClass.cs" />
+ <Compile Include="TypesTest\TimeAsTimeSpanTypeFixture.cs" />
<Compile Include="TypesTest\TimeSpanClass.cs" />
- <Compile Include="TypesTest\TimeSpanTypeFixture.cs" />
- <Compile Include="TypesTest\TimeSpanInt64Class.cs" />
<Compile Include="TypesTest\Decima2lTypeFixture.cs" />
<Compile Include="TypesTest\DateTimeTypeFixture.cs" />
<Compile Include="TypesTest\DecimalClass.cs" />
@@ -1092,7 +1093,7 @@
<Compile Include="TypesTest\StringClobTypeFixture.cs" />
<Compile Include="TypesTest\StringTypeFixture.cs" />
<Compile Include="TypesTest\TicksTypeFixture.cs" />
- <Compile Include="TypesTest\TimeSpanInt64TypeFixture.cs" />
+ <Compile Include="TypesTest\TimeSpanTypeFixture.cs" />
<Compile Include="TypesTest\TimestampTypeFixture.cs" />
<Compile Include="TypesTest\TypeFactoryFixture.cs" />
<Compile Include="TypesTest\TypeFixtureBase.cs" />
@@ -1707,6 +1708,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\Dates\Mappings\TimeAsTimeSpan.hbm.xml" />
<EmbeddedResource Include="TypesTest\CurrencyClass.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1635\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1688\Mappings.hbm.xml" />
@@ -1742,8 +1744,8 @@
<EmbeddedResource Include="Generatedkeys\ByTrigger\MyEntity.hbm.xml" />
<EmbeddedResource Include="Generatedkeys\Identity\MyEntityIdentity.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1289\Mappings.hbm.xml" />
+ <EmbeddedResource Include="TypesTest\TimeAsTimeSpanClass.hbm.xml" />
<EmbeddedResource Include="TypesTest\TimeSpanClass.hbm.xml" />
- <EmbeddedResource Include="TypesTest\TimeSpanInt64Class.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\FileStreamSql2008\Mappings.hbm.xml" />
<EmbeddedResource Include="Generatedkeys\Seqidentity\MyEntity.hbm.xml" />
<EmbeddedResource Include="IdGen\NativeGuid\NativeGuidPoid.hbm.xml" />
Copied: trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeAsTimeSpanClass.cs (from rev 4165, trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanClass.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeAsTimeSpanClass.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeAsTimeSpanClass.cs 2009-03-29 15:36:13 UTC (rev 4166)
@@ -0,0 +1,10 @@
+using System;
+
+namespace NHibernate.Test.TypesTest
+{
+ public class TimeAsTimeSpanClass
+ {
+ public int Id { get; set; }
+ public TimeSpan TimeSpanValue { get; set; }
+ }
+}
\ No newline at end of file
Copied: trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeAsTimeSpanClass.hbm.xml (from rev 4165, trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanClass.hbm.xml)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeAsTimeSpanClass.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeAsTimeSpanClass.hbm.xml 2009-03-29 15:36:13 UTC (rev 4166)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="false">
+
+ <class name="NHibernate.Test.TypesTest.TimeAsTimeSpanClass, NHibernate.Test">
+ <id name="Id">
+ <generator class="native" />
+ </id>
+ <property name="TimeSpanValue" type="TimeAsTimeSpan" />
+ </class>
+
+</hibernate-mapping>
Copied: trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeAsTimeSpanTypeFixture.cs (from rev 4165, trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanTypeFixture.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeAsTimeSpanTypeFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeAsTimeSpanTypeFixture.cs 2009-03-29 15:36:13 UTC (rev 4166)
@@ -0,0 +1,79 @@
+using System;
+using NHibernate.Type;
+using NUnit.Framework;
+
+namespace NHibernate.Test.TypesTest
+{
+ /// <summary>
+ /// Summary description for TimeAsTimeSpanTypeFixture.
+ /// </summary>
+ [TestFixture]
+ public class TimeAsTimeSpanTypeFixture
+ {
+ [Test]
+ public void Next()
+ {
+ var type = (TimeAsTimeSpanType) NHibernateUtil.TimeAsTimeSpan;
+ object current = new TimeSpan(DateTime.Now.Ticks - 5);
+ object next = type.Next(current, null);
+
+ Assert.IsTrue(next is TimeSpan, "Next should be TimeSpan");
+ Assert.IsTrue((TimeSpan) next > (TimeSpan) current,
+ "next should be greater than current (could be equal depending on how quickly this occurs)");
+ }
+
+ [Test]
+ public void Seed()
+ {
+ var type = (TimeAsTimeSpanType) NHibernateUtil.TimeAsTimeSpan;
+ Assert.IsTrue(type.Seed(null) is TimeSpan, "seed should be TimeSpan");
+ }
+ }
+
+ [TestFixture]
+ public class TimeSpanFixture2 : TypeFixtureBase
+ {
+ protected override string TypeName
+ {
+ get { return "TimeAsTimeSpan"; }
+ }
+
+ [Test]
+ public void SavingAndRetrieving()
+ {
+ var ticks = DateTime.Parse("23:59:59").TimeOfDay;
+
+ var entity = new TimeAsTimeSpanClass
+ {
+ TimeSpanValue = ticks
+ };
+
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ s.Save(entity);
+ tx.Commit();
+ }
+
+ TimeAsTimeSpanClass entityReturned;
+
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ entityReturned = s.CreateQuery("from TimeAsTimeSpanClass").UniqueResult<TimeAsTimeSpanClass>();
+
+ Assert.AreEqual(ticks, entityReturned.TimeSpanValue);
+ Assert.AreEqual(entityReturned.TimeSpanValue.Hours,ticks.Hours);
+ Assert.AreEqual(entityReturned.TimeSpanValue.Minutes, ticks.Minutes);
+ Assert.AreEqual(entityReturned.TimeSpanValue.Seconds, ticks.Seconds);
+ }
+
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ s.Delete(entityReturned);
+ tx.Commit();
+ }
+ }
+ }
+}
\ No newline at end of file
Deleted: trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanClass.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanClass.cs 2009-03-29 06:27:12 UTC (rev 4165)
+++ trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanClass.cs 2009-03-29 15:36:13 UTC (rev 4166)
@@ -1,10 +0,0 @@
-using System;
-
-namespace NHibernate.Test.TypesTest
-{
- public class TimeSpanClass
- {
- public int Id { get; set; }
- public TimeSpan TimeSpanValue { get; set; }
- }
-}
\ No newline at end of file
Copied: trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanClass.cs (from rev 4165, trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanInt64Class.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanClass.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanClass.cs 2009-03-29 15:36:13 UTC (rev 4166)
@@ -0,0 +1,10 @@
+using System;
+
+namespace NHibernate.Test.TypesTest
+{
+ public class TimeSpanClass
+ {
+ public int Id { get; set; }
+ public TimeSpan TimeSpanValue { get; set; }
+ }
+}
\ No newline at end of file
Deleted: trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanClass.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanClass.hbm.xml 2009-03-29 06:27:12 UTC (rev 4165)
+++ trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanClass.hbm.xml 2009-03-29 15:36:13 UTC (rev 4166)
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="false">
-
- <class name="NHibernate.Test.TypesTest.TimeSpanClass, NHibernate.Test">
- <id name="Id">
- <generator class="native" />
- </id>
- <property name="TimeSpanValue" type="TimeSpan" />
- </class>
-
-</hibernate-mapping>
Copied: trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanClass.hbm.xml (from rev 4165, trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanInt64Class.hbm.xml)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanClass.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanClass.hbm.xml 2009-03-29 15:36:13 UTC (rev 4166)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="false">
+
+ <class name="NHibernate.Test.TypesTest.TimeSpanClass, NHibernate.Test">
+ <id name="Id">
+ <generator class="native" />
+ </id>
+ <property name="TimeSpanValue" type="TimeSpan" />
+ </class>
+
+</hibernate-mapping>
Deleted: trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanInt64Class.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanInt64Class.cs 2009-03-29 06:27:12 UTC (rev 4165)
+++ trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanInt64Class.cs 2009-03-29 15:36:13 UTC (rev 4166)
@@ -1,10 +0,0 @@
-using System;
-
-namespace NHibernate.Test.TypesTest
-{
- public class TimeSpanInt64Class
- {
- public int Id { get; set; }
- public TimeSpan TimeSpanValue { get; set; }
- }
-}
\ No newline at end of file
Deleted: trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanInt64Class.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanInt64Class.hbm.xml 2009-03-29 06:27:12 UTC (rev 4165)
+++ trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanInt64Class.hbm.xml 2009-03-29 15:36:13 UTC (rev 4166)
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="false">
-
- <class name="NHibernate.Test.TypesTest.TimeSpanInt64Class, NHibernate.Test">
- <id name="Id">
- <generator class="native" />
- </id>
- <property name="TimeSpanValue" type="TimeSpanInt64" />
- </class>
-
-</hibernate-mapping>
Deleted: trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanInt64TypeFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanInt64TypeFixture.cs 2009-03-29 06:27:12 UTC (rev 4165)
+++ trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanInt64TypeFixture.cs 2009-03-29 15:36:13 UTC (rev 4166)
@@ -1,75 +0,0 @@
-using System;
-using NHibernate.Type;
-using NUnit.Framework;
-
-namespace NHibernate.Test.TypesTest
-{
- /// <summary>
- /// Summary description for TimeSpanTypeFixture.
- /// </summary>
- [TestFixture]
- public class TimeSpanInt64TypeFixture
- {
- [Test]
- public void Next()
- {
- var type = (TimeSpanInt64Type) NHibernateUtil.TimeSpanInt64;
- object current = new TimeSpan(DateTime.Now.Ticks - 5);
- object next = type.Next(current, null);
-
- Assert.IsTrue(next is TimeSpan, "Next should be TimeSpan");
- Assert.IsTrue((TimeSpan) next > (TimeSpan) current,
- "next should be greater than current (could be equal depending on how quickly this occurs)");
- }
-
- [Test]
- public void Seed()
- {
- var type = (TimeSpanInt64Type) NHibernateUtil.TimeSpanInt64;
- Assert.IsTrue(type.Seed(null) is TimeSpan, "seed should be TimeSpan");
- }
- }
-
- [TestFixture]
- public class TimeSpanInt64Fixture2 : TypeFixtureBase
- {
- protected override string TypeName
- {
- get { return "TimeSpanInt64"; }
- }
-
- [Test]
- public void SavingAndRetrieving()
- {
- var ticks = new TimeSpan(1982);
-
- var entity = new TimeSpanInt64Class
- {
- TimeSpanValue = ticks
- };
-
- using (ISession s = OpenSession())
- using (ITransaction tx = s.BeginTransaction())
- {
- s.Save(entity);
- tx.Commit();
- }
-
- TimeSpanInt64Class entityReturned;
-
- using (ISession s = OpenSession())
- using (ITransaction tx = s.BeginTransaction())
- {
- entityReturned = s.CreateQuery("from TimeSpanInt64Class").UniqueResult<TimeSpanInt64Class>();
- Assert.AreEqual(ticks, entityReturned.TimeSpanValue);
- }
-
- using (ISession s = OpenSession())
- using (ITransaction tx = s.BeginTransaction())
- {
- s.Delete(entityReturned);
- tx.Commit();
- }
- }
- }
-}
\ No newline at end of file
Deleted: trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanTypeFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanTypeFixture.cs 2009-03-29 06:27:12 UTC (rev 4165)
+++ trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanTypeFixture.cs 2009-03-29 15:36:13 UTC (rev 4166)
@@ -1,82 +0,0 @@
-using System;
-using NHibernate.Dialect;
-using NHibernate.Type;
-using NUnit.Framework;
-
-namespace NHibernate.Test.TypesTest
-{
- /// <summary>
- /// Summary description for TimeSpanTypeFixture.
- /// </summary>
- [TestFixture]
- public class TimeSpanTypeFixture
- {
- [Test]
- public void Next()
- {
- var type = (TimeSpanType) NHibernateUtil.TimeSpan;
- object current = new TimeSpan(DateTime.Now.Ticks - 5);
- object next = type.Next(current, null);
-
- Assert.IsTrue(next is TimeSpan, "Next should be TimeSpan");
- Assert.IsTrue((TimeSpan) next > (TimeSpan) current,
- "next should be greater than current (could be equal depending on how quickly this occurs)");
- }
-
- [Test]
- public void Seed()
- {
- var type = (TimeSpanType) NHibernateUtil.TimeSpan;
- Assert.IsTrue(type.Seed(null) is TimeSpan, "seed should be TimeSpan");
- }
- }
-
- [TestFixture]
- public class TimeSpanFixture2 : TypeFixtureBase
- {
- protected override string TypeName
- {
- get { return "TimeSpan"; }
- }
-
- [Test]
- public void SavingAndRetrieving()
- {
- var ticks = DateTime.Parse("23:59:59").TimeOfDay;
-
- var entity = new TimeSpanClass
- {
- TimeSpanValue = ticks
- };
-
- using (ISession s = OpenSession())
- using (ITransaction tx = s.BeginTransaction())
- {
- s.Save(entity);
- tx.Commit();
- }
-
- TimeSpanClass entityReturned;
-
- using (ISession s = OpenSession())
- using (ITransaction tx = s.BeginTransaction())
- {
- entityReturned = s.CreateQuery("from TimeSpanClass").UniqueResult<TimeSpanClass>();
-
- if(Dialect is MsSql2008Dialect)
- Assert.AreEqual(ticks, entityReturned.TimeSpanValue);
-
- Assert.AreEqual(entityReturned.TimeSpanValue.Hours,ticks.Hours);
- Assert.AreEqual(entityReturned.TimeSpanValue.Minutes, ticks.Minutes);
- Assert.AreEqual(entityReturned.TimeSpanValue.Seconds, ticks.Seconds);
- }
-
- using (ISession s = OpenSession())
- using (ITransaction tx = s.BeginTransaction())
- {
- s.Delete(entityReturned);
- tx.Commit();
- }
- }
- }
-}
\ No newline at end of file
Copied: trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanTypeFixture.cs (from rev 4165, trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanInt64TypeFixture.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanTypeFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/TypesTest/TimeSpanTypeFixture.cs 2009-03-29 15:36:13 UTC (rev 4166)
@@ -0,0 +1,75 @@
+using System;
+using NHibernate.Type;
+using NUnit.Framework;
+
+namespace NHibernate.Test.TypesTest
+{
+ /// <summary>
+ /// Summary description for TimeSpanTypeFixture.
+ /// </summary>
+ [TestFixture]
+ public class TimeSpanTypeFixture
+ {
+ [Test]
+ public void Next()
+ {
+ var type = (TimeSpanType) NHibernateUtil.TimeSpan;
+ object current = new TimeSpan(DateTime.Now.Ticks - 5);
+ object next = type.Next(current, null);
+
+ Assert.IsTrue(next is TimeSpan, "Next should be TimeSpan");
+ Assert.IsTrue((TimeSpan) next > (TimeSpan) current,
+ "next should be greater than current (could be equal depending on how quickly this occurs)");
+ }
+
+ [Test]
+ public void Seed()
+ {
+ var type = (TimeSpanType) NHibernateUtil.TimeSpan;
+ Assert.IsTrue(type.Seed(null) is TimeSpan, "seed should be TimeSpan");
+ }
+ }
+
+ [TestFixture]
+ public class TimeSpanTypeFixture2 : TypeFixtureBase
+ {
+ protected override string TypeName
+ {
+ get { return "TimeSpan"; }
+ }
+
+ [Test]
+ public void SavingAndRetrieving()
+ {
+ var ticks = new TimeSpan(1982);
+
+ var entity = new TimeSpanClass
+ {
+ TimeSpanValue = ticks
+ };
+
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ s.Save(entity);
+ tx.Commit();
+ }
+
+ TimeSpanClass entityReturned;
+
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ entityReturned = s.CreateQuery("from TimeSpanClass").UniqueResult<TimeSpanClass>();
+ Assert.AreEqual(ticks, entityReturned.TimeSpanValue);
+ }
+
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ s.Delete(entityReturned);
+ tx.Commit();
+ }
+ }
+ }
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|