-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestDataFunction.cs
More file actions
48 lines (40 loc) · 1.6 KB
/
TestDataFunction.cs
File metadata and controls
48 lines (40 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
namespace IntegrationTest;
using System.Reflection;
using Contracts;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
using Shared.Infrastructure;
class TestDataFunction(GlobalTestStorage storage)
{
static readonly string InformationalVersion;
static readonly DateTime StartTime;
static TestDataFunction()
{
InformationalVersion = typeof(TestDataFunction).Assembly
.GetCustomAttributes<AssemblyInformationalVersionAttribute>()
.First()
.InformationalVersion;
StartTime = DateTime.UtcNow;
}
[Function(nameof(GetTestData))]
public Payload GetTestData([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "testing/data/{testName}")] HttpRequestData _, string testName)
{
var payload = storage.CreatePayload(testName);
return payload;
}
[Function(nameof(ClearTestData))]
public string ClearTestData([HttpTrigger(AuthorizationLevel.Anonymous, "delete", Route = "testing/data/{testName}")] HttpRequestData _, string testName)
{
storage.Clear(testName);
return "OK";
}
[Function(nameof(GetInfo))]
public InfoResult GetInfo([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "testing")] HttpRequestData _)
{
var result = new InfoResult(InformationalVersion, DateTime.UtcNow - StartTime);
return result;
}
[Function(nameof(GetErrors))]
public ExceptionInfo[] GetErrors([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "testing/errors")] HttpRequestData _)
=> ExceptionTrackingMiddleware.GetErrors();
}