using ZB.MOM.WW.CBDD.Core.Collections;
using ZB.MOM.WW.CBDD.Core.Metadata;

namespace ZB.MOM.WW.CBDD.Shared;

/// <summary>
///     Extended test context that inherits from TestDbContext.
///     Used to verify that collection initialization works correctly with inheritance.
/// </summary>
public partial class TestExtendedDbContext : TestDbContext
{
    /// <summary>
    ///     Initializes a new instance of the <see cref="TestExtendedDbContext" /> class.
    /// </summary>
    /// <param name="databasePath">Database file path.</param>
    public TestExtendedDbContext(string databasePath) : base(databasePath)
    {
        InitializeCollections();
    }

    /// <summary>
    ///     Gets or sets the extended entities.
    /// </summary>
    public DocumentCollection<int, ExtendedEntity> ExtendedEntities { get; set; } = null!;

    /// <inheritdoc />
    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        base.OnModelCreating(modelBuilder);

        modelBuilder.Entity<ExtendedEntity>()
            .ToCollection("extended_entities")
            .HasKey(e => e.Id);
    }
}