Permalink
Browse files

Add copy test for enum

  • Loading branch information...
roji committed Oct 8, 2017
1 parent a9837a6 commit cfed294511b89c6bc40f8147f07ac702fa315414
Showing with 30 additions and 0 deletions.
  1. +30 −0 test/Npgsql.Tests/CopyTests.cs
@@ -457,6 +457,36 @@ public void Array()
}
}
[Test]
public void Enum()
{
var expected = Mood.Happy;
using (var conn = OpenConnection())
{
conn.ExecuteNonQuery("CREATE TYPE pg_temp.mood AS ENUM ('sad', 'ok', 'happy')");
conn.ReloadTypes();
conn.TypeMapper.MapEnum<Mood>();
conn.ExecuteNonQuery("CREATE TEMP TABLE data (mymood mood)");
using (var writer = conn.BeginBinaryImport("COPY data (mymood) FROM STDIN BINARY"))
{
writer.StartRow();
writer.Write(expected);
writer.Commit();
}
using (var reader = conn.BeginBinaryExport("COPY data (mymood) TO STDIN BINARY"))
{
reader.StartRow();
Assert.That(reader.Read<Mood>(), Is.EqualTo(expected));
}
}
}
enum Mood { Sad, Ok, Happy };
[Test, IssueLink("https://github.com/npgsql/npgsql/issues/1440")]
public void ErrorDuringImport()
{

0 comments on commit cfed294

Please sign in to comment.