Re-organize in-memory character profile storage.

Now uses a dictionary of int -> profile instead of an array filled with nulls.
This commit is contained in:
Pieter-Jan Briers
2020-10-06 15:13:16 +02:00
parent 0b1fd94dc9
commit 390d064304
12 changed files with 228 additions and 204 deletions

View File

@@ -68,7 +68,7 @@ namespace Content.Tests.Server.Preferences
var originalProfile = CharlieCharlieson();
await db.InitPrefsAsync(username, originalProfile);
var prefs = await db.GetPlayerPreferencesAsync(username);
Assert.That(prefs.Characters.ElementAt(slot).MemberwiseEquals(originalProfile));
Assert.That(prefs.Characters.Single(p => p.Key == slot).Value.MemberwiseEquals(originalProfile));
}
[Test]
@@ -81,7 +81,7 @@ namespace Content.Tests.Server.Preferences
await db.SaveSelectedCharacterIndexAsync(username, 1);
await db.SaveCharacterSlotAsync(username, null, 1);
var prefs = await db.GetPlayerPreferencesAsync(username);
Assert.That(prefs.Characters.Skip(1).All(character => character is null));
Assert.That(!prefs.Characters.Any(p => p.Key != 0));
}
private static NetUserId NewUserId()