diff --git a/osu.Game.Tests/Models/DisplayStringTest.cs b/osu.Game.Tests/Models/DisplayStringTest.cs index 754a849ac8..cac5dd1aaa 100644 --- a/osu.Game.Tests/Models/DisplayStringTest.cs +++ b/osu.Game.Tests/Models/DisplayStringTest.cs @@ -15,23 +15,20 @@ namespace osu.Game.Tests.Models [TestFixture] public class DisplayStringTest { - private static readonly object[][] test_cases = + [Test] + public void TestBeatmapSet() { - new object[] { makeNoMetadataMockBeatmapSet(), "unknown artist - unknown title" }, - new object[] { makeNoAuthorMockBeatmapSet(), "artist - title" }, - new object[] { makeMockBeatmapSet(), "artist - title (author)" }, - new object[] { makeMockBeatmap(), "artist - title (author) [difficulty]" }, - new object[] { makeMockMetadata(), "artist - title (author)" }, - new object[] { makeMockScore(), "user playing artist - title (author) [difficulty]" }, - new object[] { makeMockRuleset(), "ruleset" }, - new object[] { makeMockUser(), "user" }, - new object[] { new Fallback(), "fallback" } - }; + var mock = new Mock(); - [TestCaseSource(nameof(test_cases))] - public void TestDisplayString(object model, string expected) => Assert.That(model.GetDisplayString(), Is.EqualTo(expected)); + mock.Setup(m => m.Metadata.Artist).Returns("artist"); + mock.Setup(m => m.Metadata.Title).Returns("title"); + mock.Setup(m => m.Metadata.Author.Username).Returns("author"); - private static IBeatmapSetInfo makeNoAuthorMockBeatmapSet() + Assert.That(mock.Object.GetDisplayString(), Is.EqualTo("artist - title (author)")); + } + + [Test] + public void TestBeatmapSetWithNoAuthor() { var mock = new Mock(); @@ -39,38 +36,34 @@ namespace osu.Game.Tests.Models mock.Setup(m => m.Metadata.Title).Returns("title"); mock.Setup(m => m.Metadata.Author.Username).Returns(string.Empty); - return mock.Object; + Assert.That(mock.Object.GetDisplayString(), Is.EqualTo("artist - title")); } - private static IBeatmapSetInfo makeNoMetadataMockBeatmapSet() + [Test] + public void TestBeatmapSetWithNoMetadata() { var mock = new Mock(); mock.Setup(m => m.Metadata).Returns(new BeatmapMetadata()); - return mock.Object; + Assert.That(mock.Object.GetDisplayString(), Is.EqualTo("unknown artist - unknown title")); } - private static IBeatmapSetInfo makeMockBeatmapSet() - { - var mock = new Mock(); - - mock.Setup(m => m.Metadata).Returns(makeMockMetadata); - - return mock.Object; - } - - private static IBeatmapInfo makeMockBeatmap() + [Test] + public void TestBeatmap() { var mock = new Mock(); - mock.Setup(m => m.Metadata).Returns(makeMockMetadata); + mock.Setup(m => m.Metadata.Artist).Returns("artist"); + mock.Setup(m => m.Metadata.Title).Returns("title"); + mock.Setup(m => m.Metadata.Author.Username).Returns("author"); mock.Setup(m => m.DifficultyName).Returns("difficulty"); - return mock.Object; + Assert.That(mock.Object.GetDisplayString(), Is.EqualTo("artist - title (author) [difficulty]")); } - private static IBeatmapMetadataInfo makeMockMetadata() + [Test] + public void TestMetadata() { var mock = new Mock(); @@ -78,35 +71,49 @@ namespace osu.Game.Tests.Models mock.Setup(m => m.Title).Returns("title"); mock.Setup(m => m.Author.Username).Returns("author"); - return mock.Object; + Assert.That(mock.Object.GetDisplayString(), Is.EqualTo("artist - title (author)")); } - private static IScoreInfo makeMockScore() + [Test] + public void TestScore() { var mock = new Mock(); mock.Setup(m => m.User).Returns(new APIUser { Username = "user" }); // TODO: temporary. - mock.Setup(m => m.Beatmap).Returns(makeMockBeatmap); + mock.Setup(m => m.Beatmap.Metadata.Artist).Returns("artist"); + mock.Setup(m => m.Beatmap.Metadata.Title).Returns("title"); + mock.Setup(m => m.Beatmap.Metadata.Author.Username).Returns("author"); + mock.Setup(m => m.Beatmap.DifficultyName).Returns("difficulty"); - return mock.Object; + Assert.That(mock.Object.GetDisplayString(), Is.EqualTo("user playing artist - title (author) [difficulty]")); } - private static IRulesetInfo makeMockRuleset() + [Test] + public void TestRuleset() { var mock = new Mock(); mock.Setup(m => m.Name).Returns("ruleset"); - return mock.Object; + Assert.That(mock.Object.GetDisplayString(), Is.EqualTo("ruleset")); } - private static IUser makeMockUser() + [Test] + public void TestUser() { var mock = new Mock(); mock.Setup(m => m.Username).Returns("user"); - return mock.Object; + Assert.That(mock.Object.GetDisplayString(), Is.EqualTo("user")); + } + + [Test] + public void TestFallback() + { + var fallback = new Fallback(); + + Assert.That(fallback.GetDisplayString(), Is.EqualTo("fallback")); } private class Fallback