Files
MileageTraker/Web.Tests/Utility/CryptoTests.cs
T

42 lines
1011 B
C#

using System;
using MileageTraker.Web.Utility;
using NUnit.Framework;
namespace Web.Tests.Membership
{
[TestFixture]
public class CryptoTests
{
[Test]
public void HashPassword_Test()
{
const string password = "1da";
var hashPassword = Crypto.HashPassword(password);
Assert.That(hashPassword, Is.Not.EqualTo(password));
}
[Test]
public void VerifyHashPassword_Test()
{
const string password = "1daFH2k1jv!3dsa";
var hashPassword = Crypto.HashPassword(password);
bool verifyHashedPassword = Crypto.VerifyHashedPassword(hashPassword, password);
Assert.IsTrue(verifyHashedPassword);
}
[Test]
public void VerifyHashPassword_NotBase64Hash_Test()
{
bool verifyHashedPassword = Crypto.VerifyHashedPassword("notbase64", "not a password");
Assert.IsFalse(verifyHashedPassword);
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void VerifyHashPassword_NullHash_Test()
{
Crypto.VerifyHashedPassword(null, "not a password");
}
}
}