mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Add unit tests for Xbox 360 memory card partitions.
This commit is contained in:
94
DiscImageChef.Tests/Partitions/Xbox.cs
Normal file
94
DiscImageChef.Tests/Partitions/Xbox.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
// /***************************************************************************
|
||||
// The Disc Image Chef
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Xbox.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : DiscImageChef unit testing.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2019 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using DiscImageChef.CommonTypes;
|
||||
using DiscImageChef.CommonTypes.Interfaces;
|
||||
using DiscImageChef.DiscImages;
|
||||
using DiscImageChef.Filters;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace DiscImageChef.Tests.Partitions
|
||||
{
|
||||
[TestFixture]
|
||||
public class Xbox
|
||||
{
|
||||
readonly string[] testfiles = {"microsoft256mb.img.lz"};
|
||||
|
||||
readonly Partition[][] wanted =
|
||||
{
|
||||
new[]
|
||||
{
|
||||
new Partition
|
||||
{
|
||||
Description = "System cache",
|
||||
Name = null,
|
||||
Type = null,
|
||||
Length = 16376,
|
||||
Sequence = 0,
|
||||
Start = 0,
|
||||
},
|
||||
new Partition
|
||||
{
|
||||
Description = "Data volume",
|
||||
Name = null,
|
||||
Type = null,
|
||||
Length = 475144,
|
||||
Sequence = 1,
|
||||
Start = 16376
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
[Test]
|
||||
public void Test()
|
||||
{
|
||||
for(int i = 0; i < testfiles.Length; i++)
|
||||
{
|
||||
string location = Path.Combine(Consts.TestFilesRoot, "partitions", "xbox", testfiles[i]);
|
||||
IFilter filter = new LZip();
|
||||
filter.Open(location);
|
||||
IMediaImage image = new ZZZRawImage();
|
||||
Assert.AreEqual(true, image.Open(filter), testfiles[i]);
|
||||
List<Partition> partitions = Core.Partitions.GetAll(image);
|
||||
Assert.AreEqual(wanted[i].Length, partitions.Count, testfiles[i]);
|
||||
for(int j = 0; j < partitions.Count; j++)
|
||||
{
|
||||
// Too chatty
|
||||
Assert.AreEqual(wanted[i][j].Description, partitions[j].Description, testfiles[i]);
|
||||
Assert.AreEqual(wanted[i][j].Length * 512, partitions[j].Size, testfiles[i]);
|
||||
Assert.AreEqual(wanted[i][j].Start * 512, partitions[j].Offset, testfiles[i]);
|
||||
Assert.AreEqual(wanted[i][j].Length, partitions[j].Length, testfiles[i]);
|
||||
Assert.AreEqual(wanted[i][j].Sequence, partitions[j].Sequence, testfiles[i]);
|
||||
Assert.AreEqual(wanted[i][j].Start, partitions[j].Start, testfiles[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user