<commit_before>// Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using Moq;
using NUnit.Framework;
using osu.Game.Beatmaps;
using osu.Game.Extensions;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Rulesets;
using osu.Game.Scoring;
using osu.Game.Users;

namespace osu.Game.Tests.Models
{
    [TestFixture]
    public class DisplayStringTest
    {
        private static readonly object[][] test_cases =
        {
            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" }
        };

        [TestCaseSource(nameof(test_cases))]
        public void TestDisplayString(object model, string expected) => Assert.That(model.GetDisplayString(), Is.EqualTo(expected));

        private static IBeatmapSetInfo makeNoAuthorMockBeatmapSet()
        {
            var mock = new Mock<IBeatmapSetInfo>();

            mock.Setup(m => m.Metadata.Artist).Returns("artist");
            mock.Setup(m => m.Metadata.Title).Returns("title");
            mock.Setup(m => m.Metadata.Author.Username).Returns(string.Empty);

            return mock.Object;
        }

        private static IBeatmapSetInfo makeNoMetadataMockBeatmapSet()
        {
            var mock = new Mock<IBeatmapSetInfo>();

            mock.Setup(m => m.Metadata).Returns(new BeatmapMetadata());

            return mock.Object;
        }

        private static IBeatmapSetInfo makeMockBeatmapSet()
        {
            var mock = new Mock<IBeatmapSetInfo>();

            mock.Setup(m => m.Metadata).Returns(makeMockMetadata);

            return mock.Object;
        }

        private static IBeatmapInfo makeMockBeatmap()
        {
            var mock = new Mock<IBeatmapInfo>();

            mock.Setup(m => m.Metadata).Returns(makeMockMetadata);
            mock.Setup(m => m.DifficultyName).Returns("difficulty");

            return mock.Object;
        }

        private static IBeatmapMetadataInfo makeMockMetadata()
        {
            var mock = new Mock<IBeatmapMetadataInfo>();

            mock.Setup(m => m.Artist).Returns("artist");
            mock.Setup(m => m.Title).Returns("title");
            mock.Setup(m => m.Author.Username).Returns("author");

            return mock.Object;
        }

        private static IScoreInfo makeMockScore()
        {
            var mock = new Mock<IScoreInfo>();

            mock.Setup(m => m.User).Returns(new APIUser { Username = "user" }); // TODO: temporary.
            mock.Setup(m => m.Beatmap).Returns(makeMockBeatmap);

            return mock.Object;
        }

        private static IRulesetInfo makeMockRuleset()
        {
            var mock = new Mock<IRulesetInfo>();

            mock.Setup(m => m.Name).Returns("ruleset");

            return mock.Object;
        }

        private static IUser makeMockUser()
        {
            var mock = new Mock<IUser>();

            mock.Setup(m => m.Username).Returns("user");

            return mock.Object;
        }

        private class Fallback
        {
            public override string ToString() => "fallback";
        }
    }
}
<commit_msg>Rewrite tests to be easier to follow<commit_after>// Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using Moq;
using NUnit.Framework;
using osu.Game.Beatmaps;
using osu.Game.Extensions;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Rulesets;
using osu.Game.Scoring;
using osu.Game.Users;

namespace osu.Game.Tests.Models
{
    [TestFixture]
    public class DisplayStringTest
    {
        [Test]
        public void TestBeatmapSet()
        {
            var mock = new Mock<IBeatmapSetInfo>();

            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");

            Assert.That(mock.Object.GetDisplayString(), Is.EqualTo("artist - title (author)"));
        }

        [Test]
        public void TestBeatmapSetWithNoAuthor()
        {
            var mock = new Mock<IBeatmapSetInfo>();

            mock.Setup(m => m.Metadata.Artist).Returns("artist");
            mock.Setup(m => m.Metadata.Title).Returns("title");
            mock.Setup(m => m.Metadata.Author.Username).Returns(string.Empty);

            Assert.That(mock.Object.GetDisplayString(), Is.EqualTo("artist - title"));
        }

        [Test]
        public void TestBeatmapSetWithNoMetadata()
        {
            var mock = new Mock<IBeatmapSetInfo>();

            mock.Setup(m => m.Metadata).Returns(new BeatmapMetadata());

            Assert.That(mock.Object.GetDisplayString(), Is.EqualTo("unknown artist - unknown title"));
        }

        [Test]
        public void TestBeatmap()
        {
            var mock = new Mock<IBeatmapInfo>();

            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");

            Assert.That(mock.Object.GetDisplayString(), Is.EqualTo("artist - title (author) [difficulty]"));
        }

        [Test]
        public void TestMetadata()
        {
            var mock = new Mock<IBeatmapMetadataInfo>();

            mock.Setup(m => m.Artist).Returns("artist");
            mock.Setup(m => m.Title).Returns("title");
            mock.Setup(m => m.Author.Username).Returns("author");

            Assert.That(mock.Object.GetDisplayString(), Is.EqualTo("artist - title (author)"));
        }

        [Test]
        public void TestScore()
        {
            var mock = new Mock<IScoreInfo>();

            mock.Setup(m => m.User).Returns(new APIUser { Username = "user" }); // TODO: temporary.
            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");

            Assert.That(mock.Object.GetDisplayString(), Is.EqualTo("user playing artist - title (author) [difficulty]"));
        }

        [Test]
        public void TestRuleset()
        {
            var mock = new Mock<IRulesetInfo>();

            mock.Setup(m => m.Name).Returns("ruleset");

            Assert.That(mock.Object.GetDisplayString(), Is.EqualTo("ruleset"));
        }

        [Test]
        public void TestUser()
        {
            var mock = new Mock<IUser>();

            mock.Setup(m => m.Username).Returns("user");

            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
        {
            public override string ToString() => "fallback";
        }
    }
}

{'fraction_non_alphanumeric': 0.13452914798206278, 'fraction_numerical': 0.0, 'mean_word_length': 2.1744611630744206, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7546738', 'n_tokens_mistral': 2241, 'n_tokens_neox': 2150, 'n_words': 449}