// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Globalization;
using Microsoft.CmdPal.Ext.Calc.Helper;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Microsoft.CmdPal.Ext.Calc.UnitTests;

[TestClass]
public class QueryHelperTests
{
    private CultureInfo originalCulture;
    private CultureInfo originalUiCulture;

    [TestInitialize]
    public void Setup()
    {
        originalCulture = CultureInfo.CurrentCulture;
        CultureInfo.CurrentCulture = new CultureInfo("en-us", false);
        originalUiCulture = CultureInfo.CurrentUICulture;
        CultureInfo.CurrentUICulture = new CultureInfo("en-us", false);
    }

    [TestCleanup]
    public void CleanUp()
    {
        CultureInfo.CurrentCulture = originalCulture;
        CultureInfo.CurrentUICulture = originalUiCulture;
    }

    [DataTestMethod]
    [DataRow("2²", "4")]
    [DataRow("2³", "8")]
    [DataRow("2！", "2")]
    [DataRow("2\u00A0*\u00A02", "4")] // Non-breaking space
    [DataRow("20:10", "2")] // Colon as division
    public void Interpret_HandlesNormalizedInputs(string input, string expected)
    {
        var settings = new Settings();
        var result = QueryHelper.Query(input, settings, false, out _, (_, _) => { });

        Assert.IsNotNull(result);
        Assert.AreEqual(expected, result.Title);
    }
}
