Update some other missed incorrect null/empty usages

This commit is contained in:
Dean Herbert 2021-11-04 14:50:39 +09:00
parent 1e73b09e57
commit d1e6d1cb98
7 changed files with 14 additions and 14 deletions

View File

@ -53,7 +53,7 @@ public void Setup()
public void TestMissing()
{
// While this is a problem, it is out of scope for this check and is caught by a different one.
beatmap.Metadata.BackgroundFile = null;
beatmap.Metadata.BackgroundFile = string.Empty;
var context = getContext(null, System.Array.Empty<byte>());
Assert.That(check.Run(context), Is.Empty);

View File

@ -65,7 +65,7 @@ public void TestBackgroundSetAndNotInFiles()
[Test]
public void TestBackgroundNotSet()
{
beatmap.Metadata.BackgroundFile = null;
beatmap.Metadata.BackgroundFile = string.Empty;
var context = new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
var issues = check.Run(context).ToList();

View File

@ -189,7 +189,7 @@ public void TestCriteriaMatchingArtist(string artistName, bool filtered)
public void TestCriteriaMatchingArtistWithNullUnicodeName(string artistName, bool filtered)
{
var exampleBeatmapInfo = getExampleBeatmap();
exampleBeatmapInfo.Metadata.ArtistUnicode = null;
exampleBeatmapInfo.Metadata.ArtistUnicode = string.Empty;
var criteria = new FilterCriteria
{

View File

@ -23,10 +23,10 @@ public void TestMinimalMetadata()
AddStep("set metadata", () =>
{
editorBeatmap.Metadata.Artist = "Example Artist";
editorBeatmap.Metadata.ArtistUnicode = null;
editorBeatmap.Metadata.ArtistUnicode = string.Empty;
editorBeatmap.Metadata.Title = "Example Title";
editorBeatmap.Metadata.TitleUnicode = null;
editorBeatmap.Metadata.TitleUnicode = string.Empty;
});
createSection();
@ -44,10 +44,10 @@ public void TestInitialisationFromNonRomanisedVariant()
AddStep("set metadata", () =>
{
editorBeatmap.Metadata.ArtistUnicode = "*なみりん";
editorBeatmap.Metadata.Artist = null;
editorBeatmap.Metadata.Artist = string.Empty;
editorBeatmap.Metadata.TitleUnicode = "コイシテイク・プラネット";
editorBeatmap.Metadata.Title = null;
editorBeatmap.Metadata.Title = string.Empty;
});
createSection();
@ -86,10 +86,10 @@ public void TestValueTransfer()
AddStep("set metadata", () =>
{
editorBeatmap.Metadata.ArtistUnicode = "*なみりん";
editorBeatmap.Metadata.Artist = null;
editorBeatmap.Metadata.Artist = string.Empty;
editorBeatmap.Metadata.TitleUnicode = "コイシテイク・プラネット";
editorBeatmap.Metadata.Title = null;
editorBeatmap.Metadata.Title = string.Empty;
});
createSection();

View File

@ -54,7 +54,7 @@ public TestSceneReplayRecording()
ScoreInfo = { BeatmapInfo = gameplayState.Beatmap.BeatmapInfo }
})
{
ScreenSpaceToGamefield = pos => recordingManager.ToLocalSpace(pos)
ScreenSpaceToGamefield = pos => recordingManager?.ToLocalSpace(pos) ?? Vector2.Zero,
},
Child = new Container
{
@ -84,7 +84,7 @@ public TestSceneReplayRecording()
{
ReplayInputHandler = new TestFramedReplayInputHandler(replay)
{
GamefieldToScreenSpace = pos => playbackManager.ToScreenSpace(pos),
GamefieldToScreenSpace = pos => playbackManager?.ToScreenSpace(pos) ?? Vector2.Zero,
},
Child = new Container
{

View File

@ -142,7 +142,7 @@ private void load(BeatmapManager manager, SongSelect songSelect)
},
new OsuSpriteText
{
Text = $"{(beatmapInfo.Metadata ?? beatmapInfo.BeatmapSet.Metadata).Author.Username}",
Text = $"{(beatmapInfo.Metadata ?? beatmapInfo.BeatmapSet.Metadata).Author?.Username ?? string.Empty}",
Font = OsuFont.GetFont(italics: true),
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft

View File

@ -77,8 +77,8 @@ public bool ReplacesBackground
{
get
{
string backgroundPath = BeatmapInfo.BeatmapSet?.Metadata?.BackgroundFile?.ToLowerInvariant();
if (backgroundPath == null)
string backgroundPath = BeatmapInfo.BeatmapSet?.Metadata?.BackgroundFile.ToLowerInvariant();
if (string.IsNullOrEmpty(backgroundPath))
return false;
return GetLayer("Background").Elements.Any(e => e.Path.ToLowerInvariant() == backgroundPath);