forked from npgsql/efcore.pg
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayQueryFixture.cs
More file actions
81 lines (68 loc) · 3.68 KB
/
ArrayQueryFixture.cs
File metadata and controls
81 lines (68 loc) · 3.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using Microsoft.EntityFrameworkCore.TestModels.Array;
namespace Microsoft.EntityFrameworkCore.Query;
public abstract class ArrayQueryFixture : QueryFixtureBase<ArrayQueryContext>, ITestSqlLoggerFactory
{
protected override ITestStoreFactory TestStoreFactory
=> NpgsqlTestStoreFactory.Instance;
public TestSqlLoggerFactory TestSqlLoggerFactory
=> (TestSqlLoggerFactory)ListLoggerFactory;
private ArrayQueryData? _expectedData;
public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder)
=> base.AddOptions(builder).ConfigureWarnings(wcb => wcb.Ignore(CoreEventId.CollectionWithoutComparer));
protected override Task SeedAsync(ArrayQueryContext context)
=> ArrayQueryContext.SeedAsync(context);
public override ISetSource GetExpectedData()
=> _expectedData ??= new ArrayQueryData();
public override IReadOnlyDictionary<Type, object> EntitySorters
=> new Dictionary<Type, Func<object, object?>>
{
{ typeof(ArrayEntity), e => ((ArrayEntity)e).Id }, { typeof(ArrayContainerEntity), e => ((ArrayContainerEntity)e)?.Id }
}.ToDictionary(e => e.Key, e => (object)e.Value);
public override IReadOnlyDictionary<Type, object> EntityAsserters
=> new Dictionary<Type, Action<object, object>>
{
{
typeof(ArrayEntity), (e, a) =>
{
Assert.Equal(e is null, a is null);
if (e is not null && a is not null)
{
var ee = (ArrayEntity)e;
var aa = (ArrayEntity)a;
Assert.Equal(ee.Id, aa.Id);
Assert.Equal(ee.IntArray, ee.IntArray);
Assert.Equal(ee.IntList, ee.IntList);
Assert.Equal(ee.NullableIntArray, ee.NullableIntArray);
Assert.Equal(ee.Bytea, ee.Bytea);
Assert.Equal(ee.ByteArray, ee.ByteArray);
Assert.Equal(ee.StringArray, ee.StringArray);
Assert.Equal(ee.StringList, ee.StringList);
Assert.Equal(ee.NullableStringArray, ee.NullableStringArray);
Assert.Equal(ee.NullableStringList, ee.NullableStringList);
Assert.Equal(ee.NullableText, ee.NullableText);
Assert.Equal(ee.NonNullableText, ee.NonNullableText);
Assert.Equal(ee.EnumConvertedToInt, ee.EnumConvertedToInt);
Assert.Equal(ee.ArrayOfStringConvertedToDelimitedString, ee.ArrayOfStringConvertedToDelimitedString);
Assert.Equal(ee.ListOfStringConvertedToDelimitedString, ee.ListOfStringConvertedToDelimitedString);
Assert.Equal(ee.ValueConvertedArrayOfEnum, ee.ValueConvertedArrayOfEnum);
Assert.Equal(ee.ValueConvertedListOfEnum, ee.ValueConvertedListOfEnum);
Assert.Equal(ee.IList, ee.IList);
Assert.Equal(ee.Byte, ee.Byte);
}
}
},
{
typeof(ArrayContainerEntity), (e, a) =>
{
Assert.Equal(e is null, a is null);
if (e is not null && a is not null)
{
var ee = (ArrayContainerEntity)e;
var aa = (ArrayContainerEntity)a;
Assert.Equal(ee.Id, aa.Id);
Assert.Equal(ee.ArrayEntities, ee.ArrayEntities);
}
}
}
}.ToDictionary(e => e.Key, e => (object)e.Value);
}