public void TestCustomDirectory() { using (HeadlessGameHost host = new TestRunHeadlessGameHost(nameof(TestCustomDirectory), null)) // don't use clean run as we are writing a config file. { string osuDesktopStorage = Path.Combine(host.UserStoragePaths.First(), nameof(TestCustomDirectory)); 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); using (var storageConfig = new TournamentStorageManager(storage)) storageConfig.SetValue(StorageConfig.CurrentTournament, custom_tournament); try { var osu = LoadTournament(host); storage = osu.Dependencies.Get <Storage>(); Assert.That(storage.GetFullPath("."), Is.EqualTo(Path.Combine(host.Storage.GetFullPath("."), "tournaments", custom_tournament))); } finally { host.Exit(); } } }
public void TestCustomDirectory() { using (var host = new HeadlessGameHost(nameof(TestCustomDirectory))) { string defaultStorageLocation = Path.Combine(RuntimeInfo.StartupDirectory, "headless", nameof(TestCustomDirectory)); // need access before the game has constructed its own storage yet. Storage storage = new DesktopStorage(defaultStorageLocation, host); // manual cleaning so we can prepare a config file. storage.DeleteDirectory(string.Empty); using (var storageConfig = new StorageConfigManager(storage)) storageConfig.Set(StorageConfig.FullPath, customPath); try { var osu = loadOsu(host); // switch to DI'd storage storage = osu.Dependencies.Get <Storage>(); Assert.That(storage.GetFullPath("."), Is.EqualTo(customPath)); } finally { host.Exit(); } } }
public void TestRelativePaths() { var guid = new Guid().ToString(); var storage = new DesktopStorage(guid, null); var basePath = storage.GetFullPath(string.Empty); Assert.IsTrue(basePath.EndsWith(guid)); Assert.Throws <ArgumentException>(() => storage.GetFullPath("../")); Assert.Throws <ArgumentException>(() => storage.GetFullPath("..")); Assert.Throws <ArgumentException>(() => storage.GetFullPath("./../")); Assert.AreEqual(Path.GetFullPath(Path.Combine(basePath, "sub", "test")) + Path.DirectorySeparatorChar, storage.GetFullPath("sub/test/")); Assert.AreEqual(Path.GetFullPath(Path.Combine(basePath, "sub", "test")), storage.GetFullPath("sub/test")); storage.DeleteDirectory(string.Empty); }
public void TestSubDirectoryLookup() { using (var host = new HeadlessGameHost(nameof(TestSubDirectoryLookup))) { string defaultStorageLocation = Path.Combine(RuntimeInfo.StartupDirectory, "headless", nameof(TestSubDirectoryLookup)); // need access before the game has constructed its own storage yet. Storage storage = new DesktopStorage(defaultStorageLocation, host); // manual cleaning so we can prepare a config file. storage.DeleteDirectory(string.Empty); using (var storageConfig = new StorageConfigManager(storage)) storageConfig.Set(StorageConfig.FullPath, customPath); try { var osu = loadOsu(host); // switch to DI'd storage storage = osu.Dependencies.Get <Storage>(); string actualTestFile = Path.Combine(customPath, "rulesets", "test"); File.WriteAllText(actualTestFile, "test"); var rulesetStorage = storage.GetStorageForDirectory("rulesets"); var lookupPath = rulesetStorage.GetFiles(".").Single(); Assert.That(lookupPath, Is.EqualTo("test")); } finally { host.Exit(); } } }