示例#1
0
        public void Roundtrip()
        {
            AssertExtensions.WithCulture("de-DE", () =>
            {
                _storage.EnterFluidMode();
                var checker = new RoundtripChecker(_db, _storage);

                // native SQLite types
                checker.Check(null, null);
                checker.Check("hello", "hello");
                checker.Check(123L, 123L);
                checker.Check(3.14, 3.14);
                checker.Check(SharedChecks.SAMPLE_BLOB, SharedChecks.SAMPLE_BLOB);

                // extremal vaues
                SharedChecks.CheckRoundtripOfExtremalValues(checker);

                // conversion to string
                checker.Check(SharedChecks.SAMPLE_DATETIME, "1984-06-14 11:22:33");
                SharedChecks.CheckBigNumberRoundtripForcesString(checker);

                // Guid
#if SQLITE_MODE_GENUINE
                checker.Check(SharedChecks.SAMPLE_GUID, SharedChecks.SAMPLE_GUID.ToByteArray());
#else
                checker.Check(SharedChecks.SAMPLE_GUID, SharedChecks.SAMPLE_GUID.ToString().ToUpper());
#endif
                // upscale to long
                checker.Check(0, 0L);
                checker.Check(1, 1L);
                checker.Check(true, 1L);
                checker.Check(false, 0L);
                checker.Check(DayOfWeek.Thursday, 4L);
            });
        }
        public void Roundtrip()
        {
            AssertExtensions.WithCulture("de-DE", () =>
            {
                _storage.EnterFluidMode();
                var checker = new RoundtripChecker(_db, _storage);

                // supported ranks
                checker.Check(null, null);
                checker.Check((sbyte)123, (sbyte)123);
                checker.Check(1000, 1000);
                checker.Check(0x80000000L, 0x80000000L);
                checker.Check(3.14, 3.14);
                checker.Check("hello", "hello");
                checker.Check(SharedChecks.SAMPLE_DATETIME, SharedChecks.SAMPLE_DATETIME);
                checker.Check(SharedChecks.SAMPLE_BLOB, SharedChecks.SAMPLE_BLOB);

                // extremal vaues
                SharedChecks.CheckRoundtripOfExtremalValues(checker, checkDateTime: true);

                // conversion to string
                SharedChecks.CheckBigNumberRoundtripForcesString(checker);
                checker.Check(SharedChecks.SAMPLE_GUID, SharedChecks.SAMPLE_GUID.ToString());

                // bool
                checker.Check(true, (sbyte)1);
                checker.Check(false, (sbyte)0);

                // enum
                checker.Check(DayOfWeek.Thursday, (sbyte)4);
            });
        }
示例#3
0
        public void Roundtrip()
        {
            AssertExtensions.WithCulture("de-DE", () =>
            {
                _storage.EnterFluidMode();
                var checker = new RoundtripChecker(_db, _storage);

                // supported ranks
                checker.Check(null, null);
                checker.Check(true, true);
                checker.Check(1000, 1000);
                checker.Check(0x80000000L, 0x80000000L);
                checker.Check(3.14, 3.14);
                checker.Check(7.90M, 7.90M);
                checker.Check("hello", "hello");
                checker.Check(SharedChecks.SAMPLE_DATETIME, SharedChecks.SAMPLE_DATETIME);
                checker.Check(SharedChecks.SAMPLE_GUID, SharedChecks.SAMPLE_GUID);
                checker.Check(SharedChecks.SAMPLE_BLOB, SharedChecks.SAMPLE_BLOB);

                // https://github.com/npgsql/npgsql/issues/11
                checker.Check(
                    SharedChecks.SAMPLE_DATETIME_OFFSET,
                    SharedChecks.SAMPLE_DATETIME_OFFSET.ToLocalTime().DateTime
                    );

                // extremal vaues
                SharedChecks.CheckRoundtripOfExtremalValues(checker, checkDecimal: true, checkDateTime: true);
                checker.Check(UInt64.MaxValue, (decimal)UInt64.MaxValue);

                // enum
                checker.Check(DayOfWeek.Thursday, (int)4);
            });
        }
示例#4
0
        public static void CheckRoundtripOfExtremalValues(RoundtripChecker checker, bool checkDecimal = false, bool checkDateTime = false, bool checkDateTimeOffset = false)
        {
            checker.Check(Int64.MinValue, Int64.MinValue);
            checker.Check(Int64.MaxValue, Int64.MaxValue);
            checker.Check(Double.Epsilon, Double.Epsilon);
            checker.Check(Double.MinValue, Double.MinValue);
            checker.Check(Double.MaxValue, Double.MaxValue);

            if (checkDecimal)
            {
                checker.Check(Decimal.MinValue, decimal.MinValue);
                checker.Check(Decimal.MaxValue, decimal.MaxValue);
            }

            if (checkDateTime)
            {
                checker.Check(DateTime.MinValue, DateTime.MinValue);
                checker.Check(DateTime.MaxValue.Date, DateTime.MaxValue.Date);
            }

            if (checkDateTimeOffset)
            {
                checker.Check(DateTimeOffset.MinValue, DateTimeOffset.MinValue);
                checker.Check(DateTimeOffset.MaxValue.Date, DateTimeOffset.MaxValue.Date);
            }

            var text = String.Empty.PadRight(84 * 1000, 'x');

            checker.Check(text, text);
        }
示例#5
0
        public void StringRelaxations()
        {
            _storage.EnterFluidMode();
            var checker = new RoundtripChecker(_db, _storage);

            checker.Check("", null);
            checker.Check(" \t", null);

            _storage.ConvertEmptyStringToNull = false;
            checker.Check(" \t", "");

            _storage.TrimStrings = false;
            checker.Check(" \t", " \t");
        }
示例#6
0
        public void Roundtrip()
        {
            AssertExtensions.WithCulture("de-DE", () =>
            {
                _storage.EnterFluidMode();
                var checker = new RoundtripChecker(_db, _storage);

                // similar to https://github.com/StackExchange/dapper-dot-net/issues/229
                _db.QueryExecuting += cmd => {
                    foreach (SqlParameter p in cmd.Parameters)
                    {
                        if (Equals(p.Value, DateTime.MinValue))
                        {
                            p.SqlDbType = SqlDbType.DateTime2;
                        }
                    }
                };

                // supported ranks
                checker.Check(null, null);
                checker.Check(255, (byte)255);
                checker.Check(1000, 1000);
                checker.Check(0x80000000L, 0x80000000L);
                checker.Check(3.14, 3.14);
                checker.Check("hello", "hello");
                checker.Check(SharedChecks.SAMPLE_DATETIME, SharedChecks.SAMPLE_DATETIME);
                checker.Check(SharedChecks.SAMPLE_DATETIME_OFFSET, SharedChecks.SAMPLE_DATETIME_OFFSET);
                checker.Check(SharedChecks.SAMPLE_GUID, SharedChecks.SAMPLE_GUID);
                checker.Check(SharedChecks.SAMPLE_BLOB, SharedChecks.SAMPLE_BLOB);

                // extremal vaues
                SharedChecks.CheckRoundtripOfExtremalValues(checker, checkDateTime: true, checkDateTimeOffset: true);

                // conversion to string
                SharedChecks.CheckBigNumberRoundtripForcesString(checker);

                // bool
                checker.Check(true, (byte)1);
                checker.Check(false, (byte)0);

                // enum
                checker.Check(DayOfWeek.Thursday, (byte)4);
            });
        }
示例#7
0
        public void RegognizeIntegers()
        {
            _storage.EnterFluidMode();
            var checker = new RoundtripChecker(_db, _storage);

            checker.Check(123.0, 123L);
            checker.Check(123M, 123L);
            checker.Check(" 123 ", 123L);

            checker.Check("-0", "-0");
            checker.Check("+0", "+0");
            checker.Check("+1", "+1");
            checker.Check("00", "00");
            checker.Check("0123", "0123");
            checker.Check("0x123", "0x123");
            checker.Check(-1.0M, "-1.0");
            checker.Check("3.0e+5", "3.0e+5");

            _storage.TrimStrings = false;
            checker.Check(" 123 ", " 123 ");

            _storage.RecognizeIntegers = false;
            checker.Check("123", "123");
        }
示例#8
0
 public static void CheckBigNumberRoundtripForcesString(RoundtripChecker checker)
 {
     checker.Check(9223372036854775808, "9223372036854775808");
     checker.Check(9223372036854775808M, "9223372036854775808");
 }