diff options
author | Rob Mensching <rob@firegiant.com> | 2021-04-22 17:12:34 -0700 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2021-05-05 11:18:35 -0700 |
commit | d8e47230e094a506406a83eb78916abf2668b29c (patch) | |
tree | 2213ee3ed1a19fd5cd19a5914a23b7f7a57318ff /src/test/burn/WixToolsetTest.BurnE2E/WebServer | |
parent | 2cbe83832cc76aa379b29665de5523e82c543acf (diff) | |
download | wix-d8e47230e094a506406a83eb78916abf2668b29c.tar.gz wix-d8e47230e094a506406a83eb78916abf2668b29c.tar.bz2 wix-d8e47230e094a506406a83eb78916abf2668b29c.zip |
Move Integration into test
Diffstat (limited to 'src/test/burn/WixToolsetTest.BurnE2E/WebServer')
-rw-r--r-- | src/test/burn/WixToolsetTest.BurnE2E/WebServer/CoreOwinWebServer.cs | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/test/burn/WixToolsetTest.BurnE2E/WebServer/CoreOwinWebServer.cs b/src/test/burn/WixToolsetTest.BurnE2E/WebServer/CoreOwinWebServer.cs new file mode 100644 index 00000000..89825813 --- /dev/null +++ b/src/test/burn/WixToolsetTest.BurnE2E/WebServer/CoreOwinWebServer.cs | |||
@@ -0,0 +1,70 @@ | |||
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
2 | |||
3 | namespace WixToolsetTest.BurnE2E | ||
4 | { | ||
5 | using System; | ||
6 | using System.Collections.Generic; | ||
7 | using System.IO; | ||
8 | using Microsoft.AspNetCore.Builder; | ||
9 | using Microsoft.AspNetCore.Hosting; | ||
10 | using Microsoft.Extensions.FileProviders; | ||
11 | using Microsoft.Extensions.FileProviders.Physical; | ||
12 | using Microsoft.Extensions.Hosting; | ||
13 | using Microsoft.Extensions.Primitives; | ||
14 | |||
15 | public class CoreOwinWebServer : IWebServer, IFileProvider | ||
16 | { | ||
17 | private Dictionary<string, string> PhysicalPathsByRelativeUrl { get; } = new Dictionary<string, string>(); | ||
18 | |||
19 | private IHost WebHost { get; set; } | ||
20 | |||
21 | public void AddFiles(Dictionary<string, string> physicalPathsByRelativeUrl) | ||
22 | { | ||
23 | foreach (var kvp in physicalPathsByRelativeUrl) | ||
24 | { | ||
25 | this.PhysicalPathsByRelativeUrl.Add(kvp.Key, kvp.Value); | ||
26 | } | ||
27 | } | ||
28 | |||
29 | public void Start() | ||
30 | { | ||
31 | this.WebHost = Host.CreateDefaultBuilder() | ||
32 | .ConfigureWebHostDefaults(webBuilder => | ||
33 | { | ||
34 | // Use localhost instead of * to avoid firewall issues. | ||
35 | webBuilder.UseUrls("http://localhost:9999"); | ||
36 | webBuilder.Configure(appBuilder => | ||
37 | { | ||
38 | appBuilder.UseStaticFiles(new StaticFileOptions | ||
39 | { | ||
40 | FileProvider = this, | ||
41 | RequestPath = "/e2e", | ||
42 | ServeUnknownFileTypes = true, | ||
43 | }); | ||
44 | }); | ||
45 | }) | ||
46 | .Build(); | ||
47 | this.WebHost.Start(); | ||
48 | } | ||
49 | |||
50 | public void Dispose() | ||
51 | { | ||
52 | var waitTime = TimeSpan.FromSeconds(5); | ||
53 | this.WebHost?.StopAsync(waitTime).Wait(waitTime); | ||
54 | } | ||
55 | |||
56 | public IDirectoryContents GetDirectoryContents(string subpath) => throw new NotImplementedException(); | ||
57 | |||
58 | public IFileInfo GetFileInfo(string subpath) | ||
59 | { | ||
60 | if (this.PhysicalPathsByRelativeUrl.TryGetValue(subpath, out var filepath)) | ||
61 | { | ||
62 | return new PhysicalFileInfo(new FileInfo(filepath)); | ||
63 | } | ||
64 | |||
65 | return new NotFoundFileInfo(subpath); | ||
66 | } | ||
67 | |||
68 | public IChangeToken Watch(string filter) => throw new NotImplementedException(); | ||
69 | } | ||
70 | } \ No newline at end of file | ||