33using System . Linq ;
44using System . Text ;
55using System . Threading . Tasks ;
6+ using Microsoft . Extensions . Configuration ;
67using Microsoft . VisualStudio . TestTools . UnitTesting ;
78using SW . Bitween . NativeAdapters . RebexPop3Receiver ;
89
910namespace SW . Bitween . UnitTests ;
1011
1112/// <summary>
12- /// Requires a real Rebex license via the REBEX_LICENSE_KEY environment variable.
13+ /// Requires a real Rebex license via the Bitween:RebexLicenseKey configuration value
14+ /// (settable through the Bitween__RebexLicenseKey environment variable).
1315/// Tests report Inconclusive (not Failed) when it's not set, so CI/dev machines
1416/// without a license don't fail the build.
1517/// </summary>
1618[ TestClass ]
1719public class NativeRebexPop3ReceiverTests
1820{
21+ private static readonly string LicenseKey = new ConfigurationBuilder ( )
22+ . AddEnvironmentVariables ( )
23+ . Build ( )
24+ . GetSection ( BitweenOptions . ConfigurationSection ) [ nameof ( BitweenOptions . RebexLicenseKey ) ] ;
25+
1926 [ TestInitialize ]
2027 public void SkipIfNoLicense ( )
2128 {
22- if ( string . IsNullOrEmpty ( Environment . GetEnvironmentVariable ( NativeRebexPop3Receiver . LicenseKeyEnvironmentVariable ) ) )
23- Assert . Inconclusive ( $ "{ NativeRebexPop3Receiver . LicenseKeyEnvironmentVariable } is not set.") ;
29+ if ( string . IsNullOrEmpty ( LicenseKey ) )
30+ Assert . Inconclusive ( $ "{ BitweenOptions . ConfigurationSection } : { nameof ( BitweenOptions . RebexLicenseKey ) } is not set.") ;
2431 }
2532
2633 private static Dictionary < string , string > Settings ( string encoding = "utf8" , int batchSize = 50 ) => new ( )
@@ -34,7 +41,7 @@ public void SkipIfNoLicense()
3441
3542 private static NativeRebexPop3Receiver CreateReceiver ( FakePop3Server server , string encoding = "utf8" , int batchSize = 50 )
3643 {
37- var receiver = new NativeRebexPop3Receiver { Port = server . Port , UseSsl = false } ;
44+ var receiver = new NativeRebexPop3Receiver ( LicenseKey ) { Port = server . Port , UseSsl = false } ;
3845 receiver . InitializeStartupValues ( Settings ( encoding , batchSize ) ) ;
3946 return receiver ;
4047 }
0 commit comments