提交 65d1542b 编写于 作者: S Shay Rojansky

hstore tests

Related to #25
上级 3f115b44
......@@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Reflection;
......@@ -25,6 +26,11 @@ public BuiltInDataTypesNpgsqlFixture()
{
_testStore = NpgsqlTestStore.CreateScratch();
// TODO: find a better way to do this
_testStore.ExecuteNonQuery("CREATE EXTENSION hstore");
var npgsqlConn = (NpgsqlConnection)_testStore.Connection;
npgsqlConn.ReloadTypes();
/*
_testStore.ExecuteNonQuery("CREATE TYPE some_composite AS (some_number int, some_text text)");
var npgsqlConn = (NpgsqlConnection)_testStore.Connection;
......@@ -197,6 +203,7 @@ public class MappedDataTypes
public PhysicalAddress Macaddr { get; set; }
public NpgsqlPoint Point { get; set; }
public string Jsonb { get; set; }
public Dictionary<string, string> Hstore { get; set; }
// Composite
//public SomeComposite SomeComposite { get; set; }
......@@ -274,6 +281,7 @@ public class MappedNullableDataTypes
public PhysicalAddress Macaddr { get; set; }
public NpgsqlPoint? Point { get; set; }
public string Jsonb { get; set; }
public Dictionary<string, string> Hstore { get; set; }
// Composite
//public SomeComposite SomeComposite { get; set; }
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using Microsoft.EntityFrameworkCore.Specification.Tests;
......@@ -47,6 +48,7 @@ public virtual void Can_query_using_any_mapped_data_type()
Macaddr = PhysicalAddress.Parse("08-00-2B-01-02-03"),
Point = new NpgsqlPoint(5.2, 3.3),
Jsonb = @"{""a"": ""b""}",
Hstore = new Dictionary<string, string> { {"a", "b"} },
//SomeComposite = new SomeComposite { SomeNumber = 8, SomeText = "foo" }
});
......@@ -120,7 +122,11 @@ public virtual void Can_query_using_any_mapped_data_type()
//var param20 = @"{""a"": ""b""}";
//Assert.Same(entity, context.Set<MappedNullableDataTypes>().Single(e => e.Int == 999 && e.Jsonb == param20));
//SomeComposite param21 = new SomeComposite { SomeNumber = 8, SomeText = "foo" };
// The following fails because of https://github.com/aspnet/EntityFramework/issues/5365
// var param21 = new Dictionary<string, string> { { "a", "b" } };
// Assert.Same(entity, context.Set<MappedNullableDataTypes>().Single(e => e.Int == 999 && e.Hstore == param21));
//SomeComposite param22 = new SomeComposite { SomeNumber = 8, SomeText = "foo" };
//Assert.Same(entity, context.Set<MappedNullableDataTypes>().Single(e => e.Int == 999 && e.SomeComposite.Equals(param20)));
}
}
......@@ -203,7 +209,10 @@ public virtual void Can_query_using_any_mapped_data_types_with_nulls()
string param20 = null;
Assert.Same(entity, context.Set<MappedNullableDataTypes>().Single(e => e.Int == 911 && e.Jsonb == param20));
//SomeComposite param21 = null;
Dictionary<string, string> param21 = null;
Assert.Same(entity, context.Set<MappedNullableDataTypes>().Single(e => e.Int == 911 && e.Hstore == param21));
//SomeComposite param22 = null;
//Assert.Same(entity, context.Set<MappedNullableDataTypes>().Single(e => e.Int == 911 && e.SomeComposite == param20));
}
}
......@@ -241,9 +250,10 @@ public virtual void Can_insert_and_read_back_all_mapped_data_types()
Macaddr = PhysicalAddress.Parse("08-00-2B-01-02-03"),
Point = new NpgsqlPoint(5.2, 3.3),
Jsonb = @"{""a"": ""b""}",
Hstore = new Dictionary<string, string> { { "a", "b" } },
//SomeComposite = new SomeComposite { SomeNumber = 8, SomeText = "foo" }
});
//SomeComposite = new SomeComposite { SomeNumber = 8, SomeText = "foo" }
});
Assert.Equal(1, context.SaveChanges());
}
......@@ -277,6 +287,7 @@ public virtual void Can_insert_and_read_back_all_mapped_data_types()
Assert.Equal(PhysicalAddress.Parse("08-00-2B-01-02-03"), entity.Macaddr);
Assert.Equal(new NpgsqlPoint(5.2, 3.3), entity.Point);
Assert.Equal(@"{""a"": ""b""}", entity.Jsonb);
Assert.Equal(new Dictionary<string, string> { { "a", "b" } }, entity.Hstore);
//Assert.Equal(new SomeComposite { SomeNumber = 8, SomeText = "foo" }, entity.SomeComposite);
}
......@@ -315,6 +326,7 @@ public virtual void Can_insert_and_read_back_all_mapped_nullable_data_types()
Macaddr = PhysicalAddress.Parse("08-00-2B-01-02-03"),
Point = new NpgsqlPoint(5.2, 3.3),
Jsonb = @"{""a"": ""b""}",
Hstore = new Dictionary<string, string> { { "a", "b" } },
//SomeComposite = new SomeComposite { SomeNumber = 8, SomeText = "foo" }
});
......@@ -351,6 +363,7 @@ public virtual void Can_insert_and_read_back_all_mapped_nullable_data_types()
Assert.Equal(PhysicalAddress.Parse("08-00-2B-01-02-03"), entity.Macaddr);
Assert.Equal(new NpgsqlPoint(5.2, 3.3), entity.Point);
Assert.Equal(@"{""a"": ""b""}", entity.Jsonb);
Assert.Equal(new Dictionary<string, string> { { "a", "b" } }, entity.Hstore);
//Assert.Equal(new SomeComposite { SomeNumber = 8, SomeText = "foo" }, entity.SomeComposite);
}
......@@ -398,6 +411,7 @@ public virtual void Can_insert_and_read_back_all_mapped_data_types_set_to_null()
Assert.Null(entity.Macaddr);
Assert.Null(entity.Point);
Assert.Null(entity.Jsonb);
Assert.Null(entity.Hstore);
//Assert.Null(entity.SomeComposite);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册