Control - Repository initialisation.

This commit is contained in:
Andy Howard
2025-01-09 16:30:52 +00:00
parent d015470f58
commit 4a72043f00
103 changed files with 4324 additions and 469 deletions
@@ -0,0 +1,56 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.Helpers;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
namespace Sarand.BusinessMgr.Test.Web.Portal.App
{
//=======================================================================
[TestClass]
public class SbmApplication_Database_Tester : SbmPortalApp_Tester_Base
{
//-------------------------------------------------------------------
private static Regex reHex = new Regex("^(?:[A-F0-9]{2})+$", RegexOptions.IgnoreCase);
//-------------------------------------------------------------------
[TestMethod]
public void Test_PasswordEncoding()
{
Assert.IsNotNull(BusMgrDatabase);
StringAssert.Matches(BusMgrDatabase.EncodePassword_Hex(""), reHex);
// Iterate using random filename (8.3).
for (int i = 0; i < 1000; i++)
StringAssert.Matches(BusMgrDatabase.EncodePassword_Hex(Path.GetRandomFileName()), reHex);
}
//-------------------------------------------------------------------
[TestMethod]
public void Test_PasswordCompare()
{
Assert.IsNotNull(BusMgrDatabase);
Dictionary<string, string> passwordHashes = new Dictionary<string, string>();
// Iterate using random filename (8.3).
for (int i = 0; i < 200; i++)
{
string password = Path.GetRandomFileName();
string passwordHash = BusMgrDatabase.EncodePassword_Hex(password);
StringAssert.Matches(passwordHash, reHex);
passwordHashes.Add(password, passwordHash);
}
foreach (string password in passwordHashes.Keys)
{
string passwordHash = passwordHashes.GetValueOrDefault(password);
StringAssert.Matches(passwordHash, reHex);
Assert.IsTrue(BusMgrDatabase.ComparePassword_Hex(password, passwordHash));
}
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -13,7 +13,7 @@ namespace Sarand.BusinessMgr.Test.Web.Portal.App
Assert.IsNotNull(App);
}
//-------------------------------------------------------------------
}
//=======================================================================
//-------------------------------------------------------------------
}
//=======================================================================
}