@@ -787,35 +787,42 @@ public async Task JobExtensionTelemetryPublisherSecretValue()
787787
788788 hc . SetSingleton ( new TaskRestrictionsChecker ( ) as ITaskRestrictionsChecker ) ;
789789
790- Environment . SetEnvironmentVariable ( "http_proxy" , "http://admin:[email protected] " ) ; 791-
792- var expectedEvent = new Dictionary < string , object > ( )
790+ try
793791 {
794- { "JobId" , null } ,
795- { "ProxyAddress-${http_proxy}" , "http://admin:***@localhost.com" } ,
796- } ;
792+ Environment . SetEnvironmentVariable ( "http_proxy" , "http://admin:[email protected] " ) ; 797793
798- var actualEvents = new List < CustomerIntelligenceEvent [ ] > ( ) ;
794+ var expectedEvent = new Dictionary < string , object > ( )
795+ {
796+ { "JobId" , null } ,
797+ { "ProxyAddress-${http_proxy}" , "http://admin:***@localhost.com" } ,
798+ } ;
799799
800- _mockCiService . Setup ( s => s . PublishEventsAsync ( It . IsAny < CustomerIntelligenceEvent [ ] > ( ) ) )
801- . Callback < CustomerIntelligenceEvent [ ] > ( actualEvents . Add )
802- . Returns ( Task . CompletedTask ) ;
800+ var actualEvents = new List < CustomerIntelligenceEvent [ ] > ( ) ;
803801
802+ _mockCiService . Setup ( s => s . PublishEventsAsync ( It . IsAny < CustomerIntelligenceEvent [ ] > ( ) ) )
803+ . Callback < CustomerIntelligenceEvent [ ] > ( actualEvents . Add )
804+ . Returns ( Task . CompletedTask ) ;
804805
805- TestJobExtension testExtension = new TestJobExtension ( ) ;
806- testExtension . Initialize ( hc ) ;
807- await testExtension . InitializeJob ( _jobEc , _message ) ;
808806
809- var result = actualEvents . Where ( w => w [ 0 ] . Properties . ContainsKey ( "ProxyAddress-${http_proxy}" ) ) ;
807+ TestJobExtension testExtension = new TestJobExtension ( ) ;
808+ testExtension . Initialize ( hc ) ;
809+ await testExtension . InitializeJob ( _jobEc , _message ) ;
810+
811+ var result = actualEvents . Where ( w => w [ 0 ] . Properties . ContainsKey ( "ProxyAddress-${http_proxy}" ) ) ;
810812
811- Assert . True ( result ? . Count ( ) == 1 ) ;
813+ Assert . True ( result ? . Count ( ) == 1 ) ;
812814
813- Assert . True (
814- ! expectedEvent . Except ( result . First ( ) [ 0 ] . Properties ) . Any ( ) ,
815- $ "Event does not match. " +
816- $ "Expected:{ JsonSerializer . Serialize ( expectedEvent ) } ;" +
817- $ "Actual:{ JsonSerializer . Serialize ( result . First ( ) [ 0 ] . Properties ) } "
818- ) ;
815+ Assert . True (
816+ ! expectedEvent . Except ( result . First ( ) [ 0 ] . Properties ) . Any ( ) ,
817+ $ "Event does not match. " +
818+ $ "Expected:{ JsonSerializer . Serialize ( expectedEvent ) } ;" +
819+ $ "Actual:{ JsonSerializer . Serialize ( result . First ( ) [ 0 ] . Properties ) } "
820+ ) ;
821+ }
822+ finally
823+ {
824+ Environment . SetEnvironmentVariable ( "http_proxy" , "" ) ;
825+ }
819826 }
820827 }
821828}
0 commit comments