2017-06-30 00:34:46 +01:00
|
|
|
|
// /***************************************************************************
|
|
|
|
|
|
// The Disc Image Chef
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : MacBinary1.cs
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
2017-06-30 00:34:46 +01:00
|
|
|
|
//
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Component : DiscImageChef unit testing.
|
2017-06-30 00:34:46 +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-06-30 00:34:46 +01:00
|
|
|
|
// ****************************************************************************/
|
2017-12-19 03:50:57 +00:00
|
|
|
|
|
2017-06-30 00:34:46 +01:00
|
|
|
|
using System.IO;
|
2020-02-27 00:33:26 +00:00
|
|
|
|
using Aaru.Checksums;
|
|
|
|
|
|
using Aaru.CommonTypes.Interfaces;
|
2017-06-30 00:34:46 +01:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
|
2020-02-27 00:33:26 +00:00
|
|
|
|
namespace Aaru.Tests.Filters
|
2017-06-30 00:34:46 +01:00
|
|
|
|
{
|
|
|
|
|
|
[TestFixture]
|
|
|
|
|
|
public class MacBinary1
|
|
|
|
|
|
{
|
2018-02-03 17:39:49 +00:00
|
|
|
|
const string EXPECTED_FILE = "596c38555bc7ba284648d1ce57700884";
|
|
|
|
|
|
const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4";
|
|
|
|
|
|
const string EXPECTED_RESOURCE = "a972d27c44193a7587b21416c0953cc3";
|
2017-06-30 00:34:46 +01:00
|
|
|
|
readonly string location;
|
|
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public MacBinary1() => location = Path.Combine(Consts.TestFilesRoot, "filters", "macbinary", "macbinary1.bin");
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
public void CheckContents()
|
2017-06-30 00:34:46 +01:00
|
|
|
|
{
|
2020-02-29 18:03:35 +00:00
|
|
|
|
IFilter filter = new Aaru.Filters.AppleSingle();
|
|
|
|
|
|
filter.Open(location);
|
|
|
|
|
|
Stream str = filter.GetDataForkStream();
|
|
|
|
|
|
byte[] data = new byte[737280];
|
|
|
|
|
|
str.Read(data, 0, 737280);
|
|
|
|
|
|
str.Close();
|
|
|
|
|
|
str.Dispose();
|
|
|
|
|
|
filter.Close();
|
|
|
|
|
|
string result = Md5Context.Data(data, out _);
|
|
|
|
|
|
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
2017-06-30 00:34:46 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
public void CheckCorrectFile()
|
|
|
|
|
|
{
|
2018-02-03 19:11:41 +00:00
|
|
|
|
string result = Md5Context.File(location, out _);
|
2017-12-22 22:18:21 +00:00
|
|
|
|
Assert.AreEqual(EXPECTED_FILE, result);
|
2017-06-30 00:34:46 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
public void CheckFilterId()
|
|
|
|
|
|
{
|
2020-02-27 00:33:26 +00:00
|
|
|
|
IFilter filter = new Aaru.Filters.AppleSingle();
|
2017-06-30 00:34:46 +01:00
|
|
|
|
Assert.AreEqual(true, filter.Identify(location));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public void CheckResource()
|
2017-06-30 00:34:46 +01:00
|
|
|
|
{
|
2020-02-27 00:33:26 +00:00
|
|
|
|
IFilter filter = new Aaru.Filters.AppleSingle();
|
2017-06-30 00:34:46 +01:00
|
|
|
|
filter.Open(location);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
Stream str = filter.GetResourceForkStream();
|
|
|
|
|
|
byte[] data = new byte[286];
|
|
|
|
|
|
str.Read(data, 0, 286);
|
2017-06-30 00:34:46 +01:00
|
|
|
|
str.Close();
|
|
|
|
|
|
str.Dispose();
|
|
|
|
|
|
filter.Close();
|
2018-02-03 19:11:41 +00:00
|
|
|
|
string result = Md5Context.Data(data, out _);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
2017-06-30 00:34:46 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public void Test()
|
2017-06-30 00:34:46 +01:00
|
|
|
|
{
|
2020-02-27 00:33:26 +00:00
|
|
|
|
IFilter filter = new Aaru.Filters.AppleSingle();
|
2017-06-30 00:34:46 +01:00
|
|
|
|
filter.Open(location);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
Assert.AreEqual(true, filter.IsOpened());
|
|
|
|
|
|
Assert.AreEqual(737280, filter.GetDataForkLength());
|
|
|
|
|
|
Assert.AreNotEqual(null, filter.GetDataForkStream());
|
|
|
|
|
|
Assert.AreEqual(286, filter.GetResourceForkLength());
|
|
|
|
|
|
Assert.AreNotEqual(null, filter.GetResourceForkStream());
|
|
|
|
|
|
Assert.AreEqual(true, filter.HasResourceFork());
|
2017-06-30 00:34:46 +01:00
|
|
|
|
filter.Close();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
}
|