From 273e404f60a629fe532c28b524fd7fb24d600acc Mon Sep 17 00:00:00 2001 From: dbuechel Date: Fri, 15 Feb 2019 10:11:31 +0100 Subject: [PATCH] SEBWIN-296: Implemented unit tests for hash algorithm. --- .../Cryptography/HashAlgorithmTests.cs | 34 +++++++++++++++++++ ...ExamBrowser.Configuration.UnitTests.csproj | 1 + 2 files changed, 35 insertions(+) create mode 100644 SafeExamBrowser.Configuration.UnitTests/Cryptography/HashAlgorithmTests.cs diff --git a/SafeExamBrowser.Configuration.UnitTests/Cryptography/HashAlgorithmTests.cs b/SafeExamBrowser.Configuration.UnitTests/Cryptography/HashAlgorithmTests.cs new file mode 100644 index 00000000..701a06e1 --- /dev/null +++ b/SafeExamBrowser.Configuration.UnitTests/Cryptography/HashAlgorithmTests.cs @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET) + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +using Microsoft.VisualStudio.TestTools.UnitTesting; +using SafeExamBrowser.Configuration.Cryptography; + +namespace SafeExamBrowser.Configuration.UnitTests.Cryptography +{ + [TestClass] + public class HashAlgorithmTests + { + private HashAlgorithm sut; + + [TestInitialize] + public void Initialize() + { + sut = new HashAlgorithm(); + } + + [TestMethod] + public void MustGeneratePasswordHashCorrectly() + { + var hash = "4adfa806cb610693a6200e4cdbdafeaf352876a35f964a781d691457df9cd378"; + var generated = sut.GenerateHashFor("blabbedyblubbedy"); + + Assert.AreEqual(hash, generated); + } + } +} diff --git a/SafeExamBrowser.Configuration.UnitTests/SafeExamBrowser.Configuration.UnitTests.csproj b/SafeExamBrowser.Configuration.UnitTests/SafeExamBrowser.Configuration.UnitTests.csproj index c6721971..38af6872 100644 --- a/SafeExamBrowser.Configuration.UnitTests/SafeExamBrowser.Configuration.UnitTests.csproj +++ b/SafeExamBrowser.Configuration.UnitTests/SafeExamBrowser.Configuration.UnitTests.csproj @@ -84,6 +84,7 @@ +