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