using System.Globalization;
using PersonalToolBox.Views;

namespace PersonalToolBox.Tests.Views;

public class ConverterTests
{
    [Fact]
    public void BoolToOpacityConverter_True_ReturnsOne()
    {
        var converter = new BoolToOpacityConverter();

        var result = converter.Convert(true, typeof(double), null, CultureInfo.InvariantCulture);

        Assert.Equal(1.0, result);
    }

    [Fact]
    public void BoolToOpacityConverter_False_ReturnsZeroPointFour()
    {
        var converter = new BoolToOpacityConverter();

        var result = converter.Convert(false, typeof(double), null, CultureInfo.InvariantCulture);

        Assert.Equal(0.4, result);
    }

    [Fact]
    public void BoolToOpacityConverter_NonBool_ReturnsZeroPointFour()
    {
        var converter = new BoolToOpacityConverter();

        var result = converter.Convert("not a bool", typeof(double), null, CultureInfo.InvariantCulture);

        Assert.Equal(0.4, result);
    }

    [Fact]
    public void FirstCharConverter_NormalString_ReturnsFirstChar()
    {
        var converter = new FirstCharConverter();

        var result = converter.Convert("Postman", typeof(string), null, CultureInfo.InvariantCulture);

        Assert.Equal("P", result);
    }

    [Fact]
    public void FirstCharConverter_EmptyString_ReturnsQuestionMark()
    {
        var converter = new FirstCharConverter();

        var result = converter.Convert("", typeof(string), null, CultureInfo.InvariantCulture);

        Assert.Equal("?", result);
    }

    [Fact]
    public void FirstCharConverter_Null_ReturnsQuestionMark()
    {
        var converter = new FirstCharConverter();

        var result = converter.Convert(null!, typeof(string), null, CultureInfo.InvariantCulture);

        Assert.Equal("?", result);
    }
}
