public void Test_ZonedDateTime() { CreateTable("timestamptz"); var subject = new PostgreSQLCopyHelper <NullableNodaTypesEntity>("sample", "noda_time_test") .MapTimeStampTz("col_noda", x => x.ZonedDateTime); var entity = new NullableNodaTypesEntity { ZonedDateTime = null }; var entities = new[] { entity }; subject.SaveAll(connection, entities); // Check what's written to DB: var rows = GetAll(); // TODO: How does Postgres <-> NodaTime convert Timezones? There is a good test here, but // I couldn't see through it yet: // // https://github.com/npgsql/npgsql/blob/766658172f08abb0b87a6b7f01a7ea4b49952a29/test/Npgsql.PluginTests/NodaTimeTests.cs // var actual = (Instant)rows[0][0]; Assert.AreEqual(entity.ZonedDateTime, actual); }
public void Test_LocalDateTime() { CreateTable("timestamp"); var subject = new PostgreSQLCopyHelper <NullableNodaTypesEntity>("sample", "noda_time_test") .MapTimeStamp("col_noda", x => x.LocalDateTime); var entity = new NullableNodaTypesEntity { LocalDateTime = null }; var entities = new[] { entity }; subject.SaveAll(connection, entities); // Check what's written to DB: var rows = GetAll(); var actual = (Instant)rows[0][0]; var expected = entity.LocalDateTime; Assert.AreEqual(expected, actual); }
public void Test_OffsetTime() { CreateTable("timetz"); var subject = new PostgreSQLCopyHelper <NullableNodaTypesEntity>("sample", "noda_time_test") .MapTimeTz("col_noda", x => x.OffsetTime); var entity = new NullableNodaTypesEntity { OffsetTime = null }; var entities = new[] { entity }; subject.SaveAll(connection, entities); // Check what's written to DB: var rows = GetAll(); var actual = (OffsetTime)rows[0][0]; Assert.AreEqual(entity.OffsetTime, actual); }