@@ -50,7 +50,7 @@ public SamplesEndToEndTests(TestFixture fixture)
50
50
[ Fact ]
51
51
public async Task EventHubTrigger ( )
52
52
{
53
- TestHelpers . ClearFunctionLogs ( "EventHubTrigger" ) ;
53
+ _fixture . TraceWriter . ClearTraces ( ) ;
54
54
55
55
// write 3 events
56
56
List < EventData > events = new List < EventData > ( ) ;
@@ -87,7 +87,7 @@ await TestHelpers.Await(() =>
87
87
{
88
88
// wait until all of the 3 of the unique IDs sent
89
89
// above have been processed
90
- logs = string . Join ( "\r \n " , TestHelpers . GetFunctionLogsAsync ( "EventHubTrigger" , throwOnNoLogs : false ) . Result ) ;
90
+ logs = string . Join ( "\r \n " , _fixture . GetFunctionLogs ( "EventHubTrigger" ) ) ;
91
91
return ids . All ( p => logs . Contains ( p ) ) ;
92
92
} ) ;
93
93
@@ -350,7 +350,7 @@ public async Task HttpTrigger_DuplicateQueryParams_Succeeds()
350
350
[ Fact ]
351
351
public async Task HttpTrigger_CustomRoute_Get_ReturnsExpectedResponse ( )
352
352
{
353
- TestHelpers . ClearFunctionLogs ( "HttpTrigger-CustomRoute-Get" ) ;
353
+ _fixture . TraceWriter . ClearTraces ( ) ;
354
354
355
355
var id = "4e2796ae-b865-4071-8a20-2a15cbaf856c" ;
356
356
string functionKey = "82fprgh77jlbhcma3yr1zen8uv9yb0i7dwze3np2" ;
@@ -402,8 +402,8 @@ public async Task HttpTrigger_CustomRoute_Get_ReturnsExpectedResponse()
402
402
Assert . Equal ( HttpStatusCode . NotFound , response . StatusCode ) ;
403
403
404
404
// verify route parameters were part of binding data
405
- var logs = await TestHelpers . GetFunctionLogsAsync ( "HttpTrigger-CustomRoute-Get" ) ;
406
- var log = logs . Single ( p => p . Contains ( $ "category: electronics id: { id } ") ) ;
405
+ var logs = _fixture . GetFunctionLogs ( "HttpTrigger-CustomRoute-Get" ) ;
406
+ var log = logs . SingleOrDefault ( p => p . Contains ( $ "category: electronics id: { id } ") ) ;
407
407
Assert . NotNull ( log ) ;
408
408
}
409
409
@@ -477,7 +477,7 @@ await TestHelpers.Await(() =>
477
477
[ Fact ]
478
478
public async Task HttpTrigger_CSharp_CustomRoute_ReturnsExpectedResponse ( )
479
479
{
480
- TestHelpers . ClearFunctionLogs ( "HttpTrigger-CSharp-CustomRoute" ) ;
480
+ _fixture . TraceWriter . ClearTraces ( ) ;
481
481
482
482
string functionKey = "68qkqlughacc6f9n6t4ubk0jq7r5er7pta13yh20" ;
483
483
string uri = $ "api/csharp/products/electronics/123?code={ functionKey } ";
@@ -523,7 +523,7 @@ public async Task HttpTrigger_CSharp_CustomRoute_ReturnsExpectedResponse()
523
523
Assert . Equal ( HttpStatusCode . NotFound , response . StatusCode ) ;
524
524
525
525
// verify route parameters were part of binding data
526
- var logs = await TestHelpers . GetFunctionLogsAsync ( "HttpTrigger-CSharp-CustomRoute" ) ;
526
+ var logs = _fixture . GetFunctionLogs ( "HttpTrigger-CSharp-CustomRoute" ) ;
527
527
Assert . True ( logs . Any ( p => p . Contains ( "Parameters: category=electronics id=123" ) ) ) ;
528
528
Assert . True ( logs . Any ( p => p . Contains ( "ProductInfo: Category=electronics Id=123" ) ) ) ;
529
529
}
@@ -786,7 +786,7 @@ await TestHelpers.Await(() =>
786
786
[ Fact ]
787
787
public async Task QueueTriggerPython_Succeeds ( )
788
788
{
789
- TestHelpers . ClearFunctionLogs ( "QueueTrigger-Python" ) ;
789
+ _fixture . TraceWriter . ClearTraces ( ) ;
790
790
791
791
// write the input message
792
792
CloudQueue inputQueue = _fixture . QueueClient . GetQueueReference ( "samples-python" ) ;
@@ -809,12 +809,11 @@ public async Task QueueTriggerPython_Succeeds()
809
809
Assert . Equal ( id , ( string ) jsonObject [ "id" ] ) ;
810
810
811
811
// verify the function output
812
- var logs = await TestHelpers . GetFunctionLogsAsync ( "QueueTrigger-Python" ) ;
812
+ var logs = _fixture . GetFunctionLogs ( "QueueTrigger-Python" ) . ToList ( ) ;
813
813
814
- // strip off the timestamps and [Info] from the beginning of each line
815
- logs = logs . Select ( l => l . Split ( new [ ] { ' ' } , 3 ) [ 2 ] ) . ToList ( ) ;
816
814
int idx = logs . IndexOf ( "Read 5 Table entities" ) ;
817
- for ( int i = idx + 1 ; i < 5 ; i ++ )
815
+ logs = logs . Skip ( idx + 1 ) . Take ( 5 ) . ToList ( ) ;
816
+ for ( int i = 0 ; i < 5 ; i ++ )
818
817
{
819
818
string json = logs [ i ] ;
820
819
JObject entity = null ;
@@ -1220,6 +1219,15 @@ public TestFixture()
1220
1219
1221
1220
public HttpServer HttpServer { get ; set ; }
1222
1221
1222
+ public TestTraceWriter TraceWriter => _traceWriter ;
1223
+
1224
+ public IEnumerable < string > GetFunctionLogs ( string functionName )
1225
+ {
1226
+ return _traceWriter . GetTraces ( )
1227
+ . Where ( p => p . Properties . ContainsKey ( ScriptConstants . LoggerFunctionNameKey ) && string . Compare ( ( string ) p . Properties [ ScriptConstants . LoggerFunctionNameKey ] , functionName ) == 0 )
1228
+ . Select ( p => p . Message ) ;
1229
+ }
1230
+
1223
1231
public void Dispose ( )
1224
1232
{
1225
1233
HttpServer ? . Dispose ( ) ;
0 commit comments