mirror of
https://github.com/JogmansonReal/Radicade.git
synced 2026-10-26 07:29:00 -07:00
40 lines
1.7 KiB
C#
40 lines
1.7 KiB
C#
using System.Reflection;
|
|
using System.Text.Json;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using RadicadeServer.API.Matchmaking;
|
|
using RadicadeServer.API.Moderation;
|
|
using RadicadeServer.DB;
|
|
using Xunit;
|
|
|
|
namespace RadicadeServer.Tests;
|
|
|
|
public class LoggedRouteCompatibilityTests
|
|
{
|
|
[Theory]
|
|
[InlineData("rooms/requiring/developer")]
|
|
[InlineData("rooms/requiring/rrplus")]
|
|
public void RestrictedRoomsHasStartupRouteAndReturnsEmptyArray(string route)
|
|
{
|
|
Assert.Equal("matchmaking", typeof(MatchmakingAPI).GetCustomAttribute<RouteAttribute>()!.Template);
|
|
var method = typeof(MatchmakingAPI).GetMethod(nameof(MatchmakingAPI.GetRestrictedRooms))!;
|
|
Assert.Contains(method.GetCustomAttributes<HttpGetAttribute>(), attribute => attribute.Template == route);
|
|
|
|
using var db = new RecDBContext(TestDbOptions.Create()
|
|
.UseInMemoryDatabase(Guid.NewGuid().ToString()).Options);
|
|
var result = Assert.IsType<OkObjectResult>(new MatchmakingAPI(db).GetRestrictedRooms());
|
|
var json = JsonSerializer.SerializeToElement(result.Value);
|
|
Assert.Equal(JsonValueKind.Array, json.ValueKind);
|
|
Assert.Equal(0, json.GetArrayLength());
|
|
}
|
|
|
|
[Fact]
|
|
public void SelectedCheerAcceptsLoggedClientRouteWithoutDuplicateCaseAliases()
|
|
{
|
|
var routes = typeof(ReputationAPI).GetMethod(nameof(ReputationAPI.SetSelectedCheer))!
|
|
.GetCustomAttributes<HttpPostAttribute>().Select(attribute => attribute.Template!).ToArray();
|
|
Assert.Contains("~/api/PlayerCheer/v1/SetSelectedCheer", routes);
|
|
Assert.Equal(routes.Length, routes.Distinct(StringComparer.OrdinalIgnoreCase).Count());
|
|
}
|
|
}
|