Beispiel #1
0
        public void WhenNotEqualTicksThenShouldNotMatchIsEqual()
        {
            var type = new DateTimeOffsetType();
            var now  = DateTimeOffset.Now;

            Assert.That(type.IsEqual(new DateTimeOffset(now.Ticks - 1, now.Offset), new DateTimeOffset(now.Ticks, now.Offset)), Is.False);
        }
Beispiel #2
0
        public void SavingAndRetrievingTest()
        {
            var NowOS = DateTimeOffsetType.Round(DateTimeOffset.Now, DateAccuracyInTicks);

            AllDates dates = new AllDates {
                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>();
                    Assert.That(datesRecovered.Sql_datetimeoffset, Is.EqualTo(NowOS));
                }

            using (ISession s = OpenSession())
                using (ITransaction tx = s.BeginTransaction())
                {
                    var datesRecovered = s.CreateQuery("from AllDates").UniqueResult <AllDates>();
                    s.Delete(datesRecovered);
                    tx.Commit();
                }
        }
Beispiel #3
0
        public void WhenNotEqualTicksThenShouldNotMatchIsEqual()
        {
            var type = new DateTimeOffsetType();
            var now  = DateTimeOffset.Now;

            type.IsEqual(new DateTimeOffset(now.Ticks - 1, now.Offset), new DateTimeOffset(now.Ticks, now.Offset)).Should().Be.False();
        }
Beispiel #4
0
        public void HashCodeShouldHaveSameBehaviorOfNetType()
        {
            var type       = new DateTimeOffsetType();
            var now        = DateTimeOffset.Now;
            var exactClone = new DateTimeOffset(now.Ticks, now.Offset);

            Assert.That((now.GetHashCode() == exactClone.GetHashCode()), Is.EqualTo(now.GetHashCode() == type.GetHashCode(exactClone)));
        }
Beispiel #5
0
        public void HashCodeShouldHaveSameBehaviorOfNetType()
        {
            var type       = new DateTimeOffsetType();
            var now        = DateTimeOffset.Now;
            var exactClone = new DateTimeOffset(now.Ticks, now.Offset);

            (now.GetHashCode() == exactClone.GetHashCode()).Should().Be.EqualTo(now.GetHashCode() == type.GetHashCode(exactClone, EntityMode.Poco));
        }
Beispiel #6
0
        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));
            }
        }
Beispiel #7
0
 public void AssertEquals(ManyDataTypesPoco actualRow)
 {
     Assert.AreEqual(StringType, actualRow.StringType);
     Assert.AreEqual(GuidType, actualRow.GuidType);
     Assert.AreEqual(DateTimeType.ToString(), actualRow.DateTimeType.ToString()); // 'ToString' rounds to the nearest second
     Assert.AreEqual(DateTimeOffsetType.ToString(), actualRow.DateTimeOffsetType.ToString());
     Assert.AreEqual(BooleanType, actualRow.BooleanType);
     Assert.AreEqual(DecimalType, actualRow.DecimalType);
     Assert.AreEqual(DoubleType, actualRow.DoubleType);
     Assert.AreEqual(FloatType, actualRow.FloatType);
     Assert.AreEqual(IntType, actualRow.IntType);
     Assert.AreEqual(Int64Type, actualRow.Int64Type);
     Assert.AreEqual(TimeUuidType, actualRow.TimeUuidType);
     Assert.AreEqual(NullableTimeUuidType, actualRow.NullableTimeUuidType);
     Assert.AreEqual(DictionaryStringLongType, actualRow.DictionaryStringLongType);
     Assert.AreEqual(DictionaryStringStringType, actualRow.DictionaryStringStringType);
     Assert.AreEqual(ListOfGuidsType, actualRow.ListOfGuidsType);
     Assert.AreEqual(ListOfStringsType, actualRow.ListOfStringsType);
 }
 protected virtual DateTimeOffset GetTestDate()
 {
     return(DateTimeOffsetType.Round(Now, DateAccuracyInTicks)
            // Take another date than now for checking the value do not get overridden by seeding.
            .AddDays(1));
 }