2017-06-29 23:41:14 +01:00
|
|
|
|
// /***************************************************************************
|
|
|
|
|
|
// The Disc Image Chef
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Filename : PCExchange.cs
|
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
2017-06-29 23:41:14 +01:00
|
|
|
|
//
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Component : DiscImageChef unit testing.
|
2017-06-29 23:41:14 +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/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Copyright © 2011-2018 Natalia Portillo
|
2017-06-29 23:41:14 +01:00
|
|
|
|
// ****************************************************************************/
|
2017-12-19 03:50:57 +00:00
|
|
|
|
|
2017-06-29 23:41:14 +01:00
|
|
|
|
using System.IO;
|
|
|
|
|
|
using DiscImageChef.Checksums;
|
|
|
|
|
|
using DiscImageChef.Filters;
|
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
|
|
|
|
|
|
namespace DiscImageChef.Tests.Filters
|
|
|
|
|
|
{
|
|
|
|
|
|
[TestFixture]
|
|
|
|
|
|
public class PCExchange
|
|
|
|
|
|
{
|
|
|
|
|
|
const string ExpectedFile = "348825a08fa84766d20b91ed917012b9";
|
|
|
|
|
|
const string ExpectedContents = "c2be571406cf6353269faa59a4a8c0a4";
|
|
|
|
|
|
const string ExpectedResource = "5cb168d60ce8b2b1b3133c2faaf47165";
|
|
|
|
|
|
readonly string location;
|
|
|
|
|
|
|
|
|
|
|
|
public PCExchange()
|
|
|
|
|
|
{
|
|
|
|
|
|
location = Path.Combine(Consts.TestFilesRoot, "filters", "pcexchange", "DC6_RW_DOS_720.img");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
public void CheckCorrectFile()
|
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
|
Md5Context ctx = new Md5Context();
|
2017-06-29 23:41:14 +01:00
|
|
|
|
ctx.Init();
|
2017-12-19 20:33:03 +00:00
|
|
|
|
string result = ctx.File(Path.Combine(Consts.TestFilesRoot, "filters", "pcexchange", "FINDER.DAT"),
|
|
|
|
|
|
out byte[] tmp);
|
2017-06-29 23:41:14 +01:00
|
|
|
|
Assert.AreEqual(ExpectedFile, result);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
public void CheckFilterId()
|
|
|
|
|
|
{
|
|
|
|
|
|
Filter filter = new DiscImageChef.Filters.PCExchange();
|
|
|
|
|
|
Assert.AreEqual(true, filter.Identify(location));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
public void Test()
|
|
|
|
|
|
{
|
|
|
|
|
|
Filter filter = new DiscImageChef.Filters.PCExchange();
|
|
|
|
|
|
filter.Open(location);
|
|
|
|
|
|
Assert.AreEqual(true, filter.IsOpened());
|
|
|
|
|
|
Assert.AreEqual(737280, filter.GetDataForkLength());
|
|
|
|
|
|
Assert.AreNotEqual(null, filter.GetDataForkStream());
|
|
|
|
|
|
Assert.AreEqual(546, filter.GetResourceForkLength());
|
|
|
|
|
|
Assert.AreNotEqual(null, filter.GetResourceForkStream());
|
|
|
|
|
|
Assert.AreEqual(true, filter.HasResourceFork());
|
|
|
|
|
|
filter.Close();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
public void CheckContents()
|
|
|
|
|
|
{
|
|
|
|
|
|
Filter filter = new DiscImageChef.Filters.PCExchange();
|
|
|
|
|
|
filter.Open(location);
|
|
|
|
|
|
Stream str = filter.GetDataForkStream();
|
|
|
|
|
|
byte[] data = new byte[737280];
|
|
|
|
|
|
str.Read(data, 0, 737280);
|
|
|
|
|
|
str.Close();
|
|
|
|
|
|
str.Dispose();
|
|
|
|
|
|
filter.Close();
|
2017-12-20 17:15:26 +00:00
|
|
|
|
Md5Context ctx = new Md5Context();
|
2017-06-29 23:41:14 +01:00
|
|
|
|
ctx.Init();
|
|
|
|
|
|
string result = ctx.Data(data, out byte[] tmp);
|
|
|
|
|
|
Assert.AreEqual(ExpectedContents, result);
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-06-29 23:41:14 +01:00
|
|
|
|
[Test]
|
|
|
|
|
|
public void CheckResource()
|
|
|
|
|
|
{
|
|
|
|
|
|
Filter filter = new DiscImageChef.Filters.PCExchange();
|
|
|
|
|
|
filter.Open(location);
|
|
|
|
|
|
Stream str = filter.GetResourceForkStream();
|
|
|
|
|
|
byte[] data = new byte[546];
|
|
|
|
|
|
str.Read(data, 0, 546);
|
|
|
|
|
|
str.Close();
|
|
|
|
|
|
str.Dispose();
|
|
|
|
|
|
filter.Close();
|
2017-12-20 17:15:26 +00:00
|
|
|
|
Md5Context ctx = new Md5Context();
|
2017-06-29 23:41:14 +01:00
|
|
|
|
ctx.Init();
|
|
|
|
|
|
string result = ctx.Data(data, out byte[] tmp);
|
|
|
|
|
|
Assert.AreEqual(ExpectedResource, result);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
}
|