2017-06-30 00:34:46 +01:00
|
|
|
|
// /***************************************************************************
|
2020-07-25 02:01:36 +01:00
|
|
|
|
// Aaru Data Preservation Suite
|
2017-06-30 00:34:46 +01:00
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Filename : MacBinary3.cs
|
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
2017-06-30 00:34:46 +01:00
|
|
|
|
//
|
2020-07-25 02:01:36 +01:00
|
|
|
|
// Component : Aaru 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/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2022-02-18 10:02:53 +00:00
|
|
|
|
// Copyright © 2011-2022 Natalia Portillo
|
2017-06-30 00:34:46 +01:00
|
|
|
|
// ****************************************************************************/
|
2017-12-19 03:50:57 +00:00
|
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
|
namespace Aaru.Tests.Filters;
|
|
|
|
|
|
|
2017-06-30 00:34:46 +01:00
|
|
|
|
using System.IO;
|
2020-02-27 00:33:26 +00:00
|
|
|
|
using Aaru.Checksums;
|
2021-09-16 04:42:14 +01:00
|
|
|
|
using Aaru.CommonTypes.Enums;
|
2020-02-27 00:33:26 +00:00
|
|
|
|
using Aaru.CommonTypes.Interfaces;
|
|
|
|
|
|
using Aaru.Filters;
|
2022-11-14 09:43:16 +00:00
|
|
|
|
using Aaru.Helpers;
|
2017-06-30 00:34:46 +01:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
[TestFixture]
|
|
|
|
|
|
public class MacBinary3
|
2017-06-30 00:34:46 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
const string EXPECTED_FILE = "3a7363a6109fb52a264b0b45dfa16694";
|
|
|
|
|
|
const string EXPECTED_CONTENTS = "c2be571406cf6353269faa59a4a8c0a4";
|
|
|
|
|
|
const string EXPECTED_RESOURCE = "c689c58945169065483d94e39583d416";
|
|
|
|
|
|
readonly string _location;
|
2017-06-30 00:34:46 +01:00
|
|
|
|
|
2022-11-13 05:48:58 +00:00
|
|
|
|
public MacBinary3() => _location = Path.Combine(Consts.TestFilesRoot, "Filters", "MacBinary", "macbinary3.bin");
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
[Test]
|
|
|
|
|
|
public void CheckContents()
|
|
|
|
|
|
{
|
|
|
|
|
|
IFilter filter = new MacBinary();
|
|
|
|
|
|
filter.Open(_location);
|
|
|
|
|
|
Stream str = filter.GetDataForkStream();
|
2022-03-07 07:36:44 +00:00
|
|
|
|
var data = new byte[737280];
|
2022-11-14 09:43:16 +00:00
|
|
|
|
str.EnsureRead(data, 0, 737280);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
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
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
[Test]
|
|
|
|
|
|
public void CheckCorrectFile()
|
|
|
|
|
|
{
|
|
|
|
|
|
string result = Md5Context.File(_location, out _);
|
|
|
|
|
|
Assert.AreEqual(EXPECTED_FILE, result);
|
|
|
|
|
|
}
|
2017-06-30 00:34:46 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
[Test]
|
|
|
|
|
|
public void CheckFilterId()
|
|
|
|
|
|
{
|
|
|
|
|
|
IFilter filter = new MacBinary();
|
|
|
|
|
|
Assert.AreEqual(true, filter.Identify(_location));
|
|
|
|
|
|
}
|
2017-06-30 00:34:46 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
[Test]
|
|
|
|
|
|
public void CheckResource()
|
|
|
|
|
|
{
|
|
|
|
|
|
IFilter filter = new MacBinary();
|
|
|
|
|
|
filter.Open(_location);
|
|
|
|
|
|
Stream str = filter.GetResourceForkStream();
|
2022-03-07 07:36:44 +00:00
|
|
|
|
var data = new byte[286];
|
2022-11-14 09:43:16 +00:00
|
|
|
|
str.EnsureRead(data, 0, 286);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
str.Close();
|
|
|
|
|
|
str.Dispose();
|
|
|
|
|
|
filter.Close();
|
|
|
|
|
|
string result = Md5Context.Data(data, out _);
|
|
|
|
|
|
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
|
|
|
|
|
}
|
2017-06-30 00:34:46 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
[Test]
|
|
|
|
|
|
public void Test()
|
|
|
|
|
|
{
|
|
|
|
|
|
IFilter filter = new MacBinary();
|
|
|
|
|
|
Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location));
|
|
|
|
|
|
Assert.AreEqual(737280, filter.DataForkLength);
|
|
|
|
|
|
Assert.AreNotEqual(null, filter.GetDataForkStream());
|
|
|
|
|
|
Assert.AreEqual(286, filter.ResourceForkLength);
|
|
|
|
|
|
Assert.AreNotEqual(null, filter.GetResourceForkStream());
|
|
|
|
|
|
Assert.AreEqual(true, filter.HasResourceFork);
|
|
|
|
|
|
filter.Close();
|
2017-06-30 00:34:46 +01:00
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
}
|