@@ -15,64 +15,41 @@ public class DecimalParameterYdbTest(DecimalParameterQueryYdbFixture fixture)
1515 public async Task Parameter_decimal_uses_default_22_9_and_roundtrips ( )
1616 {
1717 await using var ctx = Fixture . CreateContext ( ) ;
18- try
19- {
20- await ctx . Database . EnsureCreatedAsync ( ) ;
18+ await ctx . Database . EnsureCreatedAsync ( ) ;
2119
22- var v = 1.23456789m ;
23- ctx . Add ( new ItemDefault { Price = v } ) ;
24- await ctx . SaveChangesAsync ( ) ;
20+ var v = 1.23456789m ;
21+ ctx . Add ( new ItemDefault { Price = v } ) ;
22+ await ctx . SaveChangesAsync ( ) ;
2523
26- var got = await ctx . Set < ItemDefault > ( ) . Where ( x => x . Price == v ) . ToListAsync ( ) ;
27- Assert . Single ( got ) ;
28- Assert . Equal ( v , got [ 0 ] . Price ) ;
29- }
30- finally
31- {
32- await ctx . Database . CloseConnectionAsync ( ) ;
33- }
24+ var got = await ctx . Set < ItemDefault > ( ) . SingleAsync ( x => x . Price == v ) ;
25+ Assert . Equal ( v , got . Price ) ;
3426 }
3527
3628 [ ConditionalFact ]
3729 public async Task Parameter_decimal_respects_explicit_22_9_and_roundtrips ( )
3830 {
3931 await using var ctx = Fixture . CreateContext ( ) ;
40- try
41- {
42- await ctx . Database . EnsureCreatedAsync ( ) ;
32+ await ctx . Database . EnsureCreatedAsync ( ) ;
4333
44- var v = 123.456789012m ;
45- ctx . Add ( new ItemExplicit { Price = v } ) ;
46- await ctx . SaveChangesAsync ( ) ;
34+ var v = 123.456789012m ;
35+ ctx . Add ( new ItemExplicit { Price = v } ) ;
36+ await ctx . SaveChangesAsync ( ) ;
4737
48- var got = await ctx . Set < ItemExplicit > ( ) . Where ( x => x . Price == v ) . ToListAsync ( ) ;
49- Assert . Single ( got ) ;
50- Assert . Equal ( v , got [ 0 ] . Price ) ;
51- }
52- finally
53- {
54- await ctx . Database . CloseConnectionAsync ( ) ;
55- }
38+ var got = await ctx . Set < ItemExplicit > ( ) . SingleAsync ( x => x . Price == v ) ;
39+ Assert . Equal ( v , got . Price ) ;
5640 }
5741
5842 [ ConditionalFact ]
5943 public async Task Decimal_out_of_range_bubbles_up ( )
6044 {
6145 await using var ctx = Fixture . CreateContext ( ) ;
62- try
63- {
64- await ctx . Database . EnsureCreatedAsync ( ) ;
46+ await ctx . Database . EnsureCreatedAsync ( ) ;
6547
66- var tooBig = new ItemExplicit { Price = 10_000_000_000_000m } ;
67- ctx . Add ( tooBig ) ;
48+ var tooBig = new ItemExplicit { Price = 10_000_000_000_000m } ;
49+ ctx . Add ( tooBig ) ;
6850
69- var ex = await Assert . ThrowsAsync < DbUpdateException > ( ( ) => ctx . SaveChangesAsync ( ) ) ;
70- Assert . Contains ( "Decimal" , ex . InnerException ? . Message ?? "" ) ;
71- }
72- finally
73- {
74- await ctx . Database . CloseConnectionAsync ( ) ;
75- }
51+ var ex = await Assert . ThrowsAsync < DbUpdateException > ( ( ) => ctx . SaveChangesAsync ( ) ) ;
52+ Assert . Contains ( "Decimal" , ex . InnerException ? . Message ?? "" ) ;
7653 }
7754
7855 [ Fact ]
@@ -115,28 +92,20 @@ public async Task Parameter_decimal_respects_custom_30_10_and_roundtrips_if_supp
11592
11693 try
11794 {
118- try
119- {
120- await ctx . Database . EnsureCreatedAsync ( ) ;
121- }
122- catch ( Exception ex ) when ( ex . ToString ( )
123- . Contains ( "EnableParameterizedDecimal" , StringComparison . OrdinalIgnoreCase ) )
124- {
125- return ;
126- }
127-
128- var v = 123.4567890123m ;
129- ctx . Add ( new MappingEntity { Price = v } ) ;
130- await ctx . SaveChangesAsync ( ) ;
131-
132- var got = await ctx . Set < MappingEntity > ( ) . Where ( x => x . Price == v ) . ToListAsync ( ) ;
133- Assert . Single ( got ) ;
134- Assert . Equal ( v , got [ 0 ] . Price ) ;
95+ await ctx . Database . EnsureCreatedAsync ( ) ;
13596 }
136- finally
97+ catch ( Exception ex ) when ( ex . ToString ( )
98+ . Contains ( "EnableParameterizedDecimal" , StringComparison . OrdinalIgnoreCase ) )
13799 {
138- await ctx . Database . CloseConnectionAsync ( ) ;
100+ return ;
139101 }
102+
103+ var v = 123.4567890123m ;
104+ ctx . Add ( new MappingEntity { Price = v } ) ;
105+ await ctx . SaveChangesAsync ( ) ;
106+
107+ var got = await ctx . Set < MappingEntity > ( ) . SingleAsync ( x => x . Price == v ) ;
108+ Assert . Equal ( v , got . Price ) ;
140109 }
141110
142111 private sealed class MappingOnlyContext ( DbContextOptions < MappingOnlyContext > options ) : DbContext ( options )
0 commit comments