Files
Aaru/Aaru.Tests/Filesystems/ProDOS.cs

117 lines
4.4 KiB
C#
Raw Normal View History

2017-07-08 19:23:52 +01:00
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : ProDOS.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
2017-07-08 19:23:52 +01:00
//
// Component : DiscImageChef unit testing.
2017-07-08 19:23:52 +01:00
//
// --[ 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/>.
//
// ----------------------------------------------------------------------------
2018-12-29 17:34:38 +00:00
// Copyright © 2011-2019 Natalia Portillo
2017-07-08 19:23:52 +01:00
// ****************************************************************************/
2017-07-08 19:23:52 +01:00
using System.Collections.Generic;
using System.IO;
2020-02-27 00:33:26 +00:00
using Aaru.CommonTypes;
using Aaru.CommonTypes.Interfaces;
using Aaru.DiscImages;
using Aaru.Filesystems;
using Aaru.Filters;
2017-07-08 19:23:52 +01:00
using NUnit.Framework;
2020-02-27 00:33:26 +00:00
namespace Aaru.Tests.Filesystems
2017-07-08 19:23:52 +01:00
{
[TestFixture]
public class ProdosApm
2017-07-08 19:23:52 +01:00
{
2020-07-20 21:11:32 +01:00
readonly string[] _testfiles =
2017-12-19 20:33:03 +00:00
{
"macos_7.5.3.aif", "macos_7.6.aif", "macos_8.0.aif", "macos_8.1.aif", "macos_9.0.4.aif", "macos_9.1.aif",
"macos_9.2.1.aif", "macos_9.2.2.aif"
2017-07-08 19:23:52 +01:00
};
2020-07-20 21:11:32 +01:00
readonly ulong[] _sectors =
2020-02-29 18:03:35 +00:00
{
49152, 49152, 49152, 49152, 49152, 49152, 49152, 49152
};
2017-07-08 19:23:52 +01:00
2020-07-20 21:11:32 +01:00
readonly uint[] _sectorsize =
2020-02-29 18:03:35 +00:00
{
512, 512, 512, 512, 512, 512, 512, 512
};
2017-07-08 19:23:52 +01:00
2020-07-20 21:11:32 +01:00
readonly long[] _clusters =
2020-02-29 18:03:35 +00:00
{
48438, 48438, 48438, 48438, 46326, 46326, 46326, 46326
};
2017-07-08 19:23:52 +01:00
2020-07-20 21:11:32 +01:00
readonly int[] _clustersize =
2020-02-29 18:03:35 +00:00
{
512, 512, 512, 512, 512, 512, 512, 512
};
2017-07-08 19:23:52 +01:00
2020-07-20 21:11:32 +01:00
readonly string[] _volumename =
2017-12-19 20:33:03 +00:00
{
"VOLUME.LABEL", "VOLUME.LABEL", "VOLUME.LABEL", "VOLUME.LABEL", "VOLUME.LABEL", "VOLUME.LABEL",
2017-12-21 02:52:12 +00:00
"VOLUME.LABEL", "VOLUME.LABEL"
2017-07-08 19:23:52 +01:00
};
2020-07-20 21:11:32 +01:00
readonly string[] _volumeserial =
2020-02-29 18:03:35 +00:00
{
null, null, null, null, null, null, null, null
};
2017-07-08 19:23:52 +01:00
[Test]
public void Test()
{
2020-07-20 21:11:32 +01:00
for(int i = 0; i < _testfiles.Length; i++)
2017-07-08 19:23:52 +01:00
{
2020-07-20 21:11:32 +01:00
string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "ProDOS filesystem (APM)",
_testfiles[i]);
2020-07-08 20:02:59 +01:00
IFilter filter = new ZZZNoFilter();
2017-07-08 19:23:52 +01:00
filter.Open(location);
IMediaImage image = new AaruFormat();
2020-07-20 21:11:32 +01:00
Assert.AreEqual(true, image.Open(filter), _testfiles[i]);
Assert.AreEqual(_sectors[i], image.Info.Sectors, _testfiles[i]);
Assert.AreEqual(_sectorsize[i], image.Info.SectorSize, _testfiles[i]);
List<Partition> partitions = Core.Partitions.GetAll(image);
2018-06-22 08:08:38 +01:00
IFilesystem fs = new ProDOSPlugin();
int part = -1;
2020-02-29 18:03:35 +00:00
2017-07-08 19:23:52 +01:00
for(int j = 0; j < partitions.Count; j++)
2017-07-19 16:37:11 +01:00
if(partitions[j].Type == "Apple_ProDOS")
2017-07-08 19:23:52 +01:00
{
part = j;
2020-02-29 18:03:35 +00:00
2017-07-08 19:23:52 +01:00
break;
}
2017-12-19 20:33:03 +00:00
2020-07-20 21:11:32 +01:00
Assert.AreNotEqual(-1, part, $"Partition not found on {_testfiles[i]}");
Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testfiles[i]);
fs.GetInformation(image, partitions[part], out _, null);
2020-07-20 21:11:32 +01:00
Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testfiles[i]);
Assert.AreEqual(_clustersize[i], fs.XmlFsType.ClusterSize, _testfiles[i]);
Assert.AreEqual("ProDOS", fs.XmlFsType.Type, _testfiles[i]);
Assert.AreEqual(_volumename[i], fs.XmlFsType.VolumeName, _testfiles[i]);
Assert.AreEqual(_volumeserial[i], fs.XmlFsType.VolumeSerial, _testfiles[i]);
2017-07-08 19:23:52 +01:00
}
}
}
2017-12-19 20:33:03 +00:00
}