diff --git a/DiscImageChef.Checksums/DiscImageChef.Checksums.csproj b/DiscImageChef.Checksums/DiscImageChef.Checksums.csproj index cc6d2ad17..33e942c3c 100644 --- a/DiscImageChef.Checksums/DiscImageChef.Checksums.csproj +++ b/DiscImageChef.Checksums/DiscImageChef.Checksums.csproj @@ -81,7 +81,7 @@ - + diff --git a/DiscImageChef.CommonTypes/DiscImageChef.CommonTypes.csproj b/DiscImageChef.CommonTypes/DiscImageChef.CommonTypes.csproj index db670a16d..fb1ffdc5b 100644 --- a/DiscImageChef.CommonTypes/DiscImageChef.CommonTypes.csproj +++ b/DiscImageChef.CommonTypes/DiscImageChef.CommonTypes.csproj @@ -57,7 +57,7 @@ - + diff --git a/DiscImageChef.Console/DiscImageChef.Console.csproj b/DiscImageChef.Console/DiscImageChef.Console.csproj index 7de9abf56..a8fc57a3f 100644 --- a/DiscImageChef.Console/DiscImageChef.Console.csproj +++ b/DiscImageChef.Console/DiscImageChef.Console.csproj @@ -55,7 +55,7 @@ - + diff --git a/DiscImageChef.Core/DiscImageChef.Core.csproj b/DiscImageChef.Core/DiscImageChef.Core.csproj index cebaa192c..f373b6c89 100644 --- a/DiscImageChef.Core/DiscImageChef.Core.csproj +++ b/DiscImageChef.Core/DiscImageChef.Core.csproj @@ -155,7 +155,7 @@ - + diff --git a/DiscImageChef.Decoders/DiscImageChef.Decoders.csproj b/DiscImageChef.Decoders/DiscImageChef.Decoders.csproj index 30900c805..c0dc006a3 100644 --- a/DiscImageChef.Decoders/DiscImageChef.Decoders.csproj +++ b/DiscImageChef.Decoders/DiscImageChef.Decoders.csproj @@ -156,7 +156,7 @@ - + diff --git a/DiscImageChef.Devices/DiscImageChef.Devices.csproj b/DiscImageChef.Devices/DiscImageChef.Devices.csproj index c976872a0..f04fae7bd 100644 --- a/DiscImageChef.Devices/DiscImageChef.Devices.csproj +++ b/DiscImageChef.Devices/DiscImageChef.Devices.csproj @@ -107,7 +107,7 @@ - + diff --git a/DiscImageChef.DiscImages/DiscImageChef.DiscImages.csproj b/DiscImageChef.DiscImages/DiscImageChef.DiscImages.csproj index 448a6ab0f..5938148a5 100644 --- a/DiscImageChef.DiscImages/DiscImageChef.DiscImages.csproj +++ b/DiscImageChef.DiscImages/DiscImageChef.DiscImages.csproj @@ -126,7 +126,7 @@ - + diff --git a/DiscImageChef.Filesystems/DiscImageChef.Filesystems.csproj b/DiscImageChef.Filesystems/DiscImageChef.Filesystems.csproj index 9e9bb5187..d74fe65ee 100644 --- a/DiscImageChef.Filesystems/DiscImageChef.Filesystems.csproj +++ b/DiscImageChef.Filesystems/DiscImageChef.Filesystems.csproj @@ -185,7 +185,7 @@ - + diff --git a/DiscImageChef.Filters/DiscImageChef.Filters.csproj b/DiscImageChef.Filters/DiscImageChef.Filters.csproj index 40f8a67d6..80781c120 100644 --- a/DiscImageChef.Filters/DiscImageChef.Filters.csproj +++ b/DiscImageChef.Filters/DiscImageChef.Filters.csproj @@ -78,7 +78,7 @@ - + diff --git a/DiscImageChef.Helpers/DiscImageChef.Helpers.csproj b/DiscImageChef.Helpers/DiscImageChef.Helpers.csproj index 7f2ebf4a0..e62b1117e 100644 --- a/DiscImageChef.Helpers/DiscImageChef.Helpers.csproj +++ b/DiscImageChef.Helpers/DiscImageChef.Helpers.csproj @@ -81,7 +81,7 @@ - + diff --git a/DiscImageChef.Interop/DiscImageChef.Interop.csproj b/DiscImageChef.Interop/DiscImageChef.Interop.csproj index 12aa4eee3..433976050 100644 --- a/DiscImageChef.Interop/DiscImageChef.Interop.csproj +++ b/DiscImageChef.Interop/DiscImageChef.Interop.csproj @@ -56,7 +56,7 @@ - + diff --git a/DiscImageChef.Metadata/DiscImageChef.Metadata.csproj b/DiscImageChef.Metadata/DiscImageChef.Metadata.csproj index 082df8a9d..dc65c9000 100644 --- a/DiscImageChef.Metadata/DiscImageChef.Metadata.csproj +++ b/DiscImageChef.Metadata/DiscImageChef.Metadata.csproj @@ -78,7 +78,7 @@ - + diff --git a/DiscImageChef.Partitions/DiscImageChef.Partitions.csproj b/DiscImageChef.Partitions/DiscImageChef.Partitions.csproj index 5ca74f5eb..c78cc993f 100644 --- a/DiscImageChef.Partitions/DiscImageChef.Partitions.csproj +++ b/DiscImageChef.Partitions/DiscImageChef.Partitions.csproj @@ -94,7 +94,7 @@ - + diff --git a/DiscImageChef.Server/ChangeLog b/DiscImageChef.Server/ChangeLog index 5bad52a2d..76503a483 100644 --- a/DiscImageChef.Server/ChangeLog +++ b/DiscImageChef.Server/ChangeLog @@ -1,3 +1,7 @@ +2017-06-29 Natalia Portillo + + * DiscImageChef.Server.csproj: Formatting options. + 2017-06-05 Natalia Portillo * ViewReport.aspx: diff --git a/DiscImageChef.Server/DiscImageChef.Server.csproj b/DiscImageChef.Server/DiscImageChef.Server.csproj index f8319323c..bbd865b7d 100644 --- a/DiscImageChef.Server/DiscImageChef.Server.csproj +++ b/DiscImageChef.Server/DiscImageChef.Server.csproj @@ -137,7 +137,7 @@ - + diff --git a/DiscImageChef.Settings/DiscImageChef.Settings.csproj b/DiscImageChef.Settings/DiscImageChef.Settings.csproj index d47e3de46..87a238119 100644 --- a/DiscImageChef.Settings/DiscImageChef.Settings.csproj +++ b/DiscImageChef.Settings/DiscImageChef.Settings.csproj @@ -67,7 +67,7 @@ - + diff --git a/DiscImageChef.Tests/Checksums/CRC16.cs b/DiscImageChef.Tests/Checksums/CRC16.cs new file mode 100644 index 000000000..19baac599 --- /dev/null +++ b/DiscImageChef.Tests/Checksums/CRC16.cs @@ -0,0 +1,47 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : CRC16.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; +namespace Checksums +{ + public class CRC16 + { + public CRC16() + { + } + } +} diff --git a/DiscImageChef.Tests/Checksums/CRC32.cs b/DiscImageChef.Tests/Checksums/CRC32.cs new file mode 100644 index 000000000..8c02b5def --- /dev/null +++ b/DiscImageChef.Tests/Checksums/CRC32.cs @@ -0,0 +1,119 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : CRC16.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; +using NUnit.Framework; +using DiscImageChef.Checksums; +using System.IO; + +namespace DiscImageChef.Tests.Checksums +{ + [TestFixture] + public class CRC16 + { + static readonly byte[] ExpectedEmpty = { 0x00, 0x00 }; + static readonly byte[] ExpectedRandom = { 0x2d, 0x6d }; + + [Test] + public void CRC16EmptyFile() + { + byte[] result = CRC16Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty")); + Assert.AreEqual(ExpectedEmpty, result); + } + + [Test] + public void CRC16EmptyData() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context.Data(data, out byte[] result); + Assert.AreEqual(ExpectedEmpty, result); + } + + [Test] + public void CRC16EmptyInstance() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context ctx = new CRC16Context(); + ctx.Init(); + ctx.Update(data); + byte[] result = ctx.Final(); + Assert.AreEqual(ExpectedEmpty, result); + } + + [Test] + public void CRC16RandomFile() + { + byte[] result = CRC16Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random")); + Assert.AreEqual(ExpectedRandom, result); + } + + [Test] + public void CRC16RandomData() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context.Data(data, out byte[] result); + Assert.AreEqual(ExpectedRandom, result); + } + + [Test] + public void CRC16RandomInstance() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context ctx = new CRC16Context(); + ctx.Init(); + ctx.Update(data); + byte[] result = ctx.Final(); + Assert.AreEqual(ExpectedRandom, result); + } + } +} diff --git a/DiscImageChef.Tests/Checksums/CRC64.cs b/DiscImageChef.Tests/Checksums/CRC64.cs new file mode 100644 index 000000000..8c02b5def --- /dev/null +++ b/DiscImageChef.Tests/Checksums/CRC64.cs @@ -0,0 +1,119 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : CRC16.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; +using NUnit.Framework; +using DiscImageChef.Checksums; +using System.IO; + +namespace DiscImageChef.Tests.Checksums +{ + [TestFixture] + public class CRC16 + { + static readonly byte[] ExpectedEmpty = { 0x00, 0x00 }; + static readonly byte[] ExpectedRandom = { 0x2d, 0x6d }; + + [Test] + public void CRC16EmptyFile() + { + byte[] result = CRC16Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty")); + Assert.AreEqual(ExpectedEmpty, result); + } + + [Test] + public void CRC16EmptyData() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context.Data(data, out byte[] result); + Assert.AreEqual(ExpectedEmpty, result); + } + + [Test] + public void CRC16EmptyInstance() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context ctx = new CRC16Context(); + ctx.Init(); + ctx.Update(data); + byte[] result = ctx.Final(); + Assert.AreEqual(ExpectedEmpty, result); + } + + [Test] + public void CRC16RandomFile() + { + byte[] result = CRC16Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random")); + Assert.AreEqual(ExpectedRandom, result); + } + + [Test] + public void CRC16RandomData() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context.Data(data, out byte[] result); + Assert.AreEqual(ExpectedRandom, result); + } + + [Test] + public void CRC16RandomInstance() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context ctx = new CRC16Context(); + ctx.Init(); + ctx.Update(data); + byte[] result = ctx.Final(); + Assert.AreEqual(ExpectedRandom, result); + } + } +} diff --git a/DiscImageChef.Tests/Checksums/MD5.cs b/DiscImageChef.Tests/Checksums/MD5.cs new file mode 100644 index 000000000..8c02b5def --- /dev/null +++ b/DiscImageChef.Tests/Checksums/MD5.cs @@ -0,0 +1,119 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : CRC16.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; +using NUnit.Framework; +using DiscImageChef.Checksums; +using System.IO; + +namespace DiscImageChef.Tests.Checksums +{ + [TestFixture] + public class CRC16 + { + static readonly byte[] ExpectedEmpty = { 0x00, 0x00 }; + static readonly byte[] ExpectedRandom = { 0x2d, 0x6d }; + + [Test] + public void CRC16EmptyFile() + { + byte[] result = CRC16Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty")); + Assert.AreEqual(ExpectedEmpty, result); + } + + [Test] + public void CRC16EmptyData() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context.Data(data, out byte[] result); + Assert.AreEqual(ExpectedEmpty, result); + } + + [Test] + public void CRC16EmptyInstance() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context ctx = new CRC16Context(); + ctx.Init(); + ctx.Update(data); + byte[] result = ctx.Final(); + Assert.AreEqual(ExpectedEmpty, result); + } + + [Test] + public void CRC16RandomFile() + { + byte[] result = CRC16Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random")); + Assert.AreEqual(ExpectedRandom, result); + } + + [Test] + public void CRC16RandomData() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context.Data(data, out byte[] result); + Assert.AreEqual(ExpectedRandom, result); + } + + [Test] + public void CRC16RandomInstance() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context ctx = new CRC16Context(); + ctx.Init(); + ctx.Update(data); + byte[] result = ctx.Final(); + Assert.AreEqual(ExpectedRandom, result); + } + } +} diff --git a/DiscImageChef.Tests/Checksums/RIPEMD160.cs b/DiscImageChef.Tests/Checksums/RIPEMD160.cs new file mode 100644 index 000000000..8c02b5def --- /dev/null +++ b/DiscImageChef.Tests/Checksums/RIPEMD160.cs @@ -0,0 +1,119 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : CRC16.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; +using NUnit.Framework; +using DiscImageChef.Checksums; +using System.IO; + +namespace DiscImageChef.Tests.Checksums +{ + [TestFixture] + public class CRC16 + { + static readonly byte[] ExpectedEmpty = { 0x00, 0x00 }; + static readonly byte[] ExpectedRandom = { 0x2d, 0x6d }; + + [Test] + public void CRC16EmptyFile() + { + byte[] result = CRC16Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty")); + Assert.AreEqual(ExpectedEmpty, result); + } + + [Test] + public void CRC16EmptyData() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context.Data(data, out byte[] result); + Assert.AreEqual(ExpectedEmpty, result); + } + + [Test] + public void CRC16EmptyInstance() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context ctx = new CRC16Context(); + ctx.Init(); + ctx.Update(data); + byte[] result = ctx.Final(); + Assert.AreEqual(ExpectedEmpty, result); + } + + [Test] + public void CRC16RandomFile() + { + byte[] result = CRC16Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random")); + Assert.AreEqual(ExpectedRandom, result); + } + + [Test] + public void CRC16RandomData() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context.Data(data, out byte[] result); + Assert.AreEqual(ExpectedRandom, result); + } + + [Test] + public void CRC16RandomInstance() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context ctx = new CRC16Context(); + ctx.Init(); + ctx.Update(data); + byte[] result = ctx.Final(); + Assert.AreEqual(ExpectedRandom, result); + } + } +} diff --git a/DiscImageChef.Tests/Checksums/SHA1.cs b/DiscImageChef.Tests/Checksums/SHA1.cs new file mode 100644 index 000000000..8c02b5def --- /dev/null +++ b/DiscImageChef.Tests/Checksums/SHA1.cs @@ -0,0 +1,119 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : CRC16.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; +using NUnit.Framework; +using DiscImageChef.Checksums; +using System.IO; + +namespace DiscImageChef.Tests.Checksums +{ + [TestFixture] + public class CRC16 + { + static readonly byte[] ExpectedEmpty = { 0x00, 0x00 }; + static readonly byte[] ExpectedRandom = { 0x2d, 0x6d }; + + [Test] + public void CRC16EmptyFile() + { + byte[] result = CRC16Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty")); + Assert.AreEqual(ExpectedEmpty, result); + } + + [Test] + public void CRC16EmptyData() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context.Data(data, out byte[] result); + Assert.AreEqual(ExpectedEmpty, result); + } + + [Test] + public void CRC16EmptyInstance() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context ctx = new CRC16Context(); + ctx.Init(); + ctx.Update(data); + byte[] result = ctx.Final(); + Assert.AreEqual(ExpectedEmpty, result); + } + + [Test] + public void CRC16RandomFile() + { + byte[] result = CRC16Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random")); + Assert.AreEqual(ExpectedRandom, result); + } + + [Test] + public void CRC16RandomData() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context.Data(data, out byte[] result); + Assert.AreEqual(ExpectedRandom, result); + } + + [Test] + public void CRC16RandomInstance() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context ctx = new CRC16Context(); + ctx.Init(); + ctx.Update(data); + byte[] result = ctx.Final(); + Assert.AreEqual(ExpectedRandom, result); + } + } +} diff --git a/DiscImageChef.Tests/Checksums/SHA256.cs b/DiscImageChef.Tests/Checksums/SHA256.cs new file mode 100644 index 000000000..8c02b5def --- /dev/null +++ b/DiscImageChef.Tests/Checksums/SHA256.cs @@ -0,0 +1,119 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : CRC16.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; +using NUnit.Framework; +using DiscImageChef.Checksums; +using System.IO; + +namespace DiscImageChef.Tests.Checksums +{ + [TestFixture] + public class CRC16 + { + static readonly byte[] ExpectedEmpty = { 0x00, 0x00 }; + static readonly byte[] ExpectedRandom = { 0x2d, 0x6d }; + + [Test] + public void CRC16EmptyFile() + { + byte[] result = CRC16Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty")); + Assert.AreEqual(ExpectedEmpty, result); + } + + [Test] + public void CRC16EmptyData() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context.Data(data, out byte[] result); + Assert.AreEqual(ExpectedEmpty, result); + } + + [Test] + public void CRC16EmptyInstance() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context ctx = new CRC16Context(); + ctx.Init(); + ctx.Update(data); + byte[] result = ctx.Final(); + Assert.AreEqual(ExpectedEmpty, result); + } + + [Test] + public void CRC16RandomFile() + { + byte[] result = CRC16Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random")); + Assert.AreEqual(ExpectedRandom, result); + } + + [Test] + public void CRC16RandomData() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context.Data(data, out byte[] result); + Assert.AreEqual(ExpectedRandom, result); + } + + [Test] + public void CRC16RandomInstance() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context ctx = new CRC16Context(); + ctx.Init(); + ctx.Update(data); + byte[] result = ctx.Final(); + Assert.AreEqual(ExpectedRandom, result); + } + } +} diff --git a/DiscImageChef.Tests/Checksums/SHA384.cs b/DiscImageChef.Tests/Checksums/SHA384.cs new file mode 100644 index 000000000..8c02b5def --- /dev/null +++ b/DiscImageChef.Tests/Checksums/SHA384.cs @@ -0,0 +1,119 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : CRC16.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; +using NUnit.Framework; +using DiscImageChef.Checksums; +using System.IO; + +namespace DiscImageChef.Tests.Checksums +{ + [TestFixture] + public class CRC16 + { + static readonly byte[] ExpectedEmpty = { 0x00, 0x00 }; + static readonly byte[] ExpectedRandom = { 0x2d, 0x6d }; + + [Test] + public void CRC16EmptyFile() + { + byte[] result = CRC16Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty")); + Assert.AreEqual(ExpectedEmpty, result); + } + + [Test] + public void CRC16EmptyData() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context.Data(data, out byte[] result); + Assert.AreEqual(ExpectedEmpty, result); + } + + [Test] + public void CRC16EmptyInstance() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context ctx = new CRC16Context(); + ctx.Init(); + ctx.Update(data); + byte[] result = ctx.Final(); + Assert.AreEqual(ExpectedEmpty, result); + } + + [Test] + public void CRC16RandomFile() + { + byte[] result = CRC16Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random")); + Assert.AreEqual(ExpectedRandom, result); + } + + [Test] + public void CRC16RandomData() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context.Data(data, out byte[] result); + Assert.AreEqual(ExpectedRandom, result); + } + + [Test] + public void CRC16RandomInstance() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context ctx = new CRC16Context(); + ctx.Init(); + ctx.Update(data); + byte[] result = ctx.Final(); + Assert.AreEqual(ExpectedRandom, result); + } + } +} diff --git a/DiscImageChef.Tests/Checksums/SHA512.cs b/DiscImageChef.Tests/Checksums/SHA512.cs new file mode 100644 index 000000000..8c02b5def --- /dev/null +++ b/DiscImageChef.Tests/Checksums/SHA512.cs @@ -0,0 +1,119 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : CRC16.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; +using NUnit.Framework; +using DiscImageChef.Checksums; +using System.IO; + +namespace DiscImageChef.Tests.Checksums +{ + [TestFixture] + public class CRC16 + { + static readonly byte[] ExpectedEmpty = { 0x00, 0x00 }; + static readonly byte[] ExpectedRandom = { 0x2d, 0x6d }; + + [Test] + public void CRC16EmptyFile() + { + byte[] result = CRC16Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty")); + Assert.AreEqual(ExpectedEmpty, result); + } + + [Test] + public void CRC16EmptyData() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context.Data(data, out byte[] result); + Assert.AreEqual(ExpectedEmpty, result); + } + + [Test] + public void CRC16EmptyInstance() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context ctx = new CRC16Context(); + ctx.Init(); + ctx.Update(data); + byte[] result = ctx.Final(); + Assert.AreEqual(ExpectedEmpty, result); + } + + [Test] + public void CRC16RandomFile() + { + byte[] result = CRC16Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random")); + Assert.AreEqual(ExpectedRandom, result); + } + + [Test] + public void CRC16RandomData() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context.Data(data, out byte[] result); + Assert.AreEqual(ExpectedRandom, result); + } + + [Test] + public void CRC16RandomInstance() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context ctx = new CRC16Context(); + ctx.Init(); + ctx.Update(data); + byte[] result = ctx.Final(); + Assert.AreEqual(ExpectedRandom, result); + } + } +} diff --git a/DiscImageChef.Tests/Checksums/SpamSum.cs b/DiscImageChef.Tests/Checksums/SpamSum.cs new file mode 100644 index 000000000..8c02b5def --- /dev/null +++ b/DiscImageChef.Tests/Checksums/SpamSum.cs @@ -0,0 +1,119 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : CRC16.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; +using NUnit.Framework; +using DiscImageChef.Checksums; +using System.IO; + +namespace DiscImageChef.Tests.Checksums +{ + [TestFixture] + public class CRC16 + { + static readonly byte[] ExpectedEmpty = { 0x00, 0x00 }; + static readonly byte[] ExpectedRandom = { 0x2d, 0x6d }; + + [Test] + public void CRC16EmptyFile() + { + byte[] result = CRC16Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty")); + Assert.AreEqual(ExpectedEmpty, result); + } + + [Test] + public void CRC16EmptyData() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context.Data(data, out byte[] result); + Assert.AreEqual(ExpectedEmpty, result); + } + + [Test] + public void CRC16EmptyInstance() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context ctx = new CRC16Context(); + ctx.Init(); + ctx.Update(data); + byte[] result = ctx.Final(); + Assert.AreEqual(ExpectedEmpty, result); + } + + [Test] + public void CRC16RandomFile() + { + byte[] result = CRC16Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random")); + Assert.AreEqual(ExpectedRandom, result); + } + + [Test] + public void CRC16RandomData() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context.Data(data, out byte[] result); + Assert.AreEqual(ExpectedRandom, result); + } + + [Test] + public void CRC16RandomInstance() + { + byte[] data = new byte[1048576]; + FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "random"), FileMode.Open, FileAccess.Read); + fs.Read(data, 0, 1048576); + fs.Close(); + fs.Dispose(); + CRC16Context ctx = new CRC16Context(); + ctx.Init(); + ctx.Update(data); + byte[] result = ctx.Final(); + Assert.AreEqual(ExpectedRandom, result); + } + } +} diff --git a/DiscImageChef.Tests/Consts.cs b/DiscImageChef.Tests/Consts.cs new file mode 100644 index 000000000..96f531772 --- /dev/null +++ b/DiscImageChef.Tests/Consts.cs @@ -0,0 +1,47 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : Consts.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; +namespace DiscImageChef.Tests +{ + public class Consts + { + public Consts() + { + } + } +} diff --git a/DiscImageChef.Tests/DiscImageChef.Tests.csproj b/DiscImageChef.Tests/DiscImageChef.Tests.csproj new file mode 100644 index 000000000..428f503cf --- /dev/null +++ b/DiscImageChef.Tests/DiscImageChef.Tests.csproj @@ -0,0 +1,36 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {B2ABC1F2-C365-4515-9F23-A5725050CC48} + Library + DiscImageChef.Tests + DiscImageChef.Tests + v4.6.1 + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + + + true + bin\Release + prompt + 4 + + + + + + + + + \ No newline at end of file diff --git a/DiscImageChef.Tests/Test.cs b/DiscImageChef.Tests/Test.cs new file mode 100644 index 000000000..965c0e51d --- /dev/null +++ b/DiscImageChef.Tests/Test.cs @@ -0,0 +1,50 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : Test.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 NUnit.Framework; +using System; +namespace DiscImageChef.Tests + { + [TestFixture()] + public class Test + { + [Test()] + public void TestCase() + { + } + } + } diff --git a/DiscImageChef.Tests/packages.config b/DiscImageChef.Tests/packages.config new file mode 100644 index 000000000..01c187ccb --- /dev/null +++ b/DiscImageChef.Tests/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file