Working on BackgroundService for Seq Logging
This commit is contained in:
parent
48578b216f
commit
7bcb7b0e66
9 changed files with 240 additions and 53 deletions
72
Tests/PasswordHasherTest.cs
Normal file
72
Tests/PasswordHasherTest.cs
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
using Autofac;
|
||||
using System.Data;
|
||||
using Insight.Database;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Core.Telemetry;
|
||||
using Core.Entities.Users;
|
||||
|
||||
namespace Tests
|
||||
{
|
||||
[TestClass]
|
||||
public class PasswordHasherTests : TestFixture
|
||||
{
|
||||
[TestMethod]
|
||||
public void HashPassword_ShouldCreateValidHashFormat()
|
||||
{
|
||||
// Arrange
|
||||
string password = "TestPassword123";
|
||||
|
||||
// Act
|
||||
string hashedPassword = PasswordHasher.HashPassword(password);
|
||||
string[] parts = hashedPassword.Split('.');
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(3, parts.Length);
|
||||
Assert.AreEqual("100000", parts[0]);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void VerifyPassword_WithCorrectPassword_ShouldReturnTrue()
|
||||
{
|
||||
// Arrange
|
||||
string password = "TestPassword123";
|
||||
string hashedPassword = PasswordHasher.HashPassword(password);
|
||||
|
||||
// Act
|
||||
bool result = PasswordHasher.VerifyPassword(hashedPassword, password);
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void VerifyPassword_WithWrongPassword_ShouldReturnFalse()
|
||||
{
|
||||
// Arrange
|
||||
string correctPassword = "TestPassword123";
|
||||
string wrongPassword = "WrongPassword123";
|
||||
string hashedPassword = PasswordHasher.HashPassword(correctPassword);
|
||||
|
||||
// Act
|
||||
bool result = PasswordHasher.VerifyPassword(hashedPassword, wrongPassword);
|
||||
|
||||
// Assert
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void VerifyPassword_WithInvalidHashFormat_ShouldReturnFalse()
|
||||
{
|
||||
// Arrange
|
||||
string password = "TestPassword123";
|
||||
string invalidHash = "InvalidHash";
|
||||
|
||||
// Act
|
||||
bool result = PasswordHasher.VerifyPassword(invalidHash, password);
|
||||
|
||||
// Assert
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue