public void TestSongsSubdirectories() { using (var storage = new TemporaryNativeStorage("stable-songs-folder")) { var songsStorage = storage.GetStorageForDirectory(StableStorage.STABLE_DEFAULT_SONGS_PATH); // normal beatmap folder var beatmap1 = songsStorage.GetStorageForDirectory("beatmap1"); createFile(beatmap1, "beatmap.osu"); // songs subdirectory var subdirectory = songsStorage.GetStorageForDirectory("subdirectory"); createFile(subdirectory, Path.Combine("beatmap2", "beatmap.osu")); createFile(subdirectory, Path.Combine("beatmap3", "beatmap.osu")); createFile(subdirectory, Path.Combine("sub-subdirectory", "beatmap4", "beatmap.osu")); // songs subdirectory with system file var subdirectory2 = songsStorage.GetStorageForDirectory("subdirectory2"); createFile(subdirectory2, ".DS_Store"); createFile(subdirectory2, Path.Combine("beatmap5", "beatmap.osu")); createFile(subdirectory2, Path.Combine("beatmap6", "beatmap.osu")); // empty songs subdirectory songsStorage.GetStorageForDirectory("subdirectory3"); string[] paths = importer.GetStableImportPaths(songsStorage).ToArray(); Assert.That(paths.Length, Is.EqualTo(6)); Assert.That(paths.Contains(songsStorage.GetFullPath("beatmap1"))); Assert.That(paths.Contains(songsStorage.GetFullPath(Path.Combine("subdirectory", "beatmap2")))); Assert.That(paths.Contains(songsStorage.GetFullPath(Path.Combine("subdirectory", "beatmap3")))); Assert.That(paths.Contains(songsStorage.GetFullPath(Path.Combine("subdirectory", "sub-subdirectory", "beatmap4")))); Assert.That(paths.Contains(songsStorage.GetFullPath(Path.Combine("subdirectory2", "beatmap5")))); Assert.That(paths.Contains(songsStorage.GetFullPath(Path.Combine("subdirectory2", "beatmap6")))); }
public void TestGetEmptySubDirectoryStorage() { string guid = Guid.NewGuid().ToString(); using (var storage = new TemporaryNativeStorage(guid)) { Assert.That(storage.GetStorageForDirectory(string.Empty).GetFullPath(string.Empty), Is.EqualTo(storage.GetFullPath(string.Empty))); } }
public void TestGetSubDirectoryStorage() { var guid = new Guid().ToString(); using (var storage = new TemporaryNativeStorage(guid)) { Assert.That(storage.GetStorageForDirectory("subdir").GetFullPath(string.Empty), Is.EqualTo(Path.Combine(storage.GetFullPath(string.Empty), "subdir"))); } }
public void TestAttemptEscapeRoot() { var guid = new Guid().ToString(); using (var storage = new TemporaryNativeStorage(guid)) { Assert.Throws <ArgumentException>(() => storage.GetStream("../test")); Assert.Throws <ArgumentException>(() => storage.GetStorageForDirectory("../")); } }
protected void RunTestWithRealm(Action <RealmContextFactory, Storage> testAction, [CallerMemberName] string caller = "") { using (HeadlessGameHost host = new CleanRunHeadlessGameHost(caller)) { host.Run(new RealmTestGame(() => { var testStorage = storage.GetStorageForDirectory(caller); using (var realmFactory = new RealmContextFactory(testStorage, caller)) { Logger.Log($"Running test using realm file {testStorage.GetFullPath(realmFactory.Filename)}"); testAction(realmFactory, testStorage); realmFactory.Dispose(); Logger.Log($"Final database size: {getFileSize(testStorage, realmFactory)}"); realmFactory.Compact(); Logger.Log($"Final database size after compact: {getFileSize(testStorage, realmFactory)}"); } })); } }
protected void RunTestWithRealm(Action <RealmContextFactory, OsuStorage> testAction, [CallerMemberName] string caller = "") { using (HeadlessGameHost host = new CleanRunHeadlessGameHost(callingMethodName: caller)) { host.Run(new RealmTestGame(() => { // ReSharper disable once AccessToDisposedClosure var testStorage = new OsuStorage(host, storage.GetStorageForDirectory(caller)); using (var realmFactory = new RealmContextFactory(testStorage, "client")) { Logger.Log($"Running test using realm file {testStorage.GetFullPath(realmFactory.Filename)}"); testAction(realmFactory, testStorage); realmFactory.Dispose(); Logger.Log($"Final database size: {getFileSize(testStorage, realmFactory)}"); realmFactory.Compact(); Logger.Log($"Final database size after compact: {getFileSize(testStorage, realmFactory)}"); } })); } }