1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 11:37:28 +08:00

Add more edge case testing

This commit is contained in:
Dean Herbert 2020-05-09 20:13:37 +09:00
parent bbebd26efb
commit 5dda94187e

View File

@ -123,6 +123,56 @@ namespace osu.Game.Tests.NonVisual
}
}
[Test]
public void TestMigrationBetweenTwoTargets()
{
using (HeadlessGameHost host = new CleanRunHeadlessGameHost(nameof(TestMigrationBetweenTwoTargets)))
{
try
{
var osu = loadOsu(host);
var storage = osu.Dependencies.Get<Storage>();
string customPath2 = $"{customPath}-2";
const string database_filename = "client.db";
Assert.DoesNotThrow(() => (storage as OsuStorage)?.Migrate(customPath));
Assert.That(File.Exists(Path.Combine(customPath, database_filename)));
Assert.DoesNotThrow(() => (storage as OsuStorage)?.Migrate(customPath2));
Assert.That(File.Exists(Path.Combine(customPath2, database_filename)));
Assert.DoesNotThrow(() => (storage as OsuStorage)?.Migrate(customPath));
Assert.That(File.Exists(Path.Combine(customPath, database_filename)));
}
finally
{
host.Exit();
}
}
}
[Test]
public void TestMigrationToSameTargetFails()
{
using (HeadlessGameHost host = new CleanRunHeadlessGameHost(nameof(TestMigrationToSameTargetFails)))
{
try
{
var osu = loadOsu(host);
var storage = osu.Dependencies.Get<Storage>();
Assert.DoesNotThrow(() => (storage as OsuStorage)?.Migrate(customPath));
Assert.Throws<InvalidOperationException>(() => (storage as OsuStorage)?.Migrate(customPath));
}
finally
{
host.Exit();
}
}
}
private OsuGameBase loadOsu(GameHost host)
{
var osu = new OsuGameBase();