mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:17:23 +08:00
Add tests
This commit is contained in:
parent
881ec146af
commit
1ce4f7c854
9
osu.Game.Tests/Resources/mania-skin-duplicate.ini
Normal file
9
osu.Game.Tests/Resources/mania-skin-duplicate.ini
Normal file
@ -0,0 +1,9 @@
|
||||
[Mania]
|
||||
Keys: 4
|
||||
ColumnWidth: 10,10,10,10
|
||||
HitPosition: 470
|
||||
|
||||
[Mania]
|
||||
Keys: 4
|
||||
ColumnWidth: 20,20,20,20
|
||||
HitPosition: 460
|
4
osu.Game.Tests/Resources/mania-skin-extra-data.ini
Normal file
4
osu.Game.Tests/Resources/mania-skin-extra-data.ini
Normal file
@ -0,0 +1,4 @@
|
||||
[Mania]
|
||||
Keys: 4
|
||||
ColumnWidth: 10,10,10,10,10,10,10
|
||||
HitPosition: 470
|
9
osu.Game.Tests/Resources/mania-skin-multiple.ini
Normal file
9
osu.Game.Tests/Resources/mania-skin-multiple.ini
Normal file
@ -0,0 +1,9 @@
|
||||
[Mania]
|
||||
Keys: 4
|
||||
ColumnWidth: 10,10,10,10
|
||||
HitPosition: 470
|
||||
|
||||
[Mania]
|
||||
Keys: 2
|
||||
ColumnWidth: 20,20
|
||||
HitPosition: 460
|
4
osu.Game.Tests/Resources/mania-skin-single.ini
Normal file
4
osu.Game.Tests/Resources/mania-skin-single.ini
Normal file
@ -0,0 +1,4 @@
|
||||
[Mania]
|
||||
Keys: 4
|
||||
ColumnWidth: 10,10,10,10
|
||||
HitPosition: 470
|
87
osu.Game.Tests/Skins/LegacyManiaSkinDecoderTest.cs
Normal file
87
osu.Game.Tests/Skins/LegacyManiaSkinDecoderTest.cs
Normal file
@ -0,0 +1,87 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Game.IO;
|
||||
using osu.Game.Skinning;
|
||||
using osu.Game.Tests.Resources;
|
||||
|
||||
namespace osu.Game.Tests.Skins
|
||||
{
|
||||
[TestFixture]
|
||||
public class LegacyManiaSkinDecoderTest
|
||||
{
|
||||
[Test]
|
||||
public void TestParseSingleConfig()
|
||||
{
|
||||
var decoder = new LegacyManiaSkinDecoder();
|
||||
|
||||
using (var resStream = TestResources.OpenResource("mania-skin-single.ini"))
|
||||
using (var stream = new LineBufferedReader(resStream))
|
||||
{
|
||||
var configs = decoder.Decode(stream);
|
||||
|
||||
Assert.That(configs.Count, Is.EqualTo(1));
|
||||
Assert.That(configs[0].Keys, Is.EqualTo(4));
|
||||
Assert.That(configs[0].ColumnWidth, Is.EquivalentTo(new float[] { 16, 16, 16, 16 }));
|
||||
Assert.That(configs[0].HitPosition, Is.EqualTo(16));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestParseMultipleConfig()
|
||||
{
|
||||
var decoder = new LegacyManiaSkinDecoder();
|
||||
|
||||
using (var resStream = TestResources.OpenResource("mania-skin-multiple.ini"))
|
||||
using (var stream = new LineBufferedReader(resStream))
|
||||
{
|
||||
var configs = decoder.Decode(stream);
|
||||
|
||||
Assert.That(configs.Count, Is.EqualTo(2));
|
||||
|
||||
Assert.That(configs[0].Keys, Is.EqualTo(4));
|
||||
Assert.That(configs[0].ColumnWidth, Is.EquivalentTo(new float[] { 16, 16, 16, 16 }));
|
||||
Assert.That(configs[0].HitPosition, Is.EqualTo(16));
|
||||
|
||||
Assert.That(configs[1].Keys, Is.EqualTo(2));
|
||||
Assert.That(configs[1].ColumnWidth, Is.EquivalentTo(new float[] { 32, 32 }));
|
||||
Assert.That(configs[1].HitPosition, Is.EqualTo(32));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestParseDuplicateConfig()
|
||||
{
|
||||
var decoder = new LegacyManiaSkinDecoder();
|
||||
|
||||
using (var resStream = TestResources.OpenResource("mania-skin-single.ini"))
|
||||
using (var stream = new LineBufferedReader(resStream))
|
||||
{
|
||||
var configs = decoder.Decode(stream);
|
||||
|
||||
Assert.That(configs.Count, Is.EqualTo(1));
|
||||
Assert.That(configs[0].Keys, Is.EqualTo(4));
|
||||
Assert.That(configs[0].ColumnWidth, Is.EquivalentTo(new float[] { 16, 16, 16, 16 }));
|
||||
Assert.That(configs[0].HitPosition, Is.EqualTo(16));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestParseWithUnnecessaryExtraData()
|
||||
{
|
||||
var decoder = new LegacyManiaSkinDecoder();
|
||||
|
||||
using (var resStream = TestResources.OpenResource("mania-skin-extra-data.ini"))
|
||||
using (var stream = new LineBufferedReader(resStream))
|
||||
{
|
||||
var configs = decoder.Decode(stream);
|
||||
|
||||
Assert.That(configs.Count, Is.EqualTo(1));
|
||||
Assert.That(configs[0].Keys, Is.EqualTo(4));
|
||||
Assert.That(configs[0].ColumnWidth, Is.EquivalentTo(new float[] { 16, 16, 16, 16 }));
|
||||
Assert.That(configs[0].HitPosition, Is.EqualTo(16));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user