2023-06-23 00:37:25 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2020-06-11 19:57:29 +08:00
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
|
|
using System.IO;
|
2021-12-24 19:17:47 +08:00
|
|
|
|
using System.Linq;
|
2020-06-11 19:57:29 +08:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Platform;
|
2021-12-24 19:17:47 +08:00
|
|
|
|
using osu.Framework.Testing;
|
2020-06-11 19:57:29 +08:00
|
|
|
|
using osu.Game.Tests;
|
2021-07-30 00:53:08 +08:00
|
|
|
|
using osu.Game.Tournament.Configuration;
|
2020-06-11 19:57:29 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tournament.Tests.NonVisual
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2021-07-30 00:53:08 +08:00
|
|
|
|
public class CustomTourneyDirectoryTest : TournamentHostTest
|
2020-06-11 19:57:29 +08:00
|
|
|
|
{
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestDefaultDirectory()
|
|
|
|
|
{
|
2021-12-24 19:17:20 +08:00
|
|
|
|
using (HeadlessGameHost host = new CleanRunHeadlessGameHost())
|
2020-06-11 19:57:29 +08:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2021-07-30 00:53:08 +08:00
|
|
|
|
var osu = LoadTournament(host);
|
2020-06-24 08:37:59 +08:00
|
|
|
|
var storage = osu.Dependencies.Get<Storage>();
|
2020-10-19 14:34:46 +08:00
|
|
|
|
|
|
|
|
|
Assert.That(storage.GetFullPath("."), Is.EqualTo(Path.Combine(host.Storage.GetFullPath("."), "tournaments", "default")));
|
2020-06-11 19:57:29 +08:00
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
host.Exit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestCustomDirectory()
|
|
|
|
|
{
|
2022-10-28 23:24:33 +08:00
|
|
|
|
using (HeadlessGameHost host = new TestRunHeadlessGameHost(nameof(TestCustomDirectory))) // don't use clean run as we are writing a config file.
|
2020-06-11 19:57:29 +08:00
|
|
|
|
{
|
2021-12-24 19:17:47 +08:00
|
|
|
|
string osuDesktopStorage = Path.Combine(host.UserStoragePaths.First(), nameof(TestCustomDirectory));
|
2020-06-11 19:57:29 +08:00
|
|
|
|
const string custom_tournament = "custom";
|
|
|
|
|
|
|
|
|
|
// need access before the game has constructed its own storage yet.
|
|
|
|
|
Storage storage = new DesktopStorage(osuDesktopStorage, host);
|
|
|
|
|
// manual cleaning so we can prepare a config file.
|
|
|
|
|
storage.DeleteDirectory(string.Empty);
|
|
|
|
|
|
2022-10-28 12:00:39 +08:00
|
|
|
|
using (var storageConfig = new TournamentConfigManager(storage))
|
2021-03-17 15:10:16 +08:00
|
|
|
|
storageConfig.SetValue(StorageConfig.CurrentTournament, custom_tournament);
|
2020-06-11 19:57:29 +08:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2021-07-30 00:53:08 +08:00
|
|
|
|
var osu = LoadTournament(host);
|
2020-06-11 19:57:29 +08:00
|
|
|
|
|
2020-06-24 08:37:59 +08:00
|
|
|
|
storage = osu.Dependencies.Get<Storage>();
|
2020-06-11 19:57:29 +08:00
|
|
|
|
|
2020-10-19 14:34:46 +08:00
|
|
|
|
Assert.That(storage.GetFullPath("."), Is.EqualTo(Path.Combine(host.Storage.GetFullPath("."), "tournaments", custom_tournament)));
|
2020-06-11 19:57:29 +08:00
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
host.Exit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-06-11 21:52:14 +08:00
|
|
|
|
}
|