1- using System ;
1+ using System . Collections . Generic ;
22using System . IO ;
33using SeqCli . Config ;
44using Xunit ;
5- using Xunit . Sdk ;
65
76namespace SeqCli . Tests . Config ;
87
@@ -17,31 +16,13 @@ public void DefaultConfigFilename()
1716 }
1817
1918 [ Fact ]
20- [ EnvironmentOverridenConfigFilenameBeforeAfter ( SeqCliConfigFile = "MyCustomSeqCli.json" ) ]
2119 public void EnvironmentOverridenConfigFilename ( )
2220 {
23- var configFile = RuntimeConfigurationLoader . SeqCliConfigFilename ( ) ;
24- var customConfigFile = Path . Combine ( Path . GetTempPath ( ) , "MyCustomSeqCli.json" ) ;
21+ var customConfigFile = Path . GetTempFileName ( ) ;
22+ var environment = new Dictionary < string , string > ( ) ;
23+ environment . Add ( "SEQCLI_CONFIG_FILE" , customConfigFile ) ;
24+
25+ var configFile = RuntimeConfigurationLoader . SeqCliConfigFilename ( environment ) ;
2526 Assert . Equal ( customConfigFile , configFile ) ;
2627 }
2728}
28-
29- [ AttributeUsage ( AttributeTargets . Method , Inherited = false , AllowMultiple = false ) ]
30- public class EnvironmentOverridenConfigFilenameBeforeAfter : BeforeAfterTestAttribute
31- {
32- private string originalValue ;
33- public string SeqCliConfigFile { get ; set ; }
34-
35- public override void Before ( System . Reflection . MethodInfo methodUnderTest )
36- {
37- originalValue = Environment . GetEnvironmentVariable ( "SEQCLI_CONFIG_FILE" ) ;
38-
39- var configFile = Path . Combine ( Path . GetTempPath ( ) , SeqCliConfigFile ) ;
40- Environment . SetEnvironmentVariable ( "SEQCLI_CONFIG_FILE" , configFile ) ;
41- }
42-
43- public override void After ( System . Reflection . MethodInfo methodUnderTest )
44- {
45- Environment . SetEnvironmentVariable ( "SEQCLI_CONFIG_FILE" , originalValue ) ;
46- }
47- }
0 commit comments