2016-10-14 11:33:58 +08:00
|
|
|
|
using System;
|
2016-10-08 03:09:52 +08:00
|
|
|
|
using System.IO;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Game.Beatmaps.IO;
|
2016-11-14 21:03:39 +08:00
|
|
|
|
using osu.Game.Modes;
|
|
|
|
|
using osu.Game.Modes.Osu;
|
2016-10-08 03:09:52 +08:00
|
|
|
|
using osu.Game.Tests.Resources;
|
|
|
|
|
|
2016-10-14 11:33:58 +08:00
|
|
|
|
namespace osu.Game.Tests.Beatmaps.IO
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class OszArchiveReaderTest
|
|
|
|
|
{
|
2016-10-28 15:09:55 +08:00
|
|
|
|
[OneTimeSetUpAttribute]
|
2016-10-14 11:33:58 +08:00
|
|
|
|
public void SetUp()
|
|
|
|
|
{
|
|
|
|
|
OszArchiveReader.Register();
|
2016-11-14 21:03:39 +08:00
|
|
|
|
Ruleset.Register(new OsuRuleset());
|
2016-10-14 11:33:58 +08:00
|
|
|
|
}
|
2016-11-14 21:03:39 +08:00
|
|
|
|
|
2016-10-14 11:33:58 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestReadBeatmaps()
|
|
|
|
|
{
|
|
|
|
|
using (var osz = Resource.OpenResource("Beatmaps.241526 Soleily - Renatus.osz"))
|
|
|
|
|
{
|
|
|
|
|
var reader = new OszArchiveReader(osz);
|
|
|
|
|
string[] expected =
|
|
|
|
|
{
|
|
|
|
|
"Soleily - Renatus (Deif) [Platter].osu",
|
|
|
|
|
"Soleily - Renatus (Deif) [Rain].osu",
|
|
|
|
|
"Soleily - Renatus (Deif) [Salad].osu",
|
|
|
|
|
"Soleily - Renatus (ExPew) [Another].osu",
|
|
|
|
|
"Soleily - Renatus (ExPew) [Hyper].osu",
|
|
|
|
|
"Soleily - Renatus (ExPew) [Normal].osu",
|
|
|
|
|
"Soleily - Renatus (Gamu) [Hard].osu",
|
|
|
|
|
"Soleily - Renatus (Gamu) [Insane].osu",
|
|
|
|
|
"Soleily - Renatus (Gamu) [Normal].osu",
|
|
|
|
|
"Soleily - Renatus (MMzz) [Futsuu].osu",
|
|
|
|
|
"Soleily - Renatus (MMzz) [Muzukashii].osu",
|
|
|
|
|
"Soleily - Renatus (MMzz) [Oni].osu"
|
|
|
|
|
};
|
2017-02-13 17:30:47 +08:00
|
|
|
|
var maps = reader.BeatmapFilenames;
|
2016-10-14 11:33:58 +08:00
|
|
|
|
foreach (var map in expected)
|
|
|
|
|
Assert.Contains(map, maps);
|
|
|
|
|
}
|
2016-10-08 03:36:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-14 11:33:58 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestReadMetadata()
|
|
|
|
|
{
|
|
|
|
|
using (var osz = Resource.OpenResource("Beatmaps.241526 Soleily - Renatus.osz"))
|
|
|
|
|
{
|
|
|
|
|
var reader = new OszArchiveReader(osz);
|
|
|
|
|
var meta = reader.ReadMetadata();
|
2017-01-09 21:05:01 +08:00
|
|
|
|
Assert.AreEqual(241526, meta.OnlineBeatmapSetID);
|
2016-10-14 11:33:58 +08:00
|
|
|
|
Assert.AreEqual("Soleily", meta.Artist);
|
|
|
|
|
Assert.AreEqual("Soleily", meta.ArtistUnicode);
|
|
|
|
|
Assert.AreEqual("03. Renatus - Soleily 192kbps.mp3", meta.AudioFile);
|
|
|
|
|
Assert.AreEqual("Deif", meta.Author);
|
|
|
|
|
Assert.AreEqual("machinetop_background.jpg", meta.BackgroundFile);
|
|
|
|
|
Assert.AreEqual(164471, meta.PreviewTime);
|
|
|
|
|
Assert.AreEqual(string.Empty, meta.Source);
|
|
|
|
|
Assert.AreEqual("MBC7 Unisphere 地球ヤバイEP Chikyu Yabai", meta.Tags);
|
|
|
|
|
Assert.AreEqual("Renatus", meta.Title);
|
|
|
|
|
Assert.AreEqual("Renatus", meta.TitleUnicode);
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-01-09 21:05:01 +08:00
|
|
|
|
|
|
|
|
|
[Test]
|
2016-10-14 11:33:58 +08:00
|
|
|
|
public void TestReadFile()
|
|
|
|
|
{
|
|
|
|
|
using (var osz = Resource.OpenResource("Beatmaps.241526 Soleily - Renatus.osz"))
|
|
|
|
|
{
|
|
|
|
|
var reader = new OszArchiveReader(osz);
|
|
|
|
|
using (var stream = new StreamReader(
|
2016-11-05 19:00:14 +08:00
|
|
|
|
reader.GetStream("Soleily - Renatus (Deif) [Platter].osu")))
|
2016-10-14 11:33:58 +08:00
|
|
|
|
{
|
|
|
|
|
Assert.AreEqual("osu file format v13", stream.ReadLine().Trim());
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-10-08 04:19:24 +08:00
|
|
|
|
}
|
2016-10-14 11:33:58 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|