mirror of
https://github.com/AlexMacocian/MTSC.git
synced 2026-07-25 08:22:17 +00:00
Created unit test project for MTSC
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using MTSC.Common.Http.ServerModules;
|
||||
using MTSC.Exceptions;
|
||||
using MTSC.Logging;
|
||||
using MTSC.Server;
|
||||
using MTSC.Server.Handlers;
|
||||
using MTSC.Server.UsageMonitors;
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace MTSC.UnitTests
|
||||
{
|
||||
[TestClass]
|
||||
public class E2ETests
|
||||
{
|
||||
public TestContext TestContext { get; set; }
|
||||
static Server.Server Server { get; set; }
|
||||
|
||||
[ClassInitialize]
|
||||
public static void InitializeServer(TestContext testContext)
|
||||
{
|
||||
Server = new Server.Server(800)
|
||||
.AddHandler(new HttpHandler()
|
||||
.AddHttpModule(new HelloWorldModule())
|
||||
)
|
||||
.AddLogger(new ConsoleLogger())
|
||||
.AddLogger(new DebugConsoleLogger())
|
||||
.AddExceptionHandler(new ExceptionConsoleLogger())
|
||||
.AddServerUsageMonitor(new TickrateEnforcer().SetTicksPerSecond(60));
|
||||
Server.RunAsync().Start();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestMethod1()
|
||||
{
|
||||
HttpClient httpClient = new HttpClient();
|
||||
httpClient.BaseAddress = new Uri("http://localhost:800");
|
||||
var result = httpClient.GetAsync("").Result;
|
||||
Assert.AreEqual(result.StatusCode, System.Net.HttpStatusCode.OK);
|
||||
}
|
||||
|
||||
[ClassCleanup]
|
||||
public static void CleanupServer()
|
||||
{
|
||||
Server.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
|
||||
<PackageReference Include="coverlet.collector" Version="1.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\MTSC\MTSC.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user