Use is class instead of Equals with template index

Ensures ordering of `PossibleTemplates` does not affect tests.
This commit is contained in:
Naxess 2021-04-13 02:29:25 +02:00
parent 0bcc39bd36
commit 6d3f9fa9ce
5 changed files with 16 additions and 12 deletions

View File

@ -246,18 +246,24 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor.Checks
assertOffscreenSlider(beatmap);
}
private void assertOneIssue(IBeatmap beatmap, int templateIndex)
private void assertOffscreenCircle(IBeatmap beatmap)
{
var issues = check.Run(beatmap).ToList();
var issue = issues.FirstOrDefault();
Assert.That(issues.Count == 1);
Assert.That(issue != null);
Assert.That(issue.Template.Equals(check.PossibleTemplates.ElementAt(templateIndex)));
Assert.That(issue.Template is CheckOffscreenObjects.IssueTemplateOffscreenCircle);
}
private void assertOffscreenCircle(IBeatmap beatmap) => assertOneIssue(beatmap, 0);
private void assertOffscreenSlider(IBeatmap beatmap)
{
var issues = check.Run(beatmap).ToList();
var issue = issues.FirstOrDefault();
private void assertOffscreenSlider(IBeatmap beatmap) => assertOneIssue(beatmap, 1);
Assert.That(issues.Count == 1);
Assert.That(issue != null);
Assert.That(issue.Template is CheckOffscreenObjects.IssueTemplateOffscreenSlider);
}
}
}

View File

@ -91,7 +91,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Checks
position.Y - radius < min_y || position.Y + radius > max_y;
}
private class IssueTemplateOffscreenCircle : IssueTemplate
public class IssueTemplateOffscreenCircle : IssueTemplate
{
public IssueTemplateOffscreenCircle(ICheck check)
: base(check, IssueType.Problem, "This circle goes offscreen on a 4:3 aspect ratio.")
@ -101,7 +101,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Checks
public Issue Create(HitCircle circle) => new Issue(circle, this);
}
private class IssueTemplateOffscreenSlider : IssueTemplate
public class IssueTemplateOffscreenSlider : IssueTemplate
{
public IssueTemplateOffscreenSlider(ICheck check)
: base(check, IssueType.Problem, "This slider goes offscreen here on a 4:3 aspect ratio.")

View File

@ -54,7 +54,7 @@ namespace osu.Game.Tests.Editing.Checks
Assert.That(issues.Count == 1);
Assert.That(issue != null);
Assert.That(issue.Template.Equals(check.PossibleTemplates.ElementAt(1)));
Assert.That(issue.Template is CheckBackground.IssueTemplateDoesNotExist);
}
[Test]
@ -67,7 +67,7 @@ namespace osu.Game.Tests.Editing.Checks
Assert.That(issues.Count == 1);
Assert.That(issue != null);
Assert.That(issue.Template.Equals(check.PossibleTemplates.ElementAt(0)));
Assert.That(issue.Template is CheckBackground.IssueTemplateNoneSet);
}
}
}

View File

@ -38,7 +38,7 @@ namespace osu.Game.Rulesets.Edit.Checks
yield return new IssueTemplateDoesNotExist(this).Create(beatmap.Metadata.BackgroundFile);
}
private class IssueTemplateNoneSet : IssueTemplate
public class IssueTemplateNoneSet : IssueTemplate
{
public IssueTemplateNoneSet(ICheck check)
: base(check, IssueType.Problem, "No background has been set")
@ -48,7 +48,7 @@ namespace osu.Game.Rulesets.Edit.Checks
public Issue Create() => new Issue(this);
}
private class IssueTemplateDoesNotExist : IssueTemplate
public class IssueTemplateDoesNotExist : IssueTemplate
{
public IssueTemplateDoesNotExist(ICheck check)
: base(check, IssueType.Problem, "The background file \"{0}\" does not exist.")

View File

@ -70,7 +70,5 @@ namespace osu.Game.Rulesets.Edit.Checks.Components
}
}
}
public bool Equals(IssueTemplate other) => other.Type == Type && other.UnformattedMessage == UnformattedMessage;
}
}