using Microsoft.EntityFrameworkCore.Query.Associations.OwnedJson;
using Microsoft.EntityFrameworkCore.TestUtilities;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;

namespace EntityFrameworkCore.Jet.FunctionalTests.Query.Associations.OwnedJson;

public class OwnedJsonStructuralEqualityJetTest(
    OwnedJsonJetFixture fixture,
    ITestOutputHelper testOutputHelper)
    : OwnedJsonStructuralEqualityRelationalTestBase<OwnedJsonJetFixture>(fixture, testOutputHelper)
{
    public override async Task Two_associates()
    {
        await base.Two_associates();

        AssertSql(
            """
SELECT `r`.`Id`, `r`.`Name`, `r`.`AssociateCollection`, `r`.`OptionalAssociate`, `r`.`RequiredAssociate`
FROM `RootEntity` AS `r`
WHERE FALSE
""");
    }

    public override async Task Two_nested_associates()
    {
        await base.Two_nested_associates();

        AssertSql(
            """
SELECT `r`.`Id`, `r`.`Name`, `r`.`AssociateCollection`, `r`.`OptionalAssociate`, `r`.`RequiredAssociate`
FROM `RootEntity` AS `r`
WHERE FALSE
""");
    }

    public override async Task Not_equals()
    {
        await base.Not_equals();

        AssertSql(
            """
SELECT `r`.`Id`, `r`.`Name`, `r`.`AssociateCollection`, `r`.`OptionalAssociate`, `r`.`RequiredAssociate`
FROM `RootEntity` AS `r`
WHERE FALSE
""");
    }

    public override async Task Associate_with_inline_null()
    {
        await base.Associate_with_inline_null();

        AssertSql(
            """
SELECT `r`.`Id`, `r`.`Name`, `r`.`AssociateCollection`, `r`.`OptionalAssociate`, `r`.`RequiredAssociate`
FROM `RootEntity` AS `r`
WHERE (`r`.`OptionalAssociate`) IS NULL
""");
    }

    public override async Task Associate_with_parameter_null()
    {
        await base.Associate_with_parameter_null();

        AssertSql(
            """
SELECT `r`.`Id`, `r`.`Name`, `r`.`AssociateCollection`, `r`.`OptionalAssociate`, `r`.`RequiredAssociate`
FROM `RootEntity` AS `r`
WHERE FALSE
""");
    }

    public override async Task Nested_associate_with_inline_null()
    {
        await base.Nested_associate_with_inline_null();

        AssertSql(
            """
SELECT [r].[Id], [r].[Name], [r].[AssociateCollection], [r].[OptionalAssociate], [r].[RequiredAssociate]
FROM [RootEntity] AS [r]
WHERE JSON_QUERY([r].[RequiredAssociate], '$.OptionalNestedAssociate') IS NULL
""");
    }

    public override async Task Nested_associate_with_inline()
    {
        await base.Nested_associate_with_inline();

        AssertSql(
        );
    }

    public override async Task Nested_associate_with_parameter()
    {
        await base.Nested_associate_with_parameter();

        AssertSql(
        );
    }

    public override async Task Two_nested_collections()
    {
        await base.Two_nested_collections();

        AssertSql(
            """
SELECT `r`.`Id`, `r`.`Name`, `r`.`AssociateCollection`, `r`.`OptionalAssociate`, `r`.`RequiredAssociate`
FROM `RootEntity` AS `r`
WHERE FALSE
""");
    }

    public override async Task Nested_collection_with_inline()
    {
        await base.Nested_collection_with_inline();

        AssertSql(
        );
    }

    public override async Task Nested_collection_with_parameter()
    {
        await base.Nested_collection_with_parameter();

        AssertSql(
        );
    }

    #region Contains

    public override async Task Contains_with_inline()
    {
        await base.Contains_with_inline();

        AssertSql();
    }

    public override async Task Contains_with_parameter()
    {
        await base.Contains_with_parameter();

        AssertSql();
    }

    public override async Task Contains_with_operators_composed_on_the_collection()
    {
        await base.Contains_with_operators_composed_on_the_collection();

        AssertSql();
    }

    public override async Task Contains_with_nested_and_composed_operators()
    {
        await base.Contains_with_nested_and_composed_operators();

        AssertSql();
    }

    #endregion Contains

    [ConditionalFact]
    public virtual void Check_all_tests_overridden()
        => TestHelpers.AssertAllMethodsOverridden(GetType());
}
