using JSMR.Infrastructure.Data.Repositories.VoiceWorks;
using Shouldly;

namespace JSMR.Tests.Unit;

public class MySqlBooleanQueryTests
{
    [Fact]
    public void Normalize_Basic_Usage()
    {
        string normalizedValue = MySqlBooleanQuery.Normalize("value1 value2|value3 -value4 \"value 5\"");

        normalizedValue.ShouldBe("+value1 +(value2 value3) -value4 +\"value 5\"");
    }

    [Fact]
    public void Normalize_Unusual_Usage()
    {
        string normalizedValue = MySqlBooleanQuery.Normalize("+value1 +(value2 value3) -value4 +\"value 5\"");

        normalizedValue.ShouldBe("+value1 +(value2 value3) -value4 +\"value 5\"");
    }

    [Fact]
    public void Normalize_Bad_Data()
    {
        string normalizedValue = MySqlBooleanQuery.Normalize("value1 + value2 - value3");

        normalizedValue.ShouldBe("+value1 +value2 +value3");
    }

    [Fact]
    public void Normalize_Bad_Or_Data()
    {
        string normalizedValue = MySqlBooleanQuery.Normalize("value1 | value2");

        normalizedValue.ShouldBe("+value1 +value2");
    }
}
