Skip to content

Commit

Permalink
Move test classes to match project structure (#566)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaliumhexacyanoferrat authored Nov 26, 2024
1 parent d5119bc commit 4594d5c
Show file tree
Hide file tree
Showing 22 changed files with 74 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using GenHTTP.Modules.Layouting;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace GenHTTP.Testing.Acceptance.Modules;
namespace GenHTTP.Testing.Acceptance.Modules.Basics;

[TestClass]
public sealed class RedirectTests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using GenHTTP.Testing.Acceptance.Utilities;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace GenHTTP.Testing.Acceptance.Modules;
namespace GenHTTP.Testing.Acceptance.Modules.ClientCaching;

[TestClass]
public sealed class CacheValidationTests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using GenHTTP.Modules.IO;
using GenHTTP.Modules.Layouting;

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace GenHTTP.Testing.Acceptance.Engine;
namespace GenHTTP.Testing.Acceptance.Modules.ClientCaching;

[TestClass]
public class ChecksumTests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using GenHTTP.Testing.Acceptance.Utilities;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace GenHTTP.Testing.Acceptance.Engine;
namespace GenHTTP.Testing.Acceptance.Modules.Compression;

[TestClass]
public sealed class CompressionTests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using GenHTTP.Modules.Conversion.Serializers.Forms;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace GenHTTP.Testing.Acceptance.Modules;
namespace GenHTTP.Testing.Acceptance.Modules.Conversion;

[TestClass]
public sealed class ConversionTests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using GenHTTP.Testing.Acceptance.Utilities;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace GenHTTP.Testing.Acceptance.Modules;
namespace GenHTTP.Testing.Acceptance.Modules.DirectoryBrowsing;

[TestClass]
public sealed class ListingTests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using GenHTTP.Testing.Acceptance.Utilities;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace GenHTTP.Testing.Acceptance.Engine;
namespace GenHTTP.Testing.Acceptance.Modules.ErrorHandling;

[TestClass]
public sealed class ErrorHandlingTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using GenHTTP.Modules.Layouting;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace GenHTTP.Testing.Acceptance.Modules;
namespace GenHTTP.Testing.Acceptance.Modules.Layouting;

[TestClass]
public sealed class LayoutTests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using GenHTTP.Modules.Layouting;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace GenHTTP.Testing.Acceptance.Engine;
namespace GenHTTP.Testing.Acceptance.Modules.Layouting;

[TestClass]
public sealed class RoutingTests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using GenHTTP.Modules.LoadBalancing;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace GenHTTP.Testing.Acceptance.Modules;
namespace GenHTTP.Testing.Acceptance.Modules.LoadBalancing;

[TestClass]
public sealed class LoadBalancerTests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using ProtoBuf;

namespace GenHTTP.Testing.Acceptance.Modules;
namespace GenHTTP.Testing.Acceptance.Modules.Protobuf;

[TestClass]
public sealed class ProtobufTests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using GenHTTP.Modules.Reflection;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace GenHTTP.Testing.Acceptance.Modules;
namespace GenHTTP.Testing.Acceptance.Modules.Reflection;

[TestClass]
public sealed class ContentTests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Cookie = GenHTTP.Api.Protocol.Cookie;

namespace GenHTTP.Testing.Acceptance.Modules;
namespace GenHTTP.Testing.Acceptance.Modules.ReverseProxy;

[TestClass]
public sealed class ReverseProxyTests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using GenHTTP.Testing.Acceptance.Utilities;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace GenHTTP.Testing.Acceptance.Modules;
namespace GenHTTP.Testing.Acceptance.Modules.SinglePageApplications;

[TestClass]
public sealed class SinglePageTests
Expand Down Expand Up @@ -91,6 +91,14 @@ public async Task TestNoFile(TestEngine engine)
await index.AssertStatusAsync(HttpStatusCode.NotFound);
}

[TestMethod]
public void TestConcernChaining()
{
var app = SinglePageApplication.From(ResourceTree.FromDirectory(CreateRoot()));

Chain.Works(app);
}

private static string CreateRoot()
{
var tempDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
Expand Down
10 changes: 10 additions & 0 deletions Testing/Acceptance/Modules/StaticWebsites/StaticWebsiteTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Net;
using GenHTTP.Modules.IO;
using GenHTTP.Modules.StaticWebsites;
using GenHTTP.Testing.Acceptance.Utilities;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace GenHTTP.Testing.Acceptance.Modules.StaticWebsites;
Expand Down Expand Up @@ -41,4 +42,13 @@ public async Task TestNoIndex(TestEngine engine)
using var subIndexResponse = await runner.GetResponseAsync("/sub/");
await subIndexResponse.AssertStatusAsync(HttpStatusCode.NotFound);
}

[TestMethod]
public void TestConcernChaining()
{
var site = StaticWebsite.From(VirtualTree.Create());

Chain.Works(site);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
using GenHTTP.Modules.IO;
using GenHTTP.Modules.Layouting;
using GenHTTP.Modules.VirtualHosting;
using GenHTTP.Testing.Acceptance.Utilities;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace GenHTTP.Testing.Acceptance.Modules;
namespace GenHTTP.Testing.Acceptance.Modules.VirtualHosting;

[TestClass]
public sealed class VirtualHostsTests
Expand Down Expand Up @@ -46,6 +47,12 @@ public async Task TestNoDefault(TestEngine engine)
await response.AssertStatusAsync(HttpStatusCode.NotFound);
}

[TestMethod]
public void TestConcernChaining()
{
Chain.Works(VirtualHosts.Create());
}

private static async Task RunTest(TestHost runner, string host, string? expected = null)
{
var request = runner.GetRequest();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
using GenHTTP.Modules.Layouting;
using GenHTTP.Modules.Reflection;
using GenHTTP.Modules.Webservices;
using GenHTTP.Testing.Acceptance.Utilities;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;

namespace GenHTTP.Testing.Acceptance.Modules;
namespace GenHTTP.Testing.Acceptance.Modules.Webservices;

[TestClass]
public sealed class WebserviceTests
Expand Down Expand Up @@ -301,6 +302,14 @@ public async Task TestWithInstance(TestEngine engine)
await response.AssertStatusAsync(HttpStatusCode.NoContent);
}

[TestMethod]
public void TestConcernChaining()
{
var service = ServiceResource.From<TestResource>();

Chain.Works(service);
}

#endregion

#region Helpers
Expand Down
5 changes: 4 additions & 1 deletion Testing/Acceptance/Modules/Websockets/IntegrationTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using WS = GenHTTP.Modules.Websockets;
using GenHTTP.Testing.Acceptance.Utilities;
using WS = GenHTTP.Modules.Websockets;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Websocket.Client;

Expand All @@ -23,6 +24,8 @@ public async Task TestServer()
socket.Close();
});

Chain.Works(server);

await using var host = await TestHost.RunAsync(server);

using var client = new WebsocketClient(new Uri("ws://localhost:" + host.Port));
Expand Down
5 changes: 5 additions & 0 deletions Testing/Acceptance/MultiEngineTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

namespace GenHTTP.Testing.Acceptance;

/// <summary>
/// When attributed on a test method, this attribute
/// injects the engines that are target to be tested
/// into the test method.
/// </summary>
[AttributeUsage(AttributeTargets.Method)]
public class MultiEngineTestAttribute : Attribute, ITestDataSource
{
Expand Down
1 change: 1 addition & 0 deletions Testing/Testing/ContentExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,5 @@ public static class ContentExtensions

return (T?)await format.DeserializeAsync(body, typeof(T));
}

}
1 change: 1 addition & 0 deletions Testing/Testing/HeaderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ public static class HeaderExtensions

return null;
}

}
13 changes: 13 additions & 0 deletions Testing/Testing/TestEngine.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
namespace GenHTTP.Testing;

/// <summary>
/// Specifies the engine the test host should
/// use to host a web server process.
/// </summary>
public enum TestEngine
{

/// <summary>
/// The built-in GenHTTP server engine.
/// </summary>
Internal,

/// <summary>
/// Microsoft Kestrel.
/// </summary>
Kestrel

}

0 comments on commit 4594d5c

Please sign in to comment.