Give the placeholder ruleset better defaults to allow tests to work again

This commit is contained in:
Dean Herbert 2022-01-17 14:40:00 +09:00
parent a0e2106468
commit 381174e482
1 changed files with 10 additions and 8 deletions

View File

@ -51,7 +51,12 @@ public BeatmapInfo(RulesetInfo ruleset, BeatmapDifficulty difficulty, BeatmapMet
[UsedImplicitly]
public BeatmapInfo() // TODO: consider removing this and migrating all usages to ctor with parameters.
{
Ruleset = new RulesetInfo();
Ruleset = new RulesetInfo
{
OnlineID = 0,
ShortName = @"osu",
Name = @"null placeholder ruleset"
};
Difficulty = new BeatmapDifficulty();
Metadata = new BeatmapMetadata();
}
@ -149,20 +154,17 @@ public bool BackgroundEquals(BeatmapInfo? other) => other != null
#region Compatibility properties
private int rulesetID;
[Ignored]
[IgnoreMap]
public int RulesetID
{
// ReSharper disable once ConstantConditionalAccessQualifier
get => Ruleset?.OnlineID ?? rulesetID;
get => Ruleset.OnlineID;
set
{
if (Ruleset != null)
throw new InvalidOperationException($"Cannot set a {nameof(RulesetID)} when {nameof(Ruleset)} is non-null");
if (!string.IsNullOrEmpty(Ruleset.InstantiationInfo))
throw new InvalidOperationException($"Cannot set a {nameof(RulesetID)} when {nameof(Ruleset)} is already set to an actual ruleset.");
rulesetID = value;
Ruleset.OnlineID = value;
}
}