mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 11:44:56 +00:00
Refactor: migrate Core -> Domain and reorganize projects
Large refactor that renames/moves core types into a new Govor.Domain surface and reorganizes the Application layer. Models, configurations, migrations and many files moved from Govor.Core/Govor.Data to Govor.Domain; numerous Application services, interfaces and implementations were relocated or added (authentication, friends, messages, medias, push notifications, user sessions, storage, synching, private chats, etc.). Tests updated to use Govor.Domain namespaces and adjusted project references (removed Govor.Data reference from API tests). Also updated API, Hub and mapping code and project files to reflect the new structure and naming. This is primarily a codebase-wide namespace and module reorganization to establish a Domain project and restructure application services.
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
using AutoFixture;
|
||||
using Govor.Domain.Common.Constants;
|
||||
using Govor.Domain.Models;
|
||||
|
||||
namespace Govor.API.Tests.UnitTests.Infrastructure.Validators;
|
||||
|
||||
[TestFixture]
|
||||
public class InvitationConstantsTests
|
||||
{
|
||||
private IObjectValidator<Invitation> _messageValidator;
|
||||
private Fixture _fixture;
|
||||
|
||||
public InvitationConstantsTests()
|
||||
{
|
||||
_messageValidator = new InvitationConstants();
|
||||
|
||||
_fixture = new Fixture();
|
||||
|
||||
_fixture.Behaviors
|
||||
.OfType<ThrowingRecursionBehavior>()
|
||||
.ToList()
|
||||
.ForEach(b => _fixture.Behaviors.Remove(b));
|
||||
|
||||
_fixture.Behaviors.Add(new OmitOnRecursionBehavior());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Given_ValidInvitation_When_Validate_Then_Returns_True()
|
||||
{
|
||||
var invitation = _fixture.Create<Invitation>();
|
||||
|
||||
// Act & Assert
|
||||
Assert.DoesNotThrow( () => _messageValidator.Validate(invitation));
|
||||
Assert.That(_messageValidator.TryValidate(invitation), Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Given_NullInvitation_When_Validate_Then_Returns_False()
|
||||
{
|
||||
// Act & Assert
|
||||
Assert.Throws<InvalidObjectException<Invitation>>( () => _messageValidator.Validate(default));
|
||||
Assert.That(_messageValidator.TryValidate(default), Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Given_EmptyInvitationId_When_Validate_Then_Returns_False()
|
||||
{
|
||||
// Arrange
|
||||
var invitation = _fixture.Create<Invitation>();
|
||||
invitation.Id = Guid.Empty;
|
||||
|
||||
// Act & Assert
|
||||
Assert.Throws<InvalidObjectException<Invitation>>( () => _messageValidator.Validate(invitation));
|
||||
Assert.That(_messageValidator.TryValidate(invitation), Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Given_EmptyInvitationCreationDate_When_Validate_Then_Returns_False()
|
||||
{
|
||||
// Arrange
|
||||
var invitation = _fixture.Create<Invitation>();
|
||||
invitation.DateCreated = DateTime.MinValue;
|
||||
|
||||
// Act & Assert
|
||||
Assert.Throws<InvalidObjectException<Invitation>>( () => _messageValidator.Validate(invitation));
|
||||
Assert.That(_messageValidator.TryValidate(invitation), Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Given_InvalidEndDatesAndIsActive_When_Validate_Then_Returns_False()
|
||||
{
|
||||
// Arrange
|
||||
var invitation = _fixture.Create<Invitation>();
|
||||
invitation.EndDate = invitation.DateCreated.AddDays(-1);
|
||||
invitation.IsActive = true;
|
||||
// Act & Assert
|
||||
Assert.Throws<InvalidObjectException<Invitation>>( () => _messageValidator.Validate(invitation));
|
||||
Assert.That(_messageValidator.TryValidate(invitation), Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Given_InvalidMaxParticipantsAndIsActive_When_Validate_Then_Returns_False()
|
||||
{
|
||||
// Arrange
|
||||
var invitation = _fixture.Create<Invitation>();
|
||||
invitation.MaxParticipants = new Random().Next(-5, 0);
|
||||
invitation.IsActive = true;
|
||||
|
||||
// Act & Assert
|
||||
Assert.Throws<InvalidObjectException<Invitation>>( () => _messageValidator.Validate(invitation));
|
||||
Assert.That(_messageValidator.TryValidate(invitation), Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Given_InvalidCode_When_Validate_Then_Returns_False()
|
||||
{
|
||||
// Arrange
|
||||
var invitation = _fixture.Create<Invitation>();
|
||||
invitation.Code = string.Empty;
|
||||
|
||||
// Act & Assert
|
||||
Assert.Throws<InvalidObjectException<Invitation>>( () => _messageValidator.Validate(invitation));
|
||||
Assert.That(_messageValidator.TryValidate(invitation), Is.False);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user