Files
Govor/Govor.API.Tests/UnitTests/Services/PasswordHasherTests.cs
T
Artemy 4f3f4ec066 Refactor to introduce Govor.Application and Govor.Contracts layers
Moved service implementations and interfaces from Govor.API and Govor.Core to new Govor.Application and Govor.Contracts projects. Updated namespaces and references throughout the solution. Added custom exception classes for authentication and invite services. Adjusted dependency injection and project references to use the new structure. This refactor improves separation of concerns and prepares the codebase for better maintainability and scalability.
2025-06-25 15:16:14 +07:00

51 lines
1.3 KiB
C#

using AutoFixture;
using Govor.Application.Services;
using Govor.Core.Infrastructure.Extensions;
namespace Govor.API.Tests.UnitTests.Services;
[TestFixture]
public class PasswordHasherTests
{
private IPasswordHasher _passwordHasher;
private Fixture _fixture;
[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);
}
}