mirror of
https://github.com/JogmansonReal/Radicade.git
synced 2026-10-26 15:39:01 -07:00
Radicade Public Code
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user