Files
wwdpublic/Content.IntegrationTests/Tests/Preferences/ServerDbSqliteTests.cs
Spatison 2549ec061e [Feature] Body Types (#180)
* feature: body types

# Conflicts:
#	Content.Shared/Humanoid/Markings/MarkingManager.cs
#	Resources/Prototypes/Nyanotrasen/Species/Oni.yml
#	Resources/Prototypes/Nyanotrasen/Species/felinid.yml
#	Resources/Prototypes/Species/arachne.yml
#	Resources/Prototypes/Species/dwarf.yml
#	Resources/Prototypes/Species/harpy.yml
#	Resources/Prototypes/Species/human.yml
#	Resources/Prototypes/Species/ipc.yml
#	Resources/Textures/Clothing/OuterClothing/Armor/armor_reflec.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Armor/bulletproof.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Armor/cult_armour.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Armor/heavy.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Armor/heavygreen.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Armor/heavyred.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Armor/lingarmor.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Armor/magusblue.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Armor/magusred.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Armor/riot.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Armor/security.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Armor/security_slim.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Bio/virology.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Coats/bomber.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Coats/brigmedic.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Coats/detective.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Coats/gentlecoat.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Coats/jensencoat.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Coats/labcoat_gene.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Coats/labcoat_robo.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Coats/pirate.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Coats/windbreaker_paramedic.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/ERTSuits/ertengineer.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/ERTSuits/ertjanitor.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/ERTSuits/ertleader.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/ERTSuits/ertmedical.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/ERTSuits/ertsecurity.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/basic.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/capspace.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/cburn.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/cybersun.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/lingspacesuit.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/luxury.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/medical.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/paramed.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/rd.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/salvage.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/spatio.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/syndicate.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/syndiecommander.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/syndieelite.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/wizard.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Misc/apron.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Misc/apronbotanist.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Misc/apronchef.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Misc/cardborg.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Misc/chaplain_hoodie.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Misc/chef.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Misc/classicponcho.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Misc/cultrobes.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Misc/grey_hoodie.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Misc/judge.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Misc/plaguedoctorsuit.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Misc/redwizard.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Misc/santa.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Misc/skubbody.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Misc/straight_jacket.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Misc/violetwizard.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Misc/wizard.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Suits/atmos_firesuit.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Suits/bombsuit.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Suits/chicken.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Suits/fire.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Suits/monkey.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Suits/rad.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Suits/shrine-maiden.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Vests/mercwebvest.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Vests/vest.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Vests/webvest.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coat.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatatmos.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatbar.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatcap.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatcargo.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatce.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatcentcom.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatchef.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatchem.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatcmo.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatengi.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatgen.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coathop.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coathos.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coathydro.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatjani.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatmed.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatmime.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatminer.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatnomi.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatparamed.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatqm.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatrd.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatrobo.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatsci.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatsec.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatviro.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatwarden.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/WinterCoats/coatwardenarmored.rsi/meta.json

* feature: body types: 2

* add: loc

* fix: rsi validate

* tweak: displasment jumpsuit

* tweak: clean up

* tweak: displasment shoes

* tweak: displasment gloves

* tweak: clean up

* tweak: displasment outerClothing

* Revert "tweak: displasment outerClothing"

This reverts commit 698fd688591a6c00a4cd19eebac7a204dce18e98.

* fix

* fix

* fix

* fix

* tweak: dwarf, Oni and Felenid now can choose slim body type

* add: outer displacement

* some fix

* some fix

* no more tags shitcode

* Reptilian body type

* harpy body type

* some fix

* rsi validator fix

* Update ClientClothingSystem.cs

* Update Model.cs

* Update MarkingManager.cs

* Update ClientClothingSystem.cs

* Update reptilian.yml
2025-03-03 18:03:18 +02:00

130 lines
4.5 KiB
C#

using System.Collections.Generic;
using System.Linq;
using Content.Server.Database;
using Content.Shared.GameTicking;
using Content.Shared.Humanoid;
using Content.Shared.Humanoid.Markings;
using Content.Shared.Preferences;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Robust.Shared.Configuration;
using Robust.Shared.Enums;
using Robust.Shared.Log;
using Robust.Shared.Maths;
using Robust.Shared.Network;
using Robust.UnitTesting;
namespace Content.IntegrationTests.Tests.Preferences
{
[TestFixture]
public sealed class ServerDbSqliteTests
{
[TestPrototypes]
private const string Prototypes = @"
- type: dataset
id: sqlite_test_names_first_male
values:
- Aaden
- type: dataset
id: sqlite_test_names_first_female
values:
- Aaliyah
- type: dataset
id: sqlite_test_names_last
values:
- Ackerley";
private static HumanoidCharacterProfile CharlieCharlieson()
{
return new HumanoidCharacterProfile
{
Name = "Charlie Charlieson",
FlavorText = "The biggest boy around.",
Species = "Human",
Customspeciename = "",
Age = 21,
Voice = "Aidar", // WD EDIT
BodyType = "Normal", // WD EDIT
Appearance = new(
"Afro",
Color.Aqua,
"Shaved",
Color.Aquamarine,
Color.Azure,
Color.Beige,
new List<Marking>()),
};
}
private static ServerDbSqlite GetDb(RobustIntegrationTest.ServerIntegrationInstance server)
{
var cfg = server.ResolveDependency<IConfigurationManager>();
var opsLog = server.ResolveDependency<ILogManager>().GetSawmill("db.ops");
var builder = new DbContextOptionsBuilder<SqliteServerDbContext>();
var conn = new SqliteConnection("Data Source=:memory:");
conn.Open();
builder.UseSqlite(conn);
return new ServerDbSqlite(() => builder.Options, true, cfg, true, opsLog);
}
[Test]
public async Task TestUserDoesNotExist()
{
var pair = await PoolManager.GetServerClient();
var db = GetDb(pair.Server);
// Database should be empty so a new GUID should do it.
Assert.That(await db.GetPlayerPreferencesAsync(NewUserId()), Is.Null);
await pair.CleanReturnAsync();
}
[Test]
public async Task TestInitPrefs()
{
var pair = await PoolManager.GetServerClient();
var db = GetDb(pair.Server);
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));
await pair.CleanReturnAsync();
}
[Test]
public async Task TestDeleteCharacter()
{
var pair = await PoolManager.GetServerClient();
var server = pair.Server;
var db = GetDb(server);
var username = new NetUserId(new Guid("640bd619-fc8d-4fe2-bf3c-4a5fb17d6ddd"));
await db.InitPrefsAsync(username, new HumanoidCharacterProfile());
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));
await pair.CleanReturnAsync();
}
[Test]
public async Task TestNoPendingDatabaseChanges()
{
var pair = await PoolManager.GetServerClient();
var server = pair.Server;
var db = GetDb(server);
Assert.That(async () => await db.HasPendingModelChanges(), Is.False,
"The database has pending model changes. Add a new migration to apply them. See https://learn.microsoft.com/en-us/ef/core/managing-schemas/migrations");
await pair.CleanReturnAsync();
}
private static NetUserId NewUserId()
{
return new(Guid.NewGuid());
}
}
}