forked from ppy/osu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayableBeatmapCacheTest.cs
More file actions
50 lines (42 loc) · 1.66 KB
/
Copy pathPlayableBeatmapCacheTest.cs
File metadata and controls
50 lines (42 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// 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.
using System;
using NUnit.Framework;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Mods;
namespace osu.Game.Tests.Beatmaps
{
[TestFixture]
public class PlayableBeatmapCacheTest
{
[Test]
public void TestReturnsClone()
{
var cache = new PlayableBeatmapCache();
var beatmap = new Beatmap
{
BeatmapInfo = new BeatmapInfo
{
Hash = "hash"
}
};
cache.CachePlayableBeatmap(beatmap.BeatmapInfo, beatmap.BeatmapInfo.Ruleset, Array.Empty<Mod>(), beatmap);
Assert.That(cache.TryGetPlayableBeatmap(beatmap.BeatmapInfo, beatmap.BeatmapInfo.Ruleset, Array.Empty<Mod>(), out var retrieved), Is.True);
Assert.That(retrieved, Is.Not.SameAs(beatmap));
}
[Test]
public void TestHashChangeMissesCache()
{
var cache = new PlayableBeatmapCache();
var beatmapInfo = new BeatmapInfo
{
Hash = "hash-a"
};
var beatmap = new Beatmap { BeatmapInfo = beatmapInfo };
cache.CachePlayableBeatmap(beatmapInfo, beatmapInfo.Ruleset, Array.Empty<Mod>(), beatmap);
Assert.That(cache.TryGetPlayableBeatmap(beatmapInfo, beatmapInfo.Ruleset, Array.Empty<Mod>(), out _), Is.True);
beatmapInfo.Hash = "hash-b";
Assert.That(cache.TryGetPlayableBeatmap(beatmapInfo, beatmapInfo.Ruleset, Array.Empty<Mod>(), out _), Is.False);
}
}
}