public void Does_save_PgSqlData()
        {
            OrmLiteUtils.PrintSql();

            using (var db = OpenDbConnection())
            {
                db.DropAndCreateTable <PgsqlData>();
                long UnixEpoch = 621355968000000000L;
                var  dateTimes = new DateTime[] {
                    new DateTime(UnixEpoch, DateTimeKind.Utc),
                    new DateTime(2001, 01, 01, 1, 1, 1, 1, DateTimeKind.Utc),
                };
                var dateTimeOffsets = dateTimes.Select(x => new DateTimeOffset(x, TimeSpan.Zero)).ToArray();

                var data = new PgsqlData
                {
                    Id              = Guid.NewGuid(),
                    Ints            = new[] { 2, 4, 1 },
                    Longs           = new long[] { 2, 4, 1 },
                    Floats          = new float[] { 2, 4, 1 },
                    Doubles         = new double[] { 2, 4, 1 },
                    Strings         = new[] { "test string 1", "test string 2" },
                    Decimals        = new decimal[] { 2, 4, 1 },
                    DateTimes       = dateTimes,
                    DateTimeOffsets = dateTimeOffsets,

                    ListInts = new[] { 2, 4, 1 }.ToList(),
                    ListLongs = new long[] { 2, 4, 1 }.ToList(),
                    ListFloats = new float[] { 2, 4, 1 }.ToList(),
                    ListDoubles = new double[] { 2, 4, 1 }.ToList(),
                    ListStrings = new[] { "test string 1", "test string 2" }.ToList(),
                    ListDecimals = new decimal[] { 2, 4, 1 }.ToList(),
                    ListDateTimes       = dateTimes.ToList(),
                    ListDateTimeOffsets = dateTimeOffsets.ToList(),
                };

                db.Save(data);

                var row = db.Select <PgsqlData>()[0];
                Assert.That(row.Ints.EquivalentTo(data.Ints));
                Assert.That(row.Longs.EquivalentTo(data.Longs));
                Assert.That(row.Floats.EquivalentTo(data.Floats));
                Assert.That(row.Doubles.EquivalentTo(data.Doubles));
                Assert.That(row.Decimals.EquivalentTo(data.Decimals));
                Assert.That(row.ListInts.EquivalentTo(data.ListInts));
                Assert.That(row.ListLongs.EquivalentTo(data.ListLongs));
                Assert.That(row.ListFloats.EquivalentTo(data.ListFloats));
                Assert.That(row.ListDoubles.EquivalentTo(data.ListDoubles));
                Assert.That(row.ListDecimals.EquivalentTo(data.ListDecimals));
                Assert.That(row.Strings.EquivalentTo(data.Strings));
                Assert.That(row.ListStrings.EquivalentTo(data.ListStrings));
            }

            OrmLiteUtils.UnPrintSql();
        }
Beispiel #2
0
        public void Does_save_PgSqlData()
        {
            using (var db = OpenDbConnection())
            {
                db.DropAndCreateTable <PgsqlData>();

                var data = new PgsqlData
                {
                    Id      = Guid.NewGuid(),
                    Ints    = new[] { 2, 4, 1 },
                    Strings = new[] { "test string 1", "test string 2" }
                };

                db.Save(data);

                var row = db.Select <PgsqlData>()[0];
                Assert.That(row.Ints.EquivalentTo(data.Ints));
                Assert.That(row.Strings.EquivalentTo(data.Strings));
            }
        }