mirror of
https://github.com/ppy/osu.git
synced 2026-05-13 20:33:35 +08:00
a996261304
It's been a while. Notes: - `SharpCompress` usages changed a bit. Manually adjusted these, mostly just renames or adjusted parameters. - nUnit 3 -> 4 migrated using https://gist.github.com/peppy/07994386d793a117350cb5f24b156585. there's a mode in this script to update to the newer `Assert.That` syntax but it requires fixes and couldn't really be bothered. - DeepEqual nuked as the only usage was on a disabled test. The reason it's disabled has been merged upstream, but it's failing for other (realm) reasons which I don't think is worthwhile to investigate for now. - This bumps Moq. I think the author is back in a sensible headspace and the new version has the stupid shit removed, so probably okay? Nice to be on a level playing field with packages for once in a long time. - Automapper is silly, but we've discussed this elsewhere. - `TestRealmKeyBindingStore` failures are a wildcard, but fixed by using a more standardised testing method. Dunno why, don't care. --------- Co-authored-by: Bartłomiej Dach <dach.bartlomiej@gmail.com>
79 lines
2.8 KiB
C#
79 lines
2.8 KiB
C#
// 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 System.Globalization;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using NUnit.Framework;
|
|
using osu.Framework.Extensions;
|
|
using osu.Framework.Utils;
|
|
using osu.Game.Beatmaps;
|
|
using osu.Game.Tests.Visual;
|
|
using SharpCompress.Archives.Zip;
|
|
|
|
namespace osu.Game.Rulesets.Taiko.Tests.Editor
|
|
{
|
|
public partial class TestSceneTaikoEditorSaving : EditorSavingTestScene
|
|
{
|
|
protected override Ruleset CreateRuleset() => new TaikoRuleset();
|
|
|
|
[TestCase(null)]
|
|
[TestCase(1f)]
|
|
[TestCase(2f)]
|
|
[TestCase(2.4f)]
|
|
public void TestTaikoSliderMultiplierInExport(float? multiplier)
|
|
{
|
|
if (multiplier.HasValue)
|
|
AddStep("Set slider multiplier", () => EditorBeatmap.Difficulty.SliderMultiplier = multiplier.Value);
|
|
|
|
SaveEditor();
|
|
AddStep("export beatmap", () => Game.BeatmapManager.Export(EditorBeatmap.BeatmapInfo.BeatmapSet!).WaitSafely());
|
|
|
|
AddAssert("check slider multiplier correct in file", () =>
|
|
{
|
|
string export = LocalStorage.GetFiles("exports").First();
|
|
|
|
using (var stream = LocalStorage.GetStream(export))
|
|
using (var zip = ZipArchive.OpenArchive(stream))
|
|
{
|
|
using (var osuStream = zip.Entries.First().OpenEntryStream())
|
|
using (var reader = new StreamReader(osuStream))
|
|
{
|
|
string? line;
|
|
|
|
while ((line = reader.ReadLine()) != null)
|
|
{
|
|
if (line.StartsWith("SliderMultiplier", StringComparison.Ordinal))
|
|
{
|
|
return float.Parse(line.Split(':', StringSplitOptions.TrimEntries).Last(), provider: CultureInfo.InvariantCulture);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}, () => Is.EqualTo(multiplier ?? new BeatmapDifficulty().SliderMultiplier).Within(Precision.FLOAT_EPSILON));
|
|
}
|
|
|
|
[Test]
|
|
public void TestTaikoSliderMultiplier()
|
|
{
|
|
AddStep("Set slider multiplier", () => EditorBeatmap.Difficulty.SliderMultiplier = 2);
|
|
|
|
SaveEditor();
|
|
|
|
AddAssert("Beatmap has correct slider multiplier", assertTaikoSliderMulitplier);
|
|
|
|
ReloadEditorToSameBeatmap();
|
|
|
|
AddAssert("Beatmap still has correct slider multiplier", assertTaikoSliderMulitplier);
|
|
|
|
bool assertTaikoSliderMulitplier()
|
|
{
|
|
return Precision.AlmostEquals(EditorBeatmap.Difficulty.SliderMultiplier, 2);
|
|
}
|
|
}
|
|
}
|
|
}
|