diff --git a/DiscImageChef.Tests/DiscImageChef.Tests.csproj b/DiscImageChef.Tests/DiscImageChef.Tests.csproj index 8070a7e5..54aa2b4e 100644 --- a/DiscImageChef.Tests/DiscImageChef.Tests.csproj +++ b/DiscImageChef.Tests/DiscImageChef.Tests.csproj @@ -51,6 +51,17 @@ + + + + + + + + + + + diff --git a/DiscImageChef.Tests/Filters/AppleDoubleDave.cs b/DiscImageChef.Tests/Filters/AppleDoubleDave.cs new file mode 100644 index 00000000..a04ed212 --- /dev/null +++ b/DiscImageChef.Tests/Filters/AppleDoubleDave.cs @@ -0,0 +1,130 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : AppleDoubleOsX.cs +// Version : 1.0 +// Author(s) : Natalia Portillo +// +// Component : Component +// +// Revision : $Revision$ +// Last change by : $Author$ +// Date : $Date$ +// +// --[ Description ] ---------------------------------------------------------- +// +// Description +// +// --[ 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 (C) 2011-2015 Claunia.com +// ****************************************************************************/ +// //$Id$ +using System.IO; +using DiscImageChef.Checksums; +using DiscImageChef.Filters; +using NUnit.Framework; + +namespace DiscImageChef.Tests.Filters +{ + [TestFixture] + public class AppleDoubleDave + { + const string ExpectedFile = "c2be571406cf6353269faa59a4a8c0a4"; + const string ExpectedSidecar = "7b0c25bf8cb70f6fb1a15eca31585250"; + const string ExpectedContents = "c2be571406cf6353269faa59a4a8c0a4"; + const string ExpectedResource = "a972d27c44193a7587b21416c0953cc3"; + readonly string location; + readonly string sidecar; + + public AppleDoubleDave() + { + location = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "dave", "DOS_720.dmg"); + sidecar = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "dave", "resource.frk", "DOS_720.dmg"); + } + + [Test] + public void CheckCorrectFile() + { + MD5Context ctx = new MD5Context(); + ctx.Init(); + string result = ctx.File(location, out byte[] tmp); + Assert.AreEqual(ExpectedFile, result); + + ctx = new MD5Context(); + ctx.Init(); + result = ctx.File(sidecar, out tmp); + Assert.AreEqual(ExpectedSidecar, result); + } + + [Test] + public void CheckFilterId() + { + Filter filter = new DiscImageChef.Filters.AppleDouble(); + Assert.AreEqual(true, filter.Identify(location)); + } + + [Test] + public void Test() + { + Filter filter = new DiscImageChef.Filters.AppleDouble(); + filter.Open(location); + 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()); + filter.Close(); + } + + [Test] + public void CheckContents() + { + Filter filter = new DiscImageChef.Filters.AppleDouble(); + filter.Open(location); + Stream str = filter.GetDataForkStream(); + byte[] data = new byte[737280]; + str.Read(data, 0, 737280); + str.Close(); + str.Dispose(); + filter.Close(); + MD5Context ctx = new MD5Context(); + ctx.Init(); + string result = ctx.Data(data, out byte[] tmp); + Assert.AreEqual(ExpectedContents, result); + } + + [Test] + public void CheckResource() + { + Filter filter = new DiscImageChef.Filters.AppleDouble(); + filter.Open(location); + Stream str = filter.GetResourceForkStream(); + byte[] data = new byte[286]; + str.Read(data, 0, 286); + str.Close(); + str.Dispose(); + filter.Close(); + MD5Context ctx = new MD5Context(); + ctx.Init(); + string result = ctx.Data(data, out byte[] tmp); + Assert.AreEqual(ExpectedResource, result); + } + } +} diff --git a/DiscImageChef.Tests/Filters/AppleDoubleDos.cs b/DiscImageChef.Tests/Filters/AppleDoubleDos.cs new file mode 100644 index 00000000..15327cff --- /dev/null +++ b/DiscImageChef.Tests/Filters/AppleDoubleDos.cs @@ -0,0 +1,130 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : AppleDoubleOsX.cs +// Version : 1.0 +// Author(s) : Natalia Portillo +// +// Component : Component +// +// Revision : $Revision$ +// Last change by : $Author$ +// Date : $Date$ +// +// --[ Description ] ---------------------------------------------------------- +// +// Description +// +// --[ 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 (C) 2011-2015 Claunia.com +// ****************************************************************************/ +// //$Id$ +using System.IO; +using DiscImageChef.Checksums; +using DiscImageChef.Filters; +using NUnit.Framework; + +namespace DiscImageChef.Tests.Filters +{ + [TestFixture] + public class AppleDoubleDos + { + const string ExpectedFile = "c2be571406cf6353269faa59a4a8c0a4"; + const string ExpectedSidecar = "7b0c25bf8cb70f6fb1a15eca31585250"; + const string ExpectedContents = "c2be571406cf6353269faa59a4a8c0a4"; + const string ExpectedResource = "a972d27c44193a7587b21416c0953cc3"; + readonly string location; + readonly string sidecar; + + public AppleDoubleDos() + { + location = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "dos", "DOS_720.dmg"); + sidecar = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "dos", "DOS_720.adf"); + } + + [Test] + public void CheckCorrectFile() + { + MD5Context ctx = new MD5Context(); + ctx.Init(); + string result = ctx.File(location, out byte[] tmp); + Assert.AreEqual(ExpectedFile, result); + + ctx = new MD5Context(); + ctx.Init(); + result = ctx.File(sidecar, out tmp); + Assert.AreEqual(ExpectedSidecar, result); + } + + [Test] + public void CheckFilterId() + { + Filter filter = new DiscImageChef.Filters.AppleDouble(); + Assert.AreEqual(true, filter.Identify(location)); + } + + [Test] + public void Test() + { + Filter filter = new DiscImageChef.Filters.AppleDouble(); + filter.Open(location); + 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()); + filter.Close(); + } + + [Test] + public void CheckContents() + { + Filter filter = new DiscImageChef.Filters.AppleDouble(); + filter.Open(location); + Stream str = filter.GetDataForkStream(); + byte[] data = new byte[737280]; + str.Read(data, 0, 737280); + str.Close(); + str.Dispose(); + filter.Close(); + MD5Context ctx = new MD5Context(); + ctx.Init(); + string result = ctx.Data(data, out byte[] tmp); + Assert.AreEqual(ExpectedContents, result); + } + + [Test] + public void CheckResource() + { + Filter filter = new DiscImageChef.Filters.AppleDouble(); + filter.Open(location); + Stream str = filter.GetResourceForkStream(); + byte[] data = new byte[286]; + str.Read(data, 0, 286); + str.Close(); + str.Dispose(); + filter.Close(); + MD5Context ctx = new MD5Context(); + ctx.Init(); + string result = ctx.Data(data, out byte[] tmp); + Assert.AreEqual(ExpectedResource, result); + } + } +} diff --git a/DiscImageChef.Tests/Filters/AppleDoubleNetatalk.cs b/DiscImageChef.Tests/Filters/AppleDoubleNetatalk.cs new file mode 100644 index 00000000..39273ccc --- /dev/null +++ b/DiscImageChef.Tests/Filters/AppleDoubleNetatalk.cs @@ -0,0 +1,130 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : AppleDoubleOsX.cs +// Version : 1.0 +// Author(s) : Natalia Portillo +// +// Component : Component +// +// Revision : $Revision$ +// Last change by : $Author$ +// Date : $Date$ +// +// --[ Description ] ---------------------------------------------------------- +// +// Description +// +// --[ 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 (C) 2011-2015 Claunia.com +// ****************************************************************************/ +// //$Id$ +using System.IO; +using DiscImageChef.Checksums; +using DiscImageChef.Filters; +using NUnit.Framework; + +namespace DiscImageChef.Tests.Filters +{ + [TestFixture] + public class AppleDoubleNetatalk + { + const string ExpectedFile = "c2be571406cf6353269faa59a4a8c0a4"; + const string ExpectedSidecar = "7b0c25bf8cb70f6fb1a15eca31585250"; + const string ExpectedContents = "c2be571406cf6353269faa59a4a8c0a4"; + const string ExpectedResource = "a972d27c44193a7587b21416c0953cc3"; + readonly string location; + readonly string sidecar; + + public AppleDoubleNetatalk() + { + location = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "netatalk", "DOS_720.dmg"); + sidecar = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "netatalk", ".AppleDouble", "DOS_720.dmg"); + } + + [Test] + public void CheckCorrectFile() + { + MD5Context ctx = new MD5Context(); + ctx.Init(); + string result = ctx.File(location, out byte[] tmp); + Assert.AreEqual(ExpectedFile, result); + + ctx = new MD5Context(); + ctx.Init(); + result = ctx.File(sidecar, out tmp); + Assert.AreEqual(ExpectedSidecar, result); + } + + [Test] + public void CheckFilterId() + { + Filter filter = new DiscImageChef.Filters.AppleDouble(); + Assert.AreEqual(true, filter.Identify(location)); + } + + [Test] + public void Test() + { + Filter filter = new DiscImageChef.Filters.AppleDouble(); + filter.Open(location); + 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()); + filter.Close(); + } + + [Test] + public void CheckContents() + { + Filter filter = new DiscImageChef.Filters.AppleDouble(); + filter.Open(location); + Stream str = filter.GetDataForkStream(); + byte[] data = new byte[737280]; + str.Read(data, 0, 737280); + str.Close(); + str.Dispose(); + filter.Close(); + MD5Context ctx = new MD5Context(); + ctx.Init(); + string result = ctx.Data(data, out byte[] tmp); + Assert.AreEqual(ExpectedContents, result); + } + + [Test] + public void CheckResource() + { + Filter filter = new DiscImageChef.Filters.AppleDouble(); + filter.Open(location); + Stream str = filter.GetResourceForkStream(); + byte[] data = new byte[286]; + str.Read(data, 0, 286); + str.Close(); + str.Dispose(); + filter.Close(); + MD5Context ctx = new MD5Context(); + ctx.Init(); + string result = ctx.Data(data, out byte[] tmp); + Assert.AreEqual(ExpectedResource, result); + } + } +} diff --git a/DiscImageChef.Tests/Filters/AppleDoubleOsX.cs b/DiscImageChef.Tests/Filters/AppleDoubleOsX.cs new file mode 100644 index 00000000..b3608ef9 --- /dev/null +++ b/DiscImageChef.Tests/Filters/AppleDoubleOsX.cs @@ -0,0 +1,130 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : AppleDoubleOsX.cs +// Version : 1.0 +// Author(s) : Natalia Portillo +// +// Component : Component +// +// Revision : $Revision$ +// Last change by : $Author$ +// Date : $Date$ +// +// --[ Description ] ---------------------------------------------------------- +// +// Description +// +// --[ 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 (C) 2011-2015 Claunia.com +// ****************************************************************************/ +// //$Id$ +using System.IO; +using DiscImageChef.Checksums; +using DiscImageChef.Filters; +using NUnit.Framework; + +namespace DiscImageChef.Tests.Filters +{ + [TestFixture] + public class AppleDoubleOsX + { + const string ExpectedFile = "c2be571406cf6353269faa59a4a8c0a4"; + const string ExpectedSidecar = "7b0c25bf8cb70f6fb1a15eca31585250"; + const string ExpectedContents = "c2be571406cf6353269faa59a4a8c0a4"; + const string ExpectedResource = "a972d27c44193a7587b21416c0953cc3"; + readonly string location; + readonly string sidecar; + + public AppleDoubleOsX() + { + location = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "osx", "DOS_720.dmg"); + sidecar = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "osx", "._DOS_720.dmg"); + } + + [Test] + public void CheckCorrectFile() + { + MD5Context ctx = new MD5Context(); + ctx.Init(); + string result = ctx.File(location, out byte[] tmp); + Assert.AreEqual(ExpectedFile, result); + + ctx = new MD5Context(); + ctx.Init(); + result = ctx.File(sidecar, out tmp); + Assert.AreEqual(ExpectedSidecar, result); + } + + [Test] + public void CheckFilterId() + { + Filter filter = new DiscImageChef.Filters.AppleDouble(); + Assert.AreEqual(true, filter.Identify(location)); + } + + [Test] + public void Test() + { + Filter filter = new DiscImageChef.Filters.AppleDouble(); + filter.Open(location); + 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()); + filter.Close(); + } + + [Test] + public void CheckContents() + { + Filter filter = new DiscImageChef.Filters.AppleDouble(); + filter.Open(location); + Stream str = filter.GetDataForkStream(); + byte[] data = new byte[737280]; + str.Read(data, 0, 737280); + str.Close(); + str.Dispose(); + filter.Close(); + MD5Context ctx = new MD5Context(); + ctx.Init(); + string result = ctx.Data(data, out byte[] tmp); + Assert.AreEqual(ExpectedContents, result); + } + + [Test] + public void CheckResource() + { + Filter filter = new DiscImageChef.Filters.AppleDouble(); + filter.Open(location); + Stream str = filter.GetResourceForkStream(); + byte[] data = new byte[286]; + str.Read(data, 0, 286); + str.Close(); + str.Dispose(); + filter.Close(); + MD5Context ctx = new MD5Context(); + ctx.Init(); + string result = ctx.Data(data, out byte[] tmp); + Assert.AreEqual(ExpectedResource, result); + } + } +} diff --git a/DiscImageChef.Tests/Filters/AppleDoubleProDos.cs b/DiscImageChef.Tests/Filters/AppleDoubleProDos.cs new file mode 100644 index 00000000..2980011a --- /dev/null +++ b/DiscImageChef.Tests/Filters/AppleDoubleProDos.cs @@ -0,0 +1,130 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : AppleDoubleOsX.cs +// Version : 1.0 +// Author(s) : Natalia Portillo +// +// Component : Component +// +// Revision : $Revision$ +// Last change by : $Author$ +// Date : $Date$ +// +// --[ Description ] ---------------------------------------------------------- +// +// Description +// +// --[ 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 (C) 2011-2015 Claunia.com +// ****************************************************************************/ +// //$Id$ +using System.IO; +using DiscImageChef.Checksums; +using DiscImageChef.Filters; +using NUnit.Framework; + +namespace DiscImageChef.Tests.Filters +{ + [TestFixture] + public class AppleDoubleProDos + { + const string ExpectedFile = "c2be571406cf6353269faa59a4a8c0a4"; + const string ExpectedSidecar = "7b0c25bf8cb70f6fb1a15eca31585250"; + const string ExpectedContents = "c2be571406cf6353269faa59a4a8c0a4"; + const string ExpectedResource = "a972d27c44193a7587b21416c0953cc3"; + readonly string location; + readonly string sidecar; + + public AppleDoubleProDos() + { + location = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "prodos", "DOS_720.dmg"); + sidecar = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "prodos", "R.DOS_720.dmg"); + } + + [Test] + public void CheckCorrectFile() + { + MD5Context ctx = new MD5Context(); + ctx.Init(); + string result = ctx.File(location, out byte[] tmp); + Assert.AreEqual(ExpectedFile, result); + + ctx = new MD5Context(); + ctx.Init(); + result = ctx.File(sidecar, out tmp); + Assert.AreEqual(ExpectedSidecar, result); + } + + [Test] + public void CheckFilterId() + { + Filter filter = new DiscImageChef.Filters.AppleDouble(); + Assert.AreEqual(true, filter.Identify(location)); + } + + [Test] + public void Test() + { + Filter filter = new DiscImageChef.Filters.AppleDouble(); + filter.Open(location); + 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()); + filter.Close(); + } + + [Test] + public void CheckContents() + { + Filter filter = new DiscImageChef.Filters.AppleDouble(); + filter.Open(location); + Stream str = filter.GetDataForkStream(); + byte[] data = new byte[737280]; + str.Read(data, 0, 737280); + str.Close(); + str.Dispose(); + filter.Close(); + MD5Context ctx = new MD5Context(); + ctx.Init(); + string result = ctx.Data(data, out byte[] tmp); + Assert.AreEqual(ExpectedContents, result); + } + + [Test] + public void CheckResource() + { + Filter filter = new DiscImageChef.Filters.AppleDouble(); + filter.Open(location); + Stream str = filter.GetResourceForkStream(); + byte[] data = new byte[286]; + str.Read(data, 0, 286); + str.Close(); + str.Dispose(); + filter.Close(); + MD5Context ctx = new MD5Context(); + ctx.Init(); + string result = ctx.Data(data, out byte[] tmp); + Assert.AreEqual(ExpectedResource, result); + } + } +} diff --git a/DiscImageChef.Tests/Filters/AppleDoubleUnAr.cs b/DiscImageChef.Tests/Filters/AppleDoubleUnAr.cs new file mode 100644 index 00000000..01b29518 --- /dev/null +++ b/DiscImageChef.Tests/Filters/AppleDoubleUnAr.cs @@ -0,0 +1,130 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : AppleDoubleOsX.cs +// Version : 1.0 +// Author(s) : Natalia Portillo +// +// Component : Component +// +// Revision : $Revision$ +// Last change by : $Author$ +// Date : $Date$ +// +// --[ Description ] ---------------------------------------------------------- +// +// Description +// +// --[ 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 (C) 2011-2015 Claunia.com +// ****************************************************************************/ +// //$Id$ +using System.IO; +using DiscImageChef.Checksums; +using DiscImageChef.Filters; +using NUnit.Framework; + +namespace DiscImageChef.Tests.Filters +{ + [TestFixture] + public class AppleDoubleUnAr + { + const string ExpectedFile = "c2be571406cf6353269faa59a4a8c0a4"; + const string ExpectedSidecar = "7b0c25bf8cb70f6fb1a15eca31585250"; + const string ExpectedContents = "c2be571406cf6353269faa59a4a8c0a4"; + const string ExpectedResource = "a972d27c44193a7587b21416c0953cc3"; + readonly string location; + readonly string sidecar; + + public AppleDoubleUnAr() + { + location = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "unar", "DOS_720.dmg"); + sidecar = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "unar", "DOS_720.dmg.rsrc"); + } + + [Test] + public void CheckCorrectFile() + { + MD5Context ctx = new MD5Context(); + ctx.Init(); + string result = ctx.File(location, out byte[] tmp); + Assert.AreEqual(ExpectedFile, result); + + ctx = new MD5Context(); + ctx.Init(); + result = ctx.File(sidecar, out tmp); + Assert.AreEqual(ExpectedSidecar, result); + } + + [Test] + public void CheckFilterId() + { + Filter filter = new DiscImageChef.Filters.AppleDouble(); + Assert.AreEqual(true, filter.Identify(location)); + } + + [Test] + public void Test() + { + Filter filter = new DiscImageChef.Filters.AppleDouble(); + filter.Open(location); + 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()); + filter.Close(); + } + + [Test] + public void CheckContents() + { + Filter filter = new DiscImageChef.Filters.AppleDouble(); + filter.Open(location); + Stream str = filter.GetDataForkStream(); + byte[] data = new byte[737280]; + str.Read(data, 0, 737280); + str.Close(); + str.Dispose(); + filter.Close(); + MD5Context ctx = new MD5Context(); + ctx.Init(); + string result = ctx.Data(data, out byte[] tmp); + Assert.AreEqual(ExpectedContents, result); + } + + [Test] + public void CheckResource() + { + Filter filter = new DiscImageChef.Filters.AppleDouble(); + filter.Open(location); + Stream str = filter.GetResourceForkStream(); + byte[] data = new byte[286]; + str.Read(data, 0, 286); + str.Close(); + str.Dispose(); + filter.Close(); + MD5Context ctx = new MD5Context(); + ctx.Init(); + string result = ctx.Data(data, out byte[] tmp); + Assert.AreEqual(ExpectedResource, result); + } + } +} diff --git a/DiscImageChef.Tests/Filters/AppleDoubleUnix.cs b/DiscImageChef.Tests/Filters/AppleDoubleUnix.cs new file mode 100644 index 00000000..b8ff2397 --- /dev/null +++ b/DiscImageChef.Tests/Filters/AppleDoubleUnix.cs @@ -0,0 +1,130 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : AppleDoubleOsX.cs +// Version : 1.0 +// Author(s) : Natalia Portillo +// +// Component : Component +// +// Revision : $Revision$ +// Last change by : $Author$ +// Date : $Date$ +// +// --[ Description ] ---------------------------------------------------------- +// +// Description +// +// --[ 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 (C) 2011-2015 Claunia.com +// ****************************************************************************/ +// //$Id$ +using System.IO; +using DiscImageChef.Checksums; +using DiscImageChef.Filters; +using NUnit.Framework; + +namespace DiscImageChef.Tests.Filters +{ + [TestFixture] + public class AppleDoubleUnix + { + const string ExpectedFile = "c2be571406cf6353269faa59a4a8c0a4"; + const string ExpectedSidecar = "7b0c25bf8cb70f6fb1a15eca31585250"; + const string ExpectedContents = "c2be571406cf6353269faa59a4a8c0a4"; + const string ExpectedResource = "a972d27c44193a7587b21416c0953cc3"; + readonly string location; + readonly string sidecar; + + public AppleDoubleUnix() + { + location = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "unix", "DOS_720.dmg"); + sidecar = Path.Combine(Consts.TestFilesRoot, "filters", "appledouble", "unix", "%DOS_720.dmg"); + } + + [Test] + public void CheckCorrectFile() + { + MD5Context ctx = new MD5Context(); + ctx.Init(); + string result = ctx.File(location, out byte[] tmp); + Assert.AreEqual(ExpectedFile, result); + + ctx = new MD5Context(); + ctx.Init(); + result = ctx.File(sidecar, out tmp); + Assert.AreEqual(ExpectedSidecar, result); + } + + [Test] + public void CheckFilterId() + { + Filter filter = new DiscImageChef.Filters.AppleDouble(); + Assert.AreEqual(true, filter.Identify(location)); + } + + [Test] + public void Test() + { + Filter filter = new DiscImageChef.Filters.AppleDouble(); + filter.Open(location); + 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()); + filter.Close(); + } + + [Test] + public void CheckContents() + { + Filter filter = new DiscImageChef.Filters.AppleDouble(); + filter.Open(location); + Stream str = filter.GetDataForkStream(); + byte[] data = new byte[737280]; + str.Read(data, 0, 737280); + str.Close(); + str.Dispose(); + filter.Close(); + MD5Context ctx = new MD5Context(); + ctx.Init(); + string result = ctx.Data(data, out byte[] tmp); + Assert.AreEqual(ExpectedContents, result); + } + + [Test] + public void CheckResource() + { + Filter filter = new DiscImageChef.Filters.AppleDouble(); + filter.Open(location); + Stream str = filter.GetResourceForkStream(); + byte[] data = new byte[286]; + str.Read(data, 0, 286); + str.Close(); + str.Dispose(); + filter.Close(); + MD5Context ctx = new MD5Context(); + ctx.Init(); + string result = ctx.Data(data, out byte[] tmp); + Assert.AreEqual(ExpectedResource, result); + } + } +} diff --git a/DiscImageChef.Tests/Filters/AppleSingle.cs b/DiscImageChef.Tests/Filters/AppleSingle.cs new file mode 100644 index 00000000..ccdb0868 --- /dev/null +++ b/DiscImageChef.Tests/Filters/AppleSingle.cs @@ -0,0 +1,122 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : AppleDoubleOsX.cs +// Version : 1.0 +// Author(s) : Natalia Portillo +// +// Component : Component +// +// Revision : $Revision$ +// Last change by : $Author$ +// Date : $Date$ +// +// --[ Description ] ---------------------------------------------------------- +// +// Description +// +// --[ 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 (C) 2011-2015 Claunia.com +// ****************************************************************************/ +// //$Id$ +using System.IO; +using DiscImageChef.Checksums; +using DiscImageChef.Filters; +using NUnit.Framework; + +namespace DiscImageChef.Tests.Filters +{ + [TestFixture] + public class AppleSingle + { + const string ExpectedFile = "7497a3b156dcd0c1046a1ab12e188ab7"; + const string ExpectedContents = "c2be571406cf6353269faa59a4a8c0a4"; + const string ExpectedResource = "a972d27c44193a7587b21416c0953cc3"; + readonly string location; + + public AppleSingle() + { + location = Path.Combine(Consts.TestFilesRoot, "filters", "applesingle", "DOS_720.ASF"); + } + + [Test] + public void CheckCorrectFile() + { + MD5Context ctx = new MD5Context(); + ctx.Init(); + string result = ctx.File(location, out byte[] tmp); + Assert.AreEqual(ExpectedFile, result); + } + + [Test] + public void CheckFilterId() + { + Filter filter = new DiscImageChef.Filters.AppleSingle(); + Assert.AreEqual(true, filter.Identify(location)); + } + + [Test] + public void Test() + { + Filter filter = new DiscImageChef.Filters.AppleSingle(); + filter.Open(location); + 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()); + filter.Close(); + } + + [Test] + public void CheckContents() + { + Filter filter = new DiscImageChef.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(); + MD5Context ctx = new MD5Context(); + ctx.Init(); + string result = ctx.Data(data, out byte[] tmp); + Assert.AreEqual(ExpectedContents, result); + } + + [Test] + public void CheckResource() + { + Filter filter = new DiscImageChef.Filters.AppleSingle(); + filter.Open(location); + Stream str = filter.GetResourceForkStream(); + byte[] data = new byte[286]; + str.Read(data, 0, 286); + str.Close(); + str.Dispose(); + filter.Close(); + MD5Context ctx = new MD5Context(); + ctx.Init(); + string result = ctx.Data(data, out byte[] tmp); + Assert.AreEqual(ExpectedResource, result); + } + } +} diff --git a/DiscImageChef.Tests/Filters/MacBinary1.cs b/DiscImageChef.Tests/Filters/MacBinary1.cs new file mode 100644 index 00000000..68b9e774 --- /dev/null +++ b/DiscImageChef.Tests/Filters/MacBinary1.cs @@ -0,0 +1,122 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : MacBinary1.cs +// Version : 1.0 +// Author(s) : Natalia Portillo +// +// Component : Component +// +// Revision : $Revision$ +// Last change by : $Author$ +// Date : $Date$ +// +// --[ Description ] ---------------------------------------------------------- +// +// Description +// +// --[ 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 (C) 2011-2015 Claunia.com +// ****************************************************************************/ +// //$Id$ +using System.IO; +using DiscImageChef.Checksums; +using DiscImageChef.Filters; +using NUnit.Framework; + +namespace DiscImageChef.Tests.Filters +{ + [TestFixture] + public class MacBinary1 + { + const string ExpectedFile = "596c38555bc7ba284648d1ce57700884"; + const string ExpectedContents = "c2be571406cf6353269faa59a4a8c0a4"; + const string ExpectedResource = "a972d27c44193a7587b21416c0953cc3"; + readonly string location; + + public MacBinary1() + { + location = Path.Combine(Consts.TestFilesRoot, "filters", "macbinary", "macbinary1.bin"); + } + + [Test] + public void CheckCorrectFile() + { + MD5Context ctx = new MD5Context(); + ctx.Init(); + string result = ctx.File(location, out byte[] tmp); + Assert.AreEqual(ExpectedFile, result); + } + + [Test] + public void CheckFilterId() + { + Filter filter = new DiscImageChef.Filters.AppleSingle(); + Assert.AreEqual(true, filter.Identify(location)); + } + + [Test] + public void Test() + { + Filter filter = new DiscImageChef.Filters.AppleSingle(); + filter.Open(location); + 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()); + filter.Close(); + } + + [Test] + public void CheckContents() + { + Filter filter = new DiscImageChef.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(); + MD5Context ctx = new MD5Context(); + ctx.Init(); + string result = ctx.Data(data, out byte[] tmp); + Assert.AreEqual(ExpectedContents, result); + } + + [Test] + public void CheckResource() + { + Filter filter = new DiscImageChef.Filters.AppleSingle(); + filter.Open(location); + Stream str = filter.GetResourceForkStream(); + byte[] data = new byte[286]; + str.Read(data, 0, 286); + str.Close(); + str.Dispose(); + filter.Close(); + MD5Context ctx = new MD5Context(); + ctx.Init(); + string result = ctx.Data(data, out byte[] tmp); + Assert.AreEqual(ExpectedResource, result); + } + } +} diff --git a/DiscImageChef.Tests/Filters/MacBinary2.cs b/DiscImageChef.Tests/Filters/MacBinary2.cs new file mode 100644 index 00000000..da27b0a6 --- /dev/null +++ b/DiscImageChef.Tests/Filters/MacBinary2.cs @@ -0,0 +1,122 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : MacBinary1.cs +// Version : 1.0 +// Author(s) : Natalia Portillo +// +// Component : Component +// +// Revision : $Revision$ +// Last change by : $Author$ +// Date : $Date$ +// +// --[ Description ] ---------------------------------------------------------- +// +// Description +// +// --[ 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 (C) 2011-2015 Claunia.com +// ****************************************************************************/ +// //$Id$ +using System.IO; +using DiscImageChef.Checksums; +using DiscImageChef.Filters; +using NUnit.Framework; + +namespace DiscImageChef.Tests.Filters +{ + [TestFixture] + public class MacBinary2 + { + const string ExpectedFile = "a8daa55a65432353e95dc4c61d42660f"; + const string ExpectedContents = "c2be571406cf6353269faa59a4a8c0a4"; + const string ExpectedResource = "a972d27c44193a7587b21416c0953cc3"; + readonly string location; + + public MacBinary2() + { + location = Path.Combine(Consts.TestFilesRoot, "filters", "macbinary", "macbinary2.bin"); + } + + [Test] + public void CheckCorrectFile() + { + MD5Context ctx = new MD5Context(); + ctx.Init(); + string result = ctx.File(location, out byte[] tmp); + Assert.AreEqual(ExpectedFile, result); + } + + [Test] + public void CheckFilterId() + { + Filter filter = new DiscImageChef.Filters.MacBinary(); + Assert.AreEqual(true, filter.Identify(location)); + } + + [Test] + public void Test() + { + Filter filter = new DiscImageChef.Filters.MacBinary(); + filter.Open(location); + 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()); + filter.Close(); + } + + [Test] + public void CheckContents() + { + Filter filter = new DiscImageChef.Filters.MacBinary(); + filter.Open(location); + Stream str = filter.GetDataForkStream(); + byte[] data = new byte[737280]; + str.Read(data, 0, 737280); + str.Close(); + str.Dispose(); + filter.Close(); + MD5Context ctx = new MD5Context(); + ctx.Init(); + string result = ctx.Data(data, out byte[] tmp); + Assert.AreEqual(ExpectedContents, result); + } + + [Test] + public void CheckResource() + { + Filter filter = new DiscImageChef.Filters.MacBinary(); + filter.Open(location); + Stream str = filter.GetResourceForkStream(); + byte[] data = new byte[286]; + str.Read(data, 0, 286); + str.Close(); + str.Dispose(); + filter.Close(); + MD5Context ctx = new MD5Context(); + ctx.Init(); + string result = ctx.Data(data, out byte[] tmp); + Assert.AreEqual(ExpectedResource, result); + } + } +} diff --git a/DiscImageChef.Tests/Filters/MacBinary3.cs b/DiscImageChef.Tests/Filters/MacBinary3.cs new file mode 100644 index 00000000..57efaa11 --- /dev/null +++ b/DiscImageChef.Tests/Filters/MacBinary3.cs @@ -0,0 +1,122 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : MacBinary1.cs +// Version : 1.0 +// Author(s) : Natalia Portillo +// +// Component : Component +// +// Revision : $Revision$ +// Last change by : $Author$ +// Date : $Date$ +// +// --[ Description ] ---------------------------------------------------------- +// +// Description +// +// --[ 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 (C) 2011-2015 Claunia.com +// ****************************************************************************/ +// //$Id$ +using System.IO; +using DiscImageChef.Checksums; +using DiscImageChef.Filters; +using NUnit.Framework; + +namespace DiscImageChef.Tests.Filters +{ + [TestFixture] + public class MacBinary3 + { + const string ExpectedFile = "3a7363a6109fb52a264b0b45dfa16694"; + const string ExpectedContents = "c2be571406cf6353269faa59a4a8c0a4"; + const string ExpectedResource = "a972d27c44193a7587b21416c0953cc3"; + readonly string location; + + public MacBinary3() + { + location = Path.Combine(Consts.TestFilesRoot, "filters", "macbinary", "macbinary3.bin"); + } + + [Test] + public void CheckCorrectFile() + { + MD5Context ctx = new MD5Context(); + ctx.Init(); + string result = ctx.File(location, out byte[] tmp); + Assert.AreEqual(ExpectedFile, result); + } + + [Test] + public void CheckFilterId() + { + Filter filter = new DiscImageChef.Filters.MacBinary(); + Assert.AreEqual(true, filter.Identify(location)); + } + + [Test] + public void Test() + { + Filter filter = new DiscImageChef.Filters.MacBinary(); + filter.Open(location); + 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()); + filter.Close(); + } + + [Test] + public void CheckContents() + { + Filter filter = new DiscImageChef.Filters.MacBinary(); + filter.Open(location); + Stream str = filter.GetDataForkStream(); + byte[] data = new byte[737280]; + str.Read(data, 0, 737280); + str.Close(); + str.Dispose(); + filter.Close(); + MD5Context ctx = new MD5Context(); + ctx.Init(); + string result = ctx.Data(data, out byte[] tmp); + Assert.AreEqual(ExpectedContents, result); + } + + [Test] + public void CheckResource() + { + Filter filter = new DiscImageChef.Filters.MacBinary(); + filter.Open(location); + Stream str = filter.GetResourceForkStream(); + byte[] data = new byte[286]; + str.Read(data, 0, 286); + str.Close(); + str.Dispose(); + filter.Close(); + MD5Context ctx = new MD5Context(); + ctx.Init(); + string result = ctx.Data(data, out byte[] tmp); + Assert.AreEqual(ExpectedResource, result); + } + } +}