4
4
using System ;
5
5
using System . IO ;
6
6
using System . Linq ;
7
+ using System . Threading . Tasks ;
7
8
using Microsoft . Azure . WebJobs . Extensions . Http ;
8
9
using Microsoft . Azure . WebJobs . Script . Config ;
9
10
using Microsoft . Azure . WebJobs . Script . Eventing ;
@@ -64,29 +65,29 @@ public void InStandbyMode_ReturnsExpectedValue()
64
65
}
65
66
66
67
[ Fact ]
67
- public void GetScriptHostConfiguration_ReturnsExpectedValue ( )
68
+ public async Task GetScriptHostConfiguration_ReturnsExpectedValue ( )
68
69
{
69
- TestGetter ( _webHostResolver . GetScriptHostConfiguration ) ;
70
+ await TestGetter ( _webHostResolver . GetScriptHostConfiguration ) ;
70
71
}
71
72
72
73
[ Fact ]
73
- public void GetSecretManager_ReturnsExpectedValue ( )
74
+ public async Task GetSecretManager_ReturnsExpectedValue ( )
74
75
{
75
- TestGetter ( _webHostResolver . GetSecretManager ) ;
76
+ await TestGetter ( _webHostResolver . GetSecretManager ) ;
76
77
}
77
78
78
79
[ Fact ]
79
- public void GetWebScriptHostManager_ReturnsExpectedValue ( )
80
+ public async Task GetWebScriptHostManager_ReturnsExpectedValue ( )
80
81
{
81
- TestGetter ( _webHostResolver . GetWebScriptHostManager ) ;
82
+ await TestGetter ( _webHostResolver . GetWebScriptHostManager ) ;
82
83
}
83
84
84
85
[ Fact ]
85
- public void EnsureInitialized_NonPlaceholderMode ( )
86
+ public async Task EnsureInitialized_NonPlaceholderMode ( )
86
87
{
87
88
using ( new TestEnvironment ( ) )
88
89
{
89
- var settings = GetWebHostSettings ( ) ;
90
+ var settings = await GetWebHostSettings ( ) ;
90
91
_settingsManager . SetSetting ( EnvironmentSettingNames . AzureWebsitePlaceholderMode , "0" ) ;
91
92
Assert . False ( WebScriptHostManager . InStandbyMode ) ;
92
93
_webHostResolver . EnsureInitialized ( settings ) ;
@@ -99,11 +100,11 @@ public void EnsureInitialized_NonPlaceholderMode()
99
100
}
100
101
101
102
[ Fact ]
102
- public void EnsureInitialized_PlaceholderMode ( )
103
+ public async Task EnsureInitialized_PlaceholderMode ( )
103
104
{
104
105
using ( new TestEnvironment ( ) )
105
106
{
106
- var settings = GetWebHostSettings ( ) ;
107
+ var settings = await GetWebHostSettings ( ) ;
107
108
_settingsManager . SetSetting ( EnvironmentSettingNames . AzureWebsitePlaceholderMode , "1" ) ;
108
109
Assert . True ( WebScriptHostManager . InStandbyMode ) ;
109
110
_webHostResolver . EnsureInitialized ( settings ) ;
@@ -120,7 +121,7 @@ public void EnsureInitialized_PlaceholderMode()
120
121
}
121
122
}
122
123
123
- private void TestGetter < T > ( Func < WebHostSettings , T > func )
124
+ private async Task TestGetter < T > ( Func < WebHostSettings , T > func )
124
125
{
125
126
using ( new TestEnvironment ( ) )
126
127
{
@@ -131,7 +132,7 @@ private void TestGetter<T>(Func<WebHostSettings, T> func)
131
132
{
132
133
_settingsManager . SetSetting ( EnvironmentSettingNames . AzureWebsitePlaceholderMode , "1" ) ;
133
134
134
- var settings = GetWebHostSettings ( ) ;
135
+ var settings = await GetWebHostSettings ( ) ;
135
136
prev = func ( settings ) ;
136
137
Assert . NotNull ( prev ) ;
137
138
@@ -156,16 +157,23 @@ private void TestGetter<T>(Func<WebHostSettings, T> func)
156
157
}
157
158
}
158
159
159
- private WebHostSettings GetWebHostSettings ( )
160
+ private Task < WebHostSettings > GetWebHostSettings ( )
160
161
{
161
162
var home = _settingsManager . GetSetting ( EnvironmentSettingNames . AzureWebsiteHomePath ) ;
162
- return new WebHostSettings
163
+ var settings = new WebHostSettings
163
164
{
164
165
IsSelfHost = true ,
165
166
ScriptPath = Path . Combine ( home , @"site\wwwroot" ) ,
166
167
LogPath = Path . Combine ( home , @"LogFiles\Application\Functions" ) ,
167
168
SecretsPath = Path . Combine ( home , @"data\Functions\secrets" )
168
169
} ;
170
+
171
+ Directory . CreateDirectory ( settings . ScriptPath ) ;
172
+ Directory . CreateDirectory ( settings . LogPath ) ;
173
+ Directory . CreateDirectory ( settings . SecretsPath ) ;
174
+
175
+ return Task . Delay ( 200 )
176
+ . ContinueWith ( t => settings ) ;
169
177
}
170
178
171
179
public void Dispose ( )
0 commit comments