mirror of
https://github.com/Govor-team/Govor.git
synced 2026-11-16 20:56:03 +00:00
2d99c57a3b
Consolidate server tests under tests/, upgrade them to .NET 10, and add CI coverage thresholds and reports. Expand API and application boundary coverage while fixing related issues in media handling, friend blocking, session crypto, presence, username validation, and local storage.
49 lines
1.2 KiB
C#
49 lines
1.2 KiB
C#
using AutoFixture;
|
|
|
|
namespace Govor.Application.Tests.Services;
|
|
|
|
[TestFixture]
|
|
public class PasswordHasherTests
|
|
{
|
|
private IPasswordHasher _passwordHasher = null!;
|
|
private Fixture _fixture = null!;
|
|
[SetUp]
|
|
public void StarUp()
|
|
{
|
|
_fixture = new Fixture();
|
|
_passwordHasher = new PasswordHasher();
|
|
}
|
|
|
|
[Test]
|
|
public void Given_Password_When_Hash_Then_Hash_And_Verify_Then_Result_Should_Be_True()
|
|
{
|
|
// Arrange
|
|
string password = _fixture.Create<string>();
|
|
|
|
// Act
|
|
string hash = _passwordHasher.Hash(password);
|
|
|
|
var result = _passwordHasher.Verify(password, hash);
|
|
|
|
// Assert
|
|
Assert.That(hash, Is.Not.EqualTo(password));
|
|
Assert.That(result, Is.True);
|
|
}
|
|
|
|
[Test]
|
|
public void Given_Password_NotPassword_When_Hash_Should_Not_Be_True_Then_Result_Should_Be_False()
|
|
{
|
|
// Arrange
|
|
string password = _fixture.Create<string>();
|
|
string notPassword = _fixture.Create<string>();
|
|
|
|
// Act
|
|
string hash = _passwordHasher.Hash(password);
|
|
|
|
var result = _passwordHasher.Verify(notPassword, hash);
|
|
|
|
// Assert
|
|
Assert.That(result, Is.False);
|
|
}
|
|
}
|