using SportsDivision.Domain.Entities;
using SportsDivision.Domain.Enums;

namespace SportsDivision.Domain.Tests;

public class HighJumpAttemptTests
{
    [Fact]
    public void IsEliminated_ThreeConsecutiveFails_ReturnsTrue()
    {
        var attempt = new HighJumpAttempt
        {
            Attempt1 = HighJumpAttemptResult.Fail,
            Attempt2 = HighJumpAttemptResult.Fail,
            Attempt3 = HighJumpAttemptResult.Fail
        };

        Assert.True(attempt.IsEliminated);
    }

    [Fact]
    public void IsEliminated_ClearOnThird_ReturnsFalse()
    {
        var attempt = new HighJumpAttempt
        {
            Attempt1 = HighJumpAttemptResult.Fail,
            Attempt2 = HighJumpAttemptResult.Fail,
            Attempt3 = HighJumpAttemptResult.Clear
        };

        Assert.False(attempt.IsEliminated);
    }

    [Fact]
    public void IsEliminated_NoAttempts_ReturnsFalse()
    {
        var attempt = new HighJumpAttempt();
        Assert.False(attempt.IsEliminated);
    }

    [Fact]
    public void IsEliminated_PassAndFails_ReturnsFalse()
    {
        var attempt = new HighJumpAttempt
        {
            Attempt1 = HighJumpAttemptResult.Pass,
            Attempt2 = HighJumpAttemptResult.Fail,
            Attempt3 = HighJumpAttemptResult.Fail
        };

        Assert.False(attempt.IsEliminated);
    }

    [Fact]
    public void HasCleared_FirstAttemptClear_ReturnsTrue()
    {
        var attempt = new HighJumpAttempt
        {
            Attempt1 = HighJumpAttemptResult.Clear
        };

        Assert.True(attempt.HasCleared);
    }

    [Fact]
    public void HasCleared_SecondAttemptClear_ReturnsTrue()
    {
        var attempt = new HighJumpAttempt
        {
            Attempt1 = HighJumpAttemptResult.Fail,
            Attempt2 = HighJumpAttemptResult.Clear
        };

        Assert.True(attempt.HasCleared);
    }

    [Fact]
    public void HasCleared_ThirdAttemptClear_ReturnsTrue()
    {
        var attempt = new HighJumpAttempt
        {
            Attempt1 = HighJumpAttemptResult.Fail,
            Attempt2 = HighJumpAttemptResult.Fail,
            Attempt3 = HighJumpAttemptResult.Clear
        };

        Assert.True(attempt.HasCleared);
    }

    [Fact]
    public void HasCleared_AllFails_ReturnsFalse()
    {
        var attempt = new HighJumpAttempt
        {
            Attempt1 = HighJumpAttemptResult.Fail,
            Attempt2 = HighJumpAttemptResult.Fail,
            Attempt3 = HighJumpAttemptResult.Fail
        };

        Assert.False(attempt.HasCleared);
    }

    [Fact]
    public void HasCleared_NoAttempts_ReturnsFalse()
    {
        var attempt = new HighJumpAttempt();
        Assert.False(attempt.HasCleared);
    }

    [Fact]
    public void FailCount_AllFails_ReturnsThree()
    {
        var attempt = new HighJumpAttempt
        {
            Attempt1 = HighJumpAttemptResult.Fail,
            Attempt2 = HighJumpAttemptResult.Fail,
            Attempt3 = HighJumpAttemptResult.Fail
        };

        Assert.Equal(3, attempt.FailCount);
    }

    [Fact]
    public void FailCount_OneFail_ReturnsOne()
    {
        var attempt = new HighJumpAttempt
        {
            Attempt1 = HighJumpAttemptResult.Fail,
            Attempt2 = HighJumpAttemptResult.Clear
        };

        Assert.Equal(1, attempt.FailCount);
    }

    [Fact]
    public void FailCount_NoFails_ReturnsZero()
    {
        var attempt = new HighJumpAttempt
        {
            Attempt1 = HighJumpAttemptResult.Clear
        };

        Assert.Equal(0, attempt.FailCount);
    }

    [Fact]
    public void FailCount_PassesAndFails_CountsOnlyFails()
    {
        var attempt = new HighJumpAttempt
        {
            Attempt1 = HighJumpAttemptResult.Pass,
            Attempt2 = HighJumpAttemptResult.Fail,
            Attempt3 = HighJumpAttemptResult.Clear
        };

        Assert.Equal(1, attempt.FailCount);
    }

    [Fact]
    public void FailCount_NullAttempts_ReturnsZero()
    {
        var attempt = new HighJumpAttempt();
        Assert.Equal(0, attempt.FailCount);
    }
}
