File tree Expand file tree Collapse file tree 7 files changed +14
-9
lines changed
tests/HydraScript.IntegrationTests Expand file tree Collapse file tree 7 files changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -18,14 +18,14 @@ private static ExecuteCommand GetCommand()
1818 {
1919 var fileInfo = parseResult . GetValue ( command . PathArgument ) ! ;
2020 var dump = parseResult . GetValue ( command . DumpOption ) ;
21- var serviceProvider = GetServiceProvider ( fileInfo , dump ) ;
21+ using var serviceProvider = GetServiceProvider ( fileInfo , dump ) ;
2222 var executor = serviceProvider . GetRequiredService < Executor > ( ) ;
2323 return executor . Invoke ( ) ;
2424 } ) ;
2525 return command ;
2626 }
2727
28- internal static IServiceProvider GetServiceProvider (
28+ internal static ServiceProvider GetServiceProvider (
2929 FileInfo fileInfo ,
3030 bool dump ,
3131 Action < IServiceCollection > ? configureServices = null )
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ public class DumpOptionTests(TestHostFixture fixture) : IClassFixture<TestHostFi
99 [ Fact ]
1010 public void Invoke_DumpOptionPassed_FilesCreated ( )
1111 {
12- var runner = fixture . GetRunner ( new TestHostFixture . Options ( Dump : true ) ) ;
12+ using var runner = fixture . GetRunner ( new TestHostFixture . Options ( Dump : true ) ) ;
1313 runner . Invoke ( ) ;
1414
1515 var fileSystemMock = runner . ServiceProvider . GetRequiredService < IFileSystem > ( ) ;
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ public class NullAssignmentWhenUndefinedTests(TestHostFixture fixture) : IClassF
77 [ Theory , MemberData ( nameof ( NullAssignmentScripts ) ) ]
88 public void NullAssignment_UndefinedDestinationOrReturnType_HydraScriptError ( string script )
99 {
10- var runner = fixture . GetRunner ( new TestHostFixture . Options ( InMemoryScript : script ) ) ;
10+ using var runner = fixture . GetRunner ( new TestHostFixture . Options ( InMemoryScript : script ) ) ;
1111 var code = runner . Invoke ( ) ;
1212 code . Should ( ) . Be ( Executor . ExitCodes . HydraScriptError ) ;
1313 fixture . LogMessages . Should ( )
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ public class VariableInitializationTests(TestHostFixture fixture) : IClassFixtur
77 [ Theory , MemberData ( nameof ( VariableInitializationScripts ) ) ]
88 public void VariableWithoutTypeDeclared_AccessedBeforeInitialization_HydraScriptError ( string script )
99 {
10- var runner = fixture . GetRunner ( new TestHostFixture . Options ( InMemoryScript : script ) ) ;
10+ using var runner = fixture . GetRunner ( new TestHostFixture . Options ( InMemoryScript : script ) ) ;
1111 var code = runner . Invoke ( ) ;
1212 code . Should ( ) . Be ( Executor . ExitCodes . HydraScriptError ) ;
1313 fixture . LogMessages . Should ( )
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ function func(b: boolean) {
1616 }
1717 let x = func(true)
1818 """ ;
19- var runner = fixture . GetRunner ( new TestHostFixture . Options ( InMemoryScript : script ) ) ;
19+ using var runner = fixture . GetRunner ( new TestHostFixture . Options ( InMemoryScript : script ) ) ;
2020 var code = runner . Invoke ( ) ;
2121 code . Should ( ) . Be ( Executor . ExitCodes . HydraScriptError ) ;
2222 fixture . LogMessages . Should ( )
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ public class SuccessfulProgramsTests(TestHostFixture fixture) : IClassFixture<Te
88 [ ClassData ( typeof ( SuccessfulPrograms ) ) ]
99 public void Invoke_NoError_ReturnCodeIsZero ( string relativePathToFile )
1010 {
11- var runner = fixture . GetRunner (
11+ using var runner = fixture . GetRunner (
1212 new TestHostFixture . Options (
1313 FileName : relativePathToFile ,
1414 MockFileSystem : false ) ) ;
Original file line number Diff line number Diff line change @@ -18,10 +18,15 @@ public record Options(
1818 bool MockFileSystem = true ,
1919 string InMemoryScript = "" ) ;
2020
21- public class Runner ( IServiceProvider serviceProvider , Executor executor )
21+ public class Runner ( ServiceProvider serviceProvider , Executor executor ) : IDisposable
2222 {
23- public IServiceProvider ServiceProvider => serviceProvider ;
23+ public ServiceProvider ServiceProvider => serviceProvider ;
2424 public int Invoke ( ) => executor . Invoke ( ) ;
25+
26+ public void Dispose ( )
27+ {
28+ serviceProvider . Dispose ( ) ;
29+ }
2530 }
2631
2732 private readonly List < string > _logMessages = [ ] ;
You can’t perform that action at this time.
0 commit comments