|
1 | 1 | using EntityFrameworkCore.Ydb.FunctionalTests.TestUtilities; |
2 | | -using EntityFrameworkCore.Ydb.Extensions; |
3 | 2 | using Microsoft.EntityFrameworkCore; |
4 | | -using Microsoft.EntityFrameworkCore.Diagnostics; |
5 | 3 | using Microsoft.EntityFrameworkCore.TestUtilities; |
6 | 4 |
|
7 | 5 | namespace EntityFrameworkCore.Ydb.FunctionalTests.Query; |
8 | 6 |
|
9 | | -public class DecimalParameterQueryYdbFixture |
10 | | - : SharedStoreFixtureBase<DecimalParameterQueryYdbFixture.DecimalContext> |
| 7 | +public class DecimalParameterQueryYdbFixture : SharedStoreFixtureBase<DecimalParameterQueryYdbFixture.TestContext> |
11 | 8 | { |
12 | | - private static DbCommandInterceptor? CurrentInterceptor => null; |
| 9 | + protected override string StoreName => "DecimalParameterTest"; |
13 | 10 |
|
14 | | - protected override string StoreName => "DecimalParameter"; |
15 | 11 | protected override ITestStoreFactory TestStoreFactory => YdbTestStoreFactory.Instance; |
16 | 12 |
|
17 | | - public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) |
| 13 | + public class TestContext : DbContext |
18 | 14 | { |
19 | | - var b = base.AddOptions(builder); |
20 | | - b.UseYdb(GetConnString()); |
21 | | - if (CurrentInterceptor is not null) |
22 | | - b.AddInterceptors(CurrentInterceptor); |
23 | | - return b; |
24 | | - } |
25 | | - |
26 | | - protected override void OnModelCreating(ModelBuilder b, DbContext ctx) |
27 | | - { |
28 | | - b.Entity<ItemDefault>(e => e.HasKey(x => x.Id)); |
29 | | - |
30 | | - b.Entity<ItemExplicit>(e => |
| 15 | + public TestContext(DbContextOptions options) : base(options) |
31 | 16 | { |
32 | | - e.HasKey(x => x.Id); |
33 | | - e.Property(x => x.Price).HasPrecision(22, 9); |
34 | | - }); |
35 | | - } |
| 17 | + } |
36 | 18 |
|
37 | | - private static string GetConnString() |
38 | | - { |
39 | | - var cs = Environment.GetEnvironmentVariable("YDB_EF_CONN"); |
40 | | - if (!string.IsNullOrWhiteSpace(cs)) return cs; |
| 19 | + public DbSet<ItemDefault> ItemsDefault => Set<ItemDefault>(); |
| 20 | + public DbSet<ItemExplicit> ItemsExplicit => Set<ItemExplicit>(); |
41 | 21 |
|
42 | | - var endpoint = Environment.GetEnvironmentVariable("YDB_ENDPOINT") ?? "grpc://localhost:2136"; |
43 | | - var database = Environment.GetEnvironmentVariable("YDB_DATABASE") ?? "/ef-tests"; |
44 | | - return $"{endpoint};database={database}"; |
| 22 | + protected override void OnModelCreating(ModelBuilder modelBuilder) |
| 23 | + { |
| 24 | + modelBuilder.Entity<ItemDefault>(b => |
| 25 | + { |
| 26 | + b.HasKey(x => x.Id); |
| 27 | + b.Property(x => x.Price); |
| 28 | + }); |
| 29 | + |
| 30 | + modelBuilder.Entity<ItemExplicit>(b => |
| 31 | + { |
| 32 | + b.HasKey(x => x.Id); |
| 33 | + b.Property(x => x.Price).HasPrecision(22, 9); |
| 34 | + }); |
| 35 | + } |
45 | 36 | } |
46 | | - |
47 | | - public class DecimalContext(DbContextOptions options) : DbContext(options); |
48 | 37 | } |
49 | 38 |
|
50 | 39 | public class ItemDefault |
51 | 40 | { |
52 | | - public int Id { get; init; } |
53 | | - public decimal Price { get; init; } |
| 41 | + public int Id { get; set; } |
| 42 | + public decimal Price { get; set; } |
54 | 43 | } |
55 | 44 |
|
56 | 45 | public class ItemExplicit |
57 | 46 | { |
58 | | - public int Id { get; init; } |
59 | | - public decimal Price { get; init; } |
| 47 | + public int Id { get; set; } |
| 48 | + public decimal Price { get; set; } |
60 | 49 | } |
0 commit comments