-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b5c9e6c
commit 8c05e90
Showing
1 changed file
with
73 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,73 @@ | ||
using System.Threading.Tasks; | ||
|
||
using GenHTTP.Api.Content.IO; | ||
using GenHTTP.Api.Routing; | ||
|
||
using GenHTTP.Modules.IO; | ||
|
||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace GenHTTP.Testing.Acceptance.Modules.IO | ||
{ | ||
|
||
[TestClass] | ||
public sealed class VirtualTreeTests | ||
{ | ||
|
||
[TestMethod] | ||
public async Task TestNestedTree() | ||
{ | ||
var tree = ResourceTree.FromAssembly("Resources"); | ||
|
||
var virt = VirtualTree.Create() | ||
.Add("r", tree) | ||
.Build(); | ||
|
||
var (node, file) = await virt.Find(GetTarget("/r/File.txt")); | ||
|
||
Assert.IsNotNull(node); | ||
Assert.IsNotNull(file); | ||
|
||
Assert.IsTrue((node as IResourceNode)?.Parent == virt); | ||
|
||
Assert.IsNotNull(virt.Modified); | ||
} | ||
|
||
[TestMethod] | ||
public async Task TestResource() | ||
{ | ||
var virt = VirtualTree.Create() | ||
.Add("res.txt", Resource.FromString("Blubb")) | ||
.Build(); | ||
|
||
var (node, file) = await virt.Find(GetTarget("/res.txt")); | ||
|
||
Assert.IsNotNull(node); | ||
Assert.IsNotNull(file); | ||
} | ||
|
||
private static RoutingTarget GetTarget(string path) => new(new PathBuilder(path).Build()); | ||
|
||
} | ||
|
||
} | ||
using System.Net; | ||
using System.Threading.Tasks; | ||
|
||
using GenHTTP.Api.Content.IO; | ||
using GenHTTP.Api.Routing; | ||
|
||
using GenHTTP.Modules.DirectoryBrowsing; | ||
using GenHTTP.Modules.IO; | ||
|
||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace GenHTTP.Testing.Acceptance.Modules.IO | ||
{ | ||
|
||
[TestClass] | ||
public sealed class VirtualTreeTests | ||
{ | ||
|
||
[TestMethod] | ||
public async Task TestNestedTree() | ||
{ | ||
var tree = ResourceTree.FromAssembly("Resources"); | ||
|
||
var virt = VirtualTree.Create() | ||
.Add("r", tree) | ||
.Build(); | ||
|
||
var (node, file) = await virt.Find(GetTarget("/r/File.txt")); | ||
|
||
Assert.IsNotNull(node); | ||
Assert.IsNotNull(file); | ||
|
||
Assert.IsTrue((node as IResourceNode)?.Parent == virt); | ||
|
||
Assert.IsNotNull(virt.Modified); | ||
} | ||
|
||
[TestMethod] | ||
public async Task TestResource() | ||
{ | ||
var virt = VirtualTree.Create() | ||
.Add("res.txt", Resource.FromString("Blubb")) | ||
.Build(); | ||
|
||
var (node, file) = await virt.Find(GetTarget("/res.txt")); | ||
|
||
Assert.IsNotNull(node); | ||
Assert.IsNotNull(file); | ||
} | ||
|
||
[TestMethod] | ||
public async Task TestUsage() | ||
{ | ||
var tree = ResourceTree.FromAssembly("Resources"); | ||
|
||
var virt = VirtualTree.Create() | ||
.Add("r", tree) | ||
.Add("res.txt", Resource.FromString("Blubb")); | ||
|
||
var handler = Listing.From(virt); | ||
|
||
using var host = TestHost.Run(handler); | ||
|
||
using var response = await host.GetResponseAsync(); | ||
|
||
await response.AssertStatusAsync(HttpStatusCode.OK); | ||
} | ||
|
||
private static RoutingTarget GetTarget(string path) => new(new PathBuilder(path).Build()); | ||
|
||
} | ||
|
||
} |