mirror of
https://github.com/JogmansonReal/Radicade.git
synced 2026-10-26 07:29:00 -07:00
Radicade Public Code
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using System.Text.Json;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using RadicadeServer.API.Config;
|
||||
using RadicadeServer.DB;
|
||||
using RadicadeServer.RecNet.Config;
|
||||
using Xunit;
|
||||
|
||||
namespace RadicadeServer.Tests;
|
||||
|
||||
public class SplitTestCompatibilityTests
|
||||
{
|
||||
[Fact]
|
||||
public void EveryForcedExperimentAndSegmentExistsInMarch2023Client()
|
||||
{
|
||||
var catalog = JsonSerializer.Deserialize<Dictionary<string, string[]>>(
|
||||
File.ReadAllText(Path.Combine(AppContext.BaseDirectory, "Fixtures", "split-tests-20230301.json")))!;
|
||||
using var db = new RecDBContext(TestDbOptions.Create()
|
||||
.UseInMemoryDatabase(Guid.NewGuid().ToString()).Options);
|
||||
db.GameConfig.Add(new ConfigVal("splitTestHardOverrides", SplitTestConfigs.HardOverrides));
|
||||
db.SaveChanges();
|
||||
var response = Assert.IsType<OkObjectResult>(new GameConfigAPI(db).GetAllGameConfigs());
|
||||
var configs = Assert.IsType<List<ConfigVal>>(response.Value);
|
||||
var overrides = configs.Single(x => x.Key == "splitTestHardOverrides").Value;
|
||||
// DB seeds hold the reference-era set, including experiments this client
|
||||
// lacks enums for; the API filters those out before responding.
|
||||
Assert.False(string.IsNullOrWhiteSpace(overrides));
|
||||
foreach (var entry in overrides.Split(';', StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
var pair = entry.Split('=', 2);
|
||||
Assert.Equal(2, pair.Length);
|
||||
Assert.True(catalog.ContainsKey(pair[0]), $"Unknown client experiment: {pair[0]}");
|
||||
Assert.Contains(pair[1], catalog[pair[0]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user