From 0273f8d476a365e6501cd431b89fde2122c68918 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Mon, 15 Apr 2019 01:13:06 +0100 Subject: [PATCH] Add unit tests for Xbox 360 memory card partitions. --- .../DiscImageChef.Tests.csproj | 1 + DiscImageChef.Tests/Partitions/Xbox.cs | 94 +++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 DiscImageChef.Tests/Partitions/Xbox.cs diff --git a/DiscImageChef.Tests/DiscImageChef.Tests.csproj b/DiscImageChef.Tests/DiscImageChef.Tests.csproj index 2f512c6a4..04e1c916a 100644 --- a/DiscImageChef.Tests/DiscImageChef.Tests.csproj +++ b/DiscImageChef.Tests/DiscImageChef.Tests.csproj @@ -144,6 +144,7 @@ + diff --git a/DiscImageChef.Tests/Partitions/Xbox.cs b/DiscImageChef.Tests/Partitions/Xbox.cs new file mode 100644 index 000000000..805770fc6 --- /dev/null +++ b/DiscImageChef.Tests/Partitions/Xbox.cs @@ -0,0 +1,94 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : Xbox.cs +// Author(s) : Natalia Portillo +// +// 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 . +// +// ---------------------------------------------------------------------------- +// 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 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]); + } + } + } + } +} \ No newline at end of file