* Completely refactor how job spawning works * Remove remains of old system. * Squash the final bug, cleanup. * Attempt to fix tests * Adjusts packed's round-start crew roster, re-enables a bunch of old roles. Also adds the Central Command Official as a proper role. * pretty up ui * refactor StationSystem into the correct folder & namespace. * remove a log, make sure the lobby gets updated if a new map is spontaneously added. * re-add accidentally removed log * We do a little logging * we do a little resolving * we do a little documenting * Renamed OverflowJob to FallbackOverflowJob Allows stations to configure their own roundstart overflow job list. * narrator: it did not compile * oops * support having no overflow jobs * filescope for consistency * small fixes * Bumps a few role counts for Packed, namely engis * log moment * E * Update Resources/Prototypes/Entities/Objects/Misc/identification_cards.yml Co-authored-by: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> * Update Content.Server/Maps/GameMapPrototype.cs Co-authored-by: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> * factored job logic, cleanup. * e * Address reviews * Remove the concept of a "default" grid. It has no future in our new multi-station world * why was clickable using that in the first place * fix bad evil bug that almost slipped through also adds chemist * rms obsolete things from chemist * Adds a sanity fallback * address reviews * adds ability to set name * fuck * cleanup joingame
119 lines
3.8 KiB
C#
119 lines
3.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Content.Server.Database;
|
|
using Content.Shared.CharacterAppearance;
|
|
using Content.Shared.GameTicking;
|
|
using Content.Shared.Preferences;
|
|
using Microsoft.Data.Sqlite;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using NUnit.Framework;
|
|
using Robust.Shared.Enums;
|
|
using Robust.Shared.IoC;
|
|
using Robust.Shared.Maths;
|
|
using Robust.Shared.Network;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Serialization.Manager;
|
|
|
|
namespace Content.Tests.Server.Preferences
|
|
{
|
|
[TestFixture]
|
|
public class ServerDbSqliteTests : ContentUnitTest
|
|
{
|
|
private const string Prototypes = @"
|
|
- type: dataset
|
|
id: names_first_male
|
|
values:
|
|
- Aaden
|
|
|
|
- type: dataset
|
|
id: names_first_female
|
|
values:
|
|
- Aaliyah
|
|
|
|
- type: dataset
|
|
id: names_last
|
|
values:
|
|
- Ackerley";
|
|
|
|
private static HumanoidCharacterProfile CharlieCharlieson()
|
|
{
|
|
return new(
|
|
"Charlie Charlieson",
|
|
21,
|
|
Sex.Male,
|
|
Gender.Epicene,
|
|
new HumanoidCharacterAppearance(
|
|
"Afro",
|
|
Color.Aqua,
|
|
"Shaved",
|
|
Color.Aquamarine,
|
|
Color.Azure,
|
|
Color.Beige
|
|
),
|
|
ClothingPreference.Jumpskirt,
|
|
BackpackPreference.Backpack,
|
|
new Dictionary<string, JobPriority>
|
|
{
|
|
{SharedGameTicker.FallbackOverflowJob, JobPriority.High}
|
|
},
|
|
PreferenceUnavailableMode.StayInLobby,
|
|
new List<string> ()
|
|
);
|
|
}
|
|
|
|
private static ServerDbSqlite GetDb()
|
|
{
|
|
var builder = new DbContextOptionsBuilder<ServerDbContext>();
|
|
var conn = new SqliteConnection("Data Source=:memory:");
|
|
conn.Open();
|
|
builder.UseSqlite(conn);
|
|
return new ServerDbSqlite(builder.Options);
|
|
}
|
|
|
|
[Test]
|
|
public async Task TestUserDoesNotExist()
|
|
{
|
|
var db = GetDb();
|
|
// Database should be empty so a new GUID should do it.
|
|
Assert.Null(await db.GetPlayerPreferencesAsync(NewUserId()));
|
|
}
|
|
|
|
[Test]
|
|
public async Task TestInitPrefs()
|
|
{
|
|
var db = GetDb();
|
|
var username = new NetUserId(new Guid("640bd619-fc8d-4fe2-bf3c-4a5fb17d6ddd"));
|
|
const int slot = 0;
|
|
var originalProfile = CharlieCharlieson();
|
|
await db.InitPrefsAsync(username, originalProfile);
|
|
var prefs = await db.GetPlayerPreferencesAsync(username);
|
|
Assert.That(prefs.Characters.Single(p => p.Key == slot).Value.MemberwiseEquals(originalProfile));
|
|
}
|
|
|
|
[Test]
|
|
public async Task TestDeleteCharacter()
|
|
{
|
|
var db = GetDb();
|
|
var username = new NetUserId(new Guid("640bd619-fc8d-4fe2-bf3c-4a5fb17d6ddd"));
|
|
IoCManager.Resolve<ISerializationManager>().Initialize();
|
|
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
|
prototypeManager.Initialize();
|
|
prototypeManager.LoadFromStream(new StringReader(Prototypes));
|
|
await db.InitPrefsAsync(username, HumanoidCharacterProfile.Default());
|
|
await db.SaveCharacterSlotAsync(username, CharlieCharlieson(), 1);
|
|
await db.SaveSelectedCharacterIndexAsync(username, 1);
|
|
await db.SaveCharacterSlotAsync(username, null, 1);
|
|
var prefs = await db.GetPlayerPreferencesAsync(username);
|
|
Assert.That(!prefs.Characters.Any(p => p.Key != 0));
|
|
}
|
|
|
|
private static NetUserId NewUserId()
|
|
{
|
|
return new(Guid.NewGuid());
|
|
}
|
|
}
|
|
}
|