@@ -492,57 +492,23 @@ public async Task GetExtensionsStartupTypes_BundlesNotConfiguredBindingsConfigur
492
492
[ Fact ]
493
493
public async Task GetExtensionsStartupTypes_NoBindings_In_ExtensionJson ( )
494
494
{
495
- TestMetricsLogger testMetricsLogger = new TestMetricsLogger ( ) ;
496
-
497
- using var directory = new TempDirectory ( ) ;
498
- var binPath = Path . Combine ( directory . Path , "bin" ) ;
499
- Directory . CreateDirectory ( binPath ) ;
500
-
501
- void CopyToBin ( string path )
495
+ ExtensionInstall storage1 = new ( "AzureStorageBlobs" , typeof ( AzureStorageWebJobsStartup ) ) ;
496
+ ExtensionInstall storage2 = new ( "Storage" , typeof ( AzureStorageWebJobsStartup ) )
502
497
{
503
- File . Copy ( path , Path . Combine ( binPath , Path . GetFileName ( path ) ) ) ;
504
- }
498
+ HintPath = "Microsoft.Azure.WebJobs.Extensions.Storage.dll"
499
+ } ;
505
500
506
- CopyToBin ( typeof ( AzureStorageWebJobsStartup ) . Assembly . Location ) ;
507
-
508
- string extensionJson = $$ """
509
- {
510
- "extensions": [
511
- {
512
- "name": "Storage",
513
- "typeName": "{{ typeof ( AzureStorageWebJobsStartup ) . AssemblyQualifiedName }} ",
514
- "hintPath": "Microsoft.Azure.WebJobs.Extensions.Storage.dll"
515
- },
516
- {
517
- "Name": "AzureStorageBlobs",
518
- "TypeName": "{{ typeof ( AzureStorageWebJobsStartup ) . AssemblyQualifiedName }} "
519
- }
520
- ]
521
- }
522
- """ ;
523
-
524
- File . WriteAllText ( Path . Combine ( binPath , "extensions.json" ) , extensionJson ) ;
525
-
526
- TestLoggerProvider testLoggerProvider = new TestLoggerProvider ( ) ;
527
- LoggerFactory factory = new LoggerFactory ( ) ;
528
- factory . AddProvider ( testLoggerProvider ) ;
529
- var testLogger = factory . CreateLogger < ScriptStartupTypeLocator > ( ) ;
530
-
531
- var mockExtensionBundleManager = new Mock < IExtensionBundleManager > ( ) ;
532
- mockExtensionBundleManager . Setup ( e => e . IsExtensionBundleConfigured ( ) ) . Returns ( true ) ;
533
- mockExtensionBundleManager . Setup ( e => e . GetExtensionBundleDetails ( ) ) . Returns ( Task . FromResult ( new ExtensionBundleDetails ( ) { Id = "bundleID" , Version = "1.0.0" } ) ) ;
534
- mockExtensionBundleManager . Setup ( e => e . GetExtensionBundleBinPathAsync ( ) ) . Returns ( Task . FromResult ( binPath ) ) ;
535
-
536
- var languageWorkerOptions = new TestOptionsMonitor < LanguageWorkerOptions > ( new LanguageWorkerOptions ( ) ) ;
537
- var mockFunctionMetadataManager = GetTestFunctionMetadataManager ( languageWorkerOptions ) ;
538
- OptionsWrapper < ExtensionRequirementOptions > optionsWrapper = new ( new ExtensionRequirementOptions ( ) ) ;
539
- var discoverer = new ScriptStartupTypeLocator ( directory . Path , testLogger , mockExtensionBundleManager . Object , mockFunctionMetadataManager , testMetricsLogger , optionsWrapper ) ;
501
+ string binPath = InstallExtensions ( storage1 , storage2 ) ;
502
+ _bundleManager . Setup ( e => e . IsExtensionBundleConfigured ( ) ) . Returns ( true ) ;
503
+ _bundleManager . Setup ( e => e . GetExtensionBundleDetails ( ) ) . ReturnsAsync ( new ExtensionBundleDetails ( ) { Id = "bundleID" , Version = "1.0.0" } ) ;
504
+ _bundleManager . Setup ( e => e . GetExtensionBundleBinPathAsync ( ) ) . ReturnsAsync ( binPath ) ;
505
+ ScriptStartupTypeLocator discoverer = CreateSystemUnderTest ( ) ;
540
506
541
507
// Act
542
508
var types = await discoverer . GetExtensionsStartupTypesAsync ( ) ;
543
509
544
510
// Assert
545
- AreExpectedMetricsGenerated ( testMetricsLogger ) ;
511
+ AreExpectedMetricsGenerated ( ) ;
546
512
Assert . Equal ( types . Count ( ) , 2 ) ;
547
513
Assert . Equal ( typeof ( AzureStorageWebJobsStartup ) . FullName , types . FirstOrDefault ( ) . FullName ) ;
548
514
}
@@ -703,6 +669,8 @@ private bool AreExpectedMetricsGenerated()
703
669
704
670
private class ExtensionInstall ( string name , Type startupType , params string [ ] bindings )
705
671
{
672
+ public string HintPath { get ; init ; }
673
+
706
674
public static ExtensionInstall Storage ( bool includeBinding = false )
707
675
{
708
676
string [ ] bindings = includeBinding ? [ "blob" ] : [ ] ;
@@ -727,7 +695,12 @@ public static ExtensionInstall Http()
727
695
728
696
public ExtensionReference GetReference ( )
729
697
{
730
- ExtensionReference reference = new ( ) { Name = name , TypeName = startupType . AssemblyQualifiedName } ;
698
+ ExtensionReference reference = new ( )
699
+ {
700
+ Name = name ,
701
+ TypeName = startupType . AssemblyQualifiedName ,
702
+ HintPath = HintPath ,
703
+ } ;
731
704
foreach ( string binding in bindings ?? Enumerable . Empty < string > ( ) )
732
705
{
733
706
reference . Bindings . Add ( binding ) ;
0 commit comments