using FluentAssertions;
using MktXService.Domain.AggregatesModel.TwitterAccountAggregate;
using MktXService.Domain.Exceptions;
using Xunit;

namespace MktXService.UnitTests.Domain;

/// <summary>
/// EN: Unit tests for Twitter account aggregate behavior.
/// VI: Unit tests cho hành vi aggregate tài khoản Twitter.
/// </summary>
public class TwitterAccountAggregateTests
{
    [Fact]
    public void CreateAccount_ShouldStartInPendingStatus()
    {
        // Act
        var account = new TwitterAccount(
            Guid.NewGuid(),
            "twitter-user-1",
            "goodgo_user",
            "encrypted-token",
            "encrypted-secret");

        // Assert
        account.Status.Should().Be(TwitterAccountStatus.Pending);
        account.OAuthToken.Should().Be("encrypted-token");
    }

    [Fact]
    public void Activate_ShouldMoveStatusToActive()
    {
        // Arrange
        var account = new TwitterAccount(
            Guid.NewGuid(),
            "twitter-user-2",
            "goodgo_user2",
            "token",
            "secret");

        // Act
        account.Activate();

        // Assert
        account.Status.Should().Be(TwitterAccountStatus.Active);
    }

    [Fact]
    public void Activate_WhenDisconnected_ShouldThrowDomainException()
    {
        // Arrange
        var account = new TwitterAccount(
            Guid.NewGuid(),
            "twitter-user-3",
            "goodgo_user3",
            "token",
            "secret");
        account.Disconnect();

        // Act
        var action = () => account.Activate();

        // Assert
        action.Should().Throw<TwitterAccountDomainException>();
    }
}
