@@ -45,91 +45,21 @@ public virtual Task Updating_then_updating_the_same_entity_results_in_DbUpdateCo
45
45
ctx => ctx . Customers . Single ( c => c . Id == "3" ) . Name = "Updated" ,
46
46
ctx => ctx . Customers . Single ( c => c . Id == "3" ) . Name = "Updated" ) ;
47
47
48
- [ ConditionalFact ]
49
- public async Task Etag_will_return_when_content_response_enabled_false ( )
50
- {
51
- await using var testDatabase = CosmosTestStore . CreateInitialized (
52
- DatabaseName ,
53
- o => o . ContentResponseOnWriteEnabled ( false ) ) ;
54
-
55
- var customer = new Customer
56
- {
57
- Id = "4" , Name = "Theon" ,
58
- } ;
59
-
60
- await using ( var context = new ConcurrencyContext ( CreateOptions ( testDatabase ) ) )
61
- {
62
- await context . Database . EnsureCreatedAsync ( ) ;
63
-
64
- await context . AddAsync ( customer ) ;
65
-
66
- await context . SaveChangesAsync ( ) ;
67
- }
68
-
69
- await using ( var context = new ConcurrencyContext ( CreateOptions ( testDatabase ) ) )
70
- {
71
- var customerFromStore = await context . Set < Customer > ( ) . SingleAsync ( ) ;
72
-
73
- Assert . Equal ( customer . Id , customerFromStore . Id ) ;
74
- Assert . Equal ( "Theon" , customerFromStore . Name ) ;
75
- Assert . Equal ( customer . ETag , customerFromStore . ETag ) ;
76
-
77
- context . Remove ( customerFromStore ) ;
78
-
79
- await context . SaveChangesAsync ( ) ;
80
- }
81
- }
82
-
83
- [ ConditionalFact ]
84
- public async Task Etag_will_return_when_content_response_enabled_true ( )
85
- {
86
- await using var testDatabase = CosmosTestStore . CreateInitialized (
87
- DatabaseName ,
88
- o => o . ContentResponseOnWriteEnabled ( ) ) ;
89
-
90
- var customer = new Customer
91
- {
92
- Id = "3" , Name = "Theon" ,
93
- } ;
94
-
95
- await using ( var context = new ConcurrencyContext ( CreateOptions ( testDatabase ) ) )
96
- {
97
- await context . Database . EnsureCreatedAsync ( ) ;
98
-
99
- await context . AddAsync ( customer ) ;
100
-
101
- await context . SaveChangesAsync ( ) ;
102
- }
103
-
104
- await using ( var context = new ConcurrencyContext ( CreateOptions ( testDatabase ) ) )
105
- {
106
- var customerFromStore = await context . Set < Customer > ( ) . SingleAsync ( ) ;
107
-
108
- Assert . Equal ( customer . Id , customerFromStore . Id ) ;
109
- Assert . Equal ( "Theon" , customerFromStore . Name ) ;
110
- Assert . Equal ( customer . ETag , customerFromStore . ETag ) ;
111
-
112
- context . Remove ( customerFromStore ) ;
113
-
114
- await context . SaveChangesAsync ( ) ;
115
- }
116
- }
117
-
118
48
[ ConditionalTheory ]
119
49
[ InlineData ( null ) ]
120
50
[ InlineData ( true ) ]
121
51
[ InlineData ( false ) ]
122
52
public async Task Etag_is_updated_in_entity_after_SaveChanges ( bool ? contentResponseOnWriteEnabled )
123
53
{
124
- await using var testDatabase = CosmosTestStore . CreateInitialized (
125
- DatabaseName ,
126
- o =>
54
+ var options = new DbContextOptionsBuilder ( Fixture . CreateOptions ( ) )
55
+ . UseCosmos ( o =>
127
56
{
128
- if ( contentResponseOnWriteEnabled . HasValue )
57
+ if ( contentResponseOnWriteEnabled != null )
129
58
{
130
59
o . ContentResponseOnWriteEnabled ( contentResponseOnWriteEnabled . Value ) ;
131
60
}
132
- } ) ;
61
+ } )
62
+ . Options ;
133
63
134
64
var customer = new Customer
135
65
{
@@ -139,10 +69,9 @@ public async Task Etag_is_updated_in_entity_after_SaveChanges(bool? contentRespo
139
69
} ;
140
70
141
71
string etag = null ;
142
-
143
- await using ( var context = new ConcurrencyContext ( CreateOptions ( testDatabase ) ) )
72
+ await using ( var context = new ConcurrencyContext ( options ) )
144
73
{
145
- await context . Database . EnsureCreatedAsync ( ) ;
74
+ await Fixture . TestStore . CleanAsync ( context ) ;
146
75
147
76
await context . AddAsync ( customer ) ;
148
77
@@ -151,7 +80,7 @@ public async Task Etag_is_updated_in_entity_after_SaveChanges(bool? contentRespo
151
80
etag = customer . ETag ;
152
81
}
153
82
154
- await using ( var context = new ConcurrencyContext ( CreateOptions ( testDatabase ) ) )
83
+ await using ( var context = new ConcurrencyContext ( options ) )
155
84
{
156
85
var customerFromStore = await context . Set < Customer > ( ) . SingleAsync ( ) ;
157
86
@@ -208,7 +137,7 @@ protected virtual async Task ConcurrencyTestAsync<TException>(
208
137
where TException : DbUpdateException
209
138
{
210
139
using var outerContext = CreateContext ( ) ;
211
- await outerContext . Database . EnsureCreatedAsync ( ) ;
140
+ await Fixture . TestStore . CleanAsync ( outerContext ) ;
212
141
seedAction ? . Invoke ( outerContext ) ;
213
142
await outerContext . SaveChangesAsync ( ) ;
214
143
@@ -258,12 +187,6 @@ protected override void OnModelCreating(ModelBuilder builder)
258
187
} ) ;
259
188
}
260
189
261
- private DbContextOptions CreateOptions ( CosmosTestStore testDatabase )
262
- => testDatabase . AddProviderOptions ( new DbContextOptionsBuilder ( ) )
263
- . ConfigureWarnings ( w => w . Ignore ( CoreEventId . ManyServiceProvidersCreatedWarning ) )
264
- . EnableDetailedErrors ( )
265
- . Options ;
266
-
267
190
public class Customer
268
191
{
269
192
public string Id { get ; set ; }
0 commit comments