@@ -69,7 +69,7 @@ public void TestManuallyMappingShouldReturnRedisExist()
69
69
var serviceProvider = builder . Services . BuildServiceProvider ( ) ;
70
70
var rabbitMqOptions = serviceProvider . GetRequiredService < IOptions < RabbitMqOptions > > ( ) ;
71
71
Assert . IsTrue ( rabbitMqOptions is
72
- { Value . HostName : "localhost" , Value . UserName : "admin" , Value . Password : "admin" , Value . VirtualHost : "/" , Value . Port : "5672" } ) ;
72
+ { Value . HostName : "localhost" , Value . UserName : "admin" , Value . Password : "admin" , Value . VirtualHost : "/" , Value . Port : "5672" } ) ;
73
73
74
74
var systemOptions = serviceProvider . GetRequiredService < IOptions < SystemOptions > > ( ) ;
75
75
Assert . IsTrue ( systemOptions is { Value . Name : "Masa TEST" } ) ;
@@ -94,7 +94,7 @@ public void TestMasaConfigurationBuilderShouldReturnSourceCount3()
94
94
95
95
Assert . IsTrue ( masaConfigurationBuilder . Build ( ) [ "KafkaOptions:Servers" ] == appsettingConfigurationBuilder . Build ( ) [ "KafkaOptions:Servers" ] ) ;
96
96
97
- Assert . IsTrue ( masaConfigurationBuilder . Properties . Count == configurationBuilder . Properties . Count ) ;
97
+ Assert . IsTrue ( masaConfigurationBuilder . Properties . Count == configurationBuilder . Properties . Count ) ;
98
98
}
99
99
100
100
[ TestMethod ]
@@ -208,7 +208,7 @@ public void TestCreateMasaConfigurationShouldReturnRedisOptionsAndSystemOptionsE
208
208
}
209
209
210
210
[ TestMethod ]
211
- public void TestConfigurationChangeShouldReturnNameEmpty ( )
211
+ public async Task TestConfigurationChangeShouldReturnNameEmpty ( )
212
212
{
213
213
var builder = WebApplication . CreateBuilder ( ) ;
214
214
@@ -231,11 +231,14 @@ public void TestConfigurationChangeShouldReturnNameEmpty()
231
231
var newRedisOption = systemOption . Value ;
232
232
newRedisOption . Name = null ;
233
233
234
- File . WriteAllText ( Path . Combine ( rootPath , "appsettings.json" ) ,
234
+ var oldContent = await File . ReadAllTextAsync ( Path . Combine ( rootPath , "appsettings.json" ) ) ;
235
+ await File . WriteAllTextAsync ( Path . Combine ( rootPath , "appsettings.json" ) ,
235
236
System . Text . Json . JsonSerializer . Serialize ( new { SystemOptions = newRedisOption } ) ) ;
236
237
237
238
Thread . Sleep ( 2000 ) ;
238
239
var option = serviceProvider . GetRequiredService < IOptionsMonitor < SystemOptions > > ( ) ;
239
240
Assert . IsTrue ( option . CurrentValue . Name == "" ) ;
241
+
242
+ await File . WriteAllTextAsync ( Path . Combine ( rootPath , "appsettings.json" ) , oldContent ) ;
240
243
}
241
244
}
0 commit comments