Working on code and tests for a serve file extension to make developing a small web server easier.
This commit is contained in:
42
Rest.Net.Tests/ServeFileTests.cs
Normal file
42
Rest.Net.Tests/ServeFileTests.cs
Normal file
@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using FluentAssertions;
|
||||
using MontoyaTech.Rest.Net;
|
||||
using Xunit;
|
||||
|
||||
namespace Rest.Net.Tests
|
||||
{
|
||||
public class ServeFileTests
|
||||
{
|
||||
public string TestDirectory = null;
|
||||
|
||||
public string TestFile = null;
|
||||
|
||||
public ServeFileTests()
|
||||
{
|
||||
this.TestDirectory = Path.Combine(Environment.CurrentDirectory, "test/");
|
||||
|
||||
if (!Directory.Exists(this.TestDirectory))
|
||||
Directory.CreateDirectory(this.TestDirectory);
|
||||
|
||||
this.TestFile = Path.Combine(this.TestDirectory, "test.html");
|
||||
|
||||
if (!File.Exists(this.TestFile))
|
||||
File.WriteAllText(this.TestFile, "hello world");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ServeMultipleShouldWorkForFiles()
|
||||
{
|
||||
HttpListenerResponseExtensions.ResolveMultiPagePath(Path.Combine(Environment.CurrentDirectory, "test"), "../../test.html", null, out string resolvedPath, out bool isDirecotry).Should().BeTrue();
|
||||
|
||||
isDirecotry.Should().BeFalse();
|
||||
|
||||
resolvedPath.Should().BeEquivalentTo(this.TestFile);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user