--- /dev/null
+/* ---------------------------------------------------------------------------------------------- */
+/* MHash-384 - Simple fast portable secure hashing library */
+/* Copyright(c) 2016-2020 LoRd_MuldeR <mulder2@gmx.de> */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining a copy of this software */
+/* and associated documentation files (the "Software"), to deal in the Software without */
+/* restriction, including without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the */
+/* Software is furnished to do so, subject to the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be included in all copies or */
+/* substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING */
+/* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
+/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, */
+/* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
+/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/* ---------------------------------------------------------------------------------------------- */
+
+using System;
+
+namespace com.muldersoft.mhash384.test.mono_compat
+{
+ public sealed class TestClassAttribute : Attribute { }
+
+ public sealed class TestMethodAttribute : Attribute { }
+
+ public sealed class ClassInitializeAttribute : Attribute { }
+
+ public sealed class ClassCleanupAttribute : Attribute { }
+
+ public sealed class TestContext { }
+
+ public class AssertFailedException : Exception
+ {
+ public AssertFailedException(string message) : base(message)
+ {
+ }
+ }
+
+ public static class Assert
+ {
+ public static void Fail(String message)
+ {
+ throw new AssertFailedException(message);
+ }
+ }
+}
\ No newline at end of file
using System;
using System.Text;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Diagnostics;
+#if !__MonoCS__
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+#else
+using com.muldersoft.mhash384.test.mono_compat;
+#endif
+
namespace com.muldersoft.mhash384.test
{
[TestClass]
{
private static bool m_success;
- [ClassInitialize()]
+ [ClassInitialize]
public static void Initialize(TestContext testContext)
{
Trace.WriteLine(String.Format("MHash-384 v{0:D}.{1:D2}-{2:D}, Microsoft.NET v{3} [{4:D}-Bit]\n", MHash384.VERSION_MAJOR, MHash384.VERSION_MINOR, MHash384.VERSION_PATCH, System.Environment.Version, System.Environment.Is64BitProcess ? 64 : 32));
m_success = true;
}
- [ClassCleanup()]
+ [ClassCleanup]
public static void Cleanup()
{
if(m_success)
bool matches = digest.Equals(expected, StringComparison.OrdinalIgnoreCase);
m_success &= matches;
Trace.WriteLine(String.Format("{0} - {1}", digest, matches ? "OK" : "Error!"));
- Assert.IsTrue(matches);
+ if(!matches)
+ {
+ Assert.Fail("Computed digest does *not* match reference!");
+ }
}
private static string GetDigest(uint repetitions, string test)
/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/* ---------------------------------------------------------------------------------------------- */
-using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
+#if !__MonoCS__
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+#else
+using com.muldersoft.mhash384.test.mono_compat;
+#endif
+
namespace com.muldersoft.mhash384.test
{
class TestDriver
}
catch (TargetInvocationException targetInvocationException)
{
- if (typeof(AssertFailedException).IsAssignableFrom(targetInvocationException.GetType()))
+ Exception innerException = targetInvocationException.InnerException;
+ if (!Object.ReferenceEquals(innerException, null))
{
- throw targetInvocationException;
+ Console.WriteLine(@"Test failed: ""{0}""", innerException.Message);
}
}
}