Fix broken test cases, remove some recursive lookup methods.

This commit is contained in:
Dean Herbert 2017-05-11 18:14:48 +09:00
parent 18b7c8e783
commit a2f6d8a3e6
4 changed files with 8 additions and 7 deletions

View File

@ -142,7 +142,7 @@ namespace osu.Game.Tests.Beatmaps.IO
Assert.IsTrue(waitAction.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(timeout), Assert.IsTrue(waitAction.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(timeout),
@"Beatmaps did not import to the database in allocated time"); @"Beatmaps did not import to the database in allocated time");
var set = host.Dependencies.Get<BeatmapDatabase>().GetChildren(resultSets.First(), true); var set = host.Dependencies.Get<BeatmapDatabase>().GetChildren(resultSets.First());
Assert.IsTrue(set.Beatmaps.Count == resultBeatmaps.Count(), Assert.IsTrue(set.Beatmaps.Count == resultBeatmaps.Count(),
$@"Incorrect database beatmap count post-import ({resultBeatmaps.Count()} but should be {set.Beatmaps.Count})."); $@"Incorrect database beatmap count post-import ({resultBeatmaps.Count()} but should be {set.Beatmaps.Count}).");

View File

@ -267,6 +267,9 @@ namespace osu.Game.Database
public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo, WorkingBeatmap previous = null, bool withStoryboard = false) public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo, WorkingBeatmap previous = null, bool withStoryboard = false)
{ {
if (beatmapInfo.BeatmapSet == null)
beatmapInfo = GetChildren(beatmapInfo, true);
if (beatmapInfo.BeatmapSet == null) if (beatmapInfo.BeatmapSet == null)
throw new InvalidOperationException($@"Beatmap set {beatmapInfo.BeatmapSetInfoID} is not in the local database."); throw new InvalidOperationException($@"Beatmap set {beatmapInfo.BeatmapSetInfoID} is not in the local database.");

View File

@ -48,11 +48,9 @@ namespace osu.Game.Database
return Connection.Table<T>(); return Connection.Table<T>();
} }
public T GetWithChildren<T>(object id, bool recursive = false) where T : class /// <summary>
{ /// This is expensive. Use with caution.
return Connection.GetWithChildren<T>(id, recursive); /// </summary>
}
public List<T> GetAllWithChildren<T>(Expression<Func<T, bool>> filter = null, bool recursive = true) public List<T> GetAllWithChildren<T>(Expression<Func<T, bool>> filter = null, bool recursive = true)
where T : class where T : class
{ {

View File

@ -79,7 +79,7 @@ namespace osu.Game.Screens.Menu
if (count > 0) if (count > 0)
{ {
var beatmap = query.ElementAt(RNG.Next(0, count - 1)); var beatmap = query.ElementAt(RNG.Next(0, count - 1));
beatmaps.GetChildren(beatmap, true); beatmaps.GetChildren(beatmap);
Beatmap = beatmaps.GetWorkingBeatmap(beatmap.Beatmaps[0]); Beatmap = beatmaps.GetWorkingBeatmap(beatmap.Beatmaps[0]);
} }
} }